I’ve gathered together the pieces to build the ring clock from Pi magazine #165 (pg20), which uses a Waveshare DS3231 RTC module plus a neopixel ring.
However I already have a simple little clock running using a PicoScroll pack, and I was wondering if there’s any way that the RTC module can be used with that? If I try using the original Pimoroni uf2 (MicroPython v1.15) that was set up, it mostly gives an EIO error (i2c.scan() shows 108).
If I try with the current MicroPython uf2 (v1.27) then I still get the error, but also the clock script fails as it looks like everything was rewritten between the two versions (the script uses scroll.ini(), which fails in 1.27).
As a seconary question, are the commands available from the picoscroll library listed anywhere, or is it just what’s available in the example files linked from the shop page?
The 17x7 matrix driver uses I2C address: 0x74. What i2c scan code are you using, and what pins is it set up to scan?
This should work?
import machine
sda=machine.Pin(4) # Explorer 20 Breakout 4
scl=machine.Pin(5) # Explorer 21 Breakout 5
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
print('Scan i2c bus...')
devices = i2c.scan()
if len(devices) == 0:
print("No i2c device !")
else:
print('i2c devices found:',len(devices))
for device in devices:
print("Decimal address: ",device," | Hex address: ",hex(device))
This may help, commands wise.
Last first - thanks for the link. That’s what I was looking for to get the commands.
For the scan, I was just typing the i2c.scan() command into the shell area in Thonny.
Running your code (with the v1.15 Pimoroni firmware) gives:
Scan i2c bus...
i2c devices found: 1
Decimal address: 116 | Hex address: 0x74
which would align with what you say about expectations.
But if I try to run the Waveshare script, it generally gives me an EIO error as mentioned before.
So I think with this firmware perhaps I can see/drive the pack but not the RTC, and with the Waveshare firmware the other way around?
One big issue is that the Wave Share RTC used GP20 for SDA and GP21 for SCL. It’s using different pins for I2C. That’s why your scan only ever see’s the one device. I neglected to click the link you posted or I would have noticed this earlier.
I don’t know of any easy way around that, as both are packs. If it was a RTC like this.
RV3028 Real-Time Clock (RTC) Breakout
You could just wire it up to whatever pins are needed to make everything work.
This should find the waveshare RTC.
import machine
sda=machine.Pin(20) # Explorer 20 Breakout 4
scl=machine.Pin(21) # Explorer 21 Breakout 5
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
print('Scan i2c bus...')
devices = i2c.scan()
if len(devices) == 0:
print("No i2c device !")
else:
print('i2c devices found:',len(devices))
for device in devices:
print("Decimal address: ",device," | Hex address: ",hex(device))
Yes, using the other pins detects the RTC:
Scan i2c bus...
i2c devices found: 1
Decimal address: 104 | Hex address: 0x68
As a basic question, if nothing else is using those four pins, would it work to just connect them in pairs (sda to sda and scl to scl, so pins 4 to 20 and 5 to 21)? I have no real knowledge of how I2C works, but would such a connection allow one script to detect both packs?
Otherwise I think I’ll look to return the RTC pack, as it’s otherwise not compatible with the scroll pack which is what I wanted it for.
Yes, you could jumper 20 to 4 and 21 to 5, and then use 4 and 5 as you i2c pins.
Will put this one on hold I think for now, as the ring clock works well and PiHut have accepted a return/refund request for the spare RTC pack.
If I get bored with it, then I might come back to this with a cross-wiring as discussed, but a job maybe for the future.
Thanks for the help and support as usual @alphanumeric . Learned something about I2C anyway with all this.