Compatibility of Adafruit PCF8523 RTC with Micropython

I have a project using a Plasma2040 running Micropython which controls addressable LED’s and a 4 digit LED display via a Qwiic interface. I would like to incorporate an Adafruit PCF8523 RTC which also has a Qwiic interface but the information for this device does not talk about micropython. Is it conceptually possible that I could incorporate both devices ( 4 digit display and RTC ) on the same I2C bus run from a micropython programme on the Plasma2040. At present the 4 digit display only shows hours (and not real time anyway) but I would like to extend it to show real time to minutes and hours (using the available 4 digits) derived from the RTC. If there is a compatibility issue I don’t want to waste a lot of time with something that might be impossible. Thanks.

Just check the I2C-addresses of both devices. If they are different, you should have no problems. You will find plenty of Micropython code for this RTC, but of course not on Adafruit-sites.

Thank you bablokb, now that I know it is conceptually possible I shall give it a try.

I now realise that my fundamental problem is a simple lack of knowledge!!! As both the 4 digit display and RTC I am using are from Adafruit, they provide virtually no support that is micropython oriented. When I look at the information they have, I realise that I simply don’t know if the libraries they provide for Circuitpython will be of any use in my case as I am committed to micropython by the existing code already written and tested for the primary operation of the Plasma2040. On top of that I also realise that I simply don’t know enough about I2C addressing and control in software. I would appreciate being pointed in the direction of some simple guides and code examples to achieve the stated aims in my original post.
Thank you

You can find many simple guides regarding I2C. The main problem with I2C is not the low-level stuff (addressing for example is simple, it is just a number). The problem of I2C is that every device uses it’s own “language”.

I wouldn’t give up in your case. You could try this driver: esp8266-upy/pcf8523 at master · mchobby/esp8266-upy · GitHub. For the 4-digit display, it depends on the chip. The Adafruit-documentation should give you a hint.

BTW: I once ported a micropython-lib for a 4-digit display from micropython to circuitpython. It was for the TM1637-chip: GitHub - mcauser/micropython-tm1637: MicroPython driver for TM1637 quad 7-segment LED modules. But once you have the chip, a google-search should help you (edit: maybe this one, ported from Adafruit?!: GitHub - hybotics/micropython-ht16k33: Micropython driver for the HT16K33, a LED matrix, 7-Segment Numeric, and 14-Segment Alphanumeric display driver IC)

There is a third option I never tried: Adafruit has a small compatibility layer that translates the CircuitPython API to Micropython called Blinka (there is a learning-guide for that). But I am not sure if you can freely mix the APIs, so if parts of your code is Micropython (e.g. the plasma-driver stuff), than this might not work.

Hi bablokb, I followed your advice and downloaded the file and both of the test files to set and retrieve the date and tried running both from within Thonny. In both cases I got the same error message,

Traceback (most recent call last):
File “”, line 17, in
File “”, line 48, in init
OSError: [Errno 5] EIO

I am afraid that’s where I came to a stop! Any further thoughts ?

I think I am OK with the 4 digit displays as I have these working from my existing micropython programme so I know I can talk to them.

Judging from the title of the repository, the PCF implementation is for the ESP8266. You might have to dig into the code and port/fix that part. Not every program author thinks about portability. The traceback actually gives you the place where the problem is located.

Thank you for your efforts, bablokb, but one of the most important lessons I learned when an RF development engineer for Marconi was to know when to stop and give up trying to “Chart the Universe”, I think I have reached that point now so my next approach is to look for an alternative RTC for which the necessary libraries exist and are proven in micropython. Micropython forums here I come !! (PS I looked at the file I downloaded from the GitHub site you mentioned and frankly I am lost ). Thanks again for you efforts to date.

I think you are giving up to fast. You probably only pass the wrong i2c object to the constructor. Have a look at examples/ The code is explicitly for the pico (you might have to adapt the i2c-object to the plasma-pins for sda/scl).

Hi bablokb, I think I have stumbled on at least one of my problems. I think you are assuming that I know something about Object Oriented Programming and understand terms like Classes, Methods, Objects and Constructor but I am afraid I don’t so I have just got the Python book out and am having a read. Like McArthur, I shall return when I am better equipped !!!

Fine! You can also share your code and maybe someone here spots the problem. Experience tells that programmers tend to miss even simple mistakes in their own programs. At least this is what happens to me regularly.