I cannot get this USB RTC to work with my Raspberry and Ubuntu.
Nothing happens when I run sudo python3 test.py or sudo python3 Set_Time.py in the terminal. The terminal just locks up.
When I try to run either one of them in Thonny I get the following errors;
Traceback (most recent call last):
File “/home/ubuntu/USB-RTC/test.py”, line 19, in
bus = SMBus.SMBus()
File “/usr/local/lib/python3.6/dist-packages/PyMCP2221A/SMBus.py”, line 13, in init
self.mcp2221 = PyMCP2221A.PyMCP2221A(VID,PID,devnum)
File “/usr/local/lib/python3.6/dist-packages/PyMCP2221A/PyMCP2221A.py”, line 16, in init
File “hid.pyx”, line 142, in hid.device.open_path
OSError: open failed
All three links in your post are giving me errors. The ask ubuntu links give page not found, and the SB components link goes to a website maintenance notice.
Since it looks like that RTC is a USB device, have you tried using it with a different device like a Windows PC just to see if it gives an error there? It might help rule out hardware failure as a cause of your python errors.
Since it works with Raspberry Pi OS but not Ubuntu you can rule out a hardware fault with the unit.
It might be that Ubuntu isn’t detecting the USB device, either because of a lack of drivers (or linux equivalent to drivers) or some other fault.
Can you try running the command lsusb and see what is being detected by your system?
And you can get our latest projects and tips straight away by following us on: