USB RTC with Ubuntu

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
self.mcp2221a.open_path(hid.enumerate(VID, PID)[devnum][“path”])
File “hid.pyx”, line 142, in hid.device.open_path
OSError: open failed

https://askubuntu.com/questions/1430262/raspberry-real-time-clock-with-ubuntuhttps://askubuntu.com/questions/1432003/raspberry-rtc-with-ununtu-problem

Hi Don,

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.

Hi Trent. Thank you for the reply.

The SB components site did appear to be down for awhile. It’s back up now.

Ii works with a Raspberry running Raspberrian. But it does not work with a Raspberry running Ubuntu 18.4, and I need to use Ubuntu for the project that I am working on.

Hi Don,

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?

2 Likes