Badger 2040 + RV3028 RTC newbie problems

Hi, I’m very much a newbie to Python and while I have some Arduino experience, I’ve ran into enough stumbling blocks that suggest I’ve fundamentally misunderstood something. I’m trying to use an RV3028 RTC board with a Badger 2040 running Micropython v1.19.6, the RTC is connected through the QW/ST connector, and I’ve been using Thonny to run some sketches on the Badger without issue. I’ve installed the rv3028 library v0.0.5 in Thonny, along with smbus2 v0.4.2 and i2cdevice v0.0.7 (all through the PyPI package manager).

My first problem is running the example ‘set-time.py’ sketch, as the compiler reports ImportError: no module named ‘datetime’. It seems to be a requirement of the rv3028 library that’s not included? I wasn’t able to find a “datetime” module in PyPI that actually installed, as the only one (DateTime) says it’s not a Micropython package. I see a number of other examples import a module called rv3028_rtc but that doesn’t appear in PyPI or the Pimoroni Github.

  • The RV3028 is supposed to be compatible, so when the example sketch fails, what have I missed?

My next question is in the interfacing to the Badger itself. I know that to use the RV3028 with the Badger (and indeed to actually set the time in the first place) I’ve connected the RV3028 to the Badger using the QW/ST connector on the back, and I’ll import the rv2038 module in the sketch running in the Badger.

Thanks in advance. I’m sure I must be missing some obvious things because I see so many people making such awesome things and can’t believe they’re all falling at the first hurdle like me.

If you’re running pimoroni-pico micropython the RV3028 drivers should be included, you shouldn’t need to install anything else.

Badger’s I2C pins are the Pico defaults - GP4 (SDA) and GP5 (SCL) so the set-time.py example should work as is - just double checking this is the code you’re running?

1 Like

Thank you so much! I knew it would be something simple that I’d missed. I was looking at the examples here - rv3028-python/set-time.py at master · pimoroni/rv3028-python · GitHub - which definitely don’t just work with the Badger.
The examples you linked to are much more like what I was expecting with pin definitions etc. I have now been able to initialise my RV3028!

1 Like

Yeah, for Micro Python, these are the examples to use.
pimoroni-pico/micropython/examples at main · pimoroni/pimoroni-pico (github.com)