One more small success.
I found this code to scan the I2C bus for devices.
However you need to know what GPIO pins the device uses.
The Core Electronics page says to use Pin 9 and 10 GPIO 6 SDA and GPIO 7 SCL where the Wave Share Wiki says to use SDA 20 and SCL 21
Turns out Waveshare is correct.
This bus scan code correctly finds the device. Link Here
Hi Aaron,
That message is a long way down the thread. I wasn’t really expecting you guys to spot it. Well done. As it turned out I was using the settings (mostly) from Waveshare. But they have way too much fluff on their page.
Here is my work in progress in case someone else wants to take up where I left off. The routines to set the pico from the DS3231 and to set the DS3231 from the pico are working fine, just include the code and if the pico time is correct set the DS3231 time once. From then on each time the pico starts up set the time from the DS3231.
Have a look at the examples in the “main” section at the bottom. I added a routine to list all the device settings to the screen in binary but didn’t get very far figuring out if something was obviously wrong that was stopping the alarm from waking up the pico. ds3231.zip (3.1 KB)
Nice work on the library, David! Finding those correct I2C pins for the Waveshare module is half the battle - I’ve spent way too long in the past staring at a blank terminal only to realize I had SDA and SCL swapped in my head.
On the alarm triggering: if you’re still having trouble with the Pico not catching the interrupt, definitely check if the ‘Alarm Flag’ (A1F) is being cleared in your IRQ handler. If it stays high, the DS3231 won’t pull the INT pin high again for the next cycle. One thing I’ve been doing to double-check my math for the alarm intervals (especially when testing daily offsets) is using https://onlinealarm.co/. It’s a simple web tool, but it’s super handy for verifying exactly how many minutes/hours until a specific ‘test’ time while you’re still debugging the Python logic.
Keep us posted on how the low-power sleep mode goes - that’s the real ‘holy grail’ for these Pico projects!
Hi Britany,
Well that was a while back. I sent the project to the friend of mine who asked “Could you make something that does this?”
I left him the task of putting it in a little project box and testing it. As far as I know he never touched it.
A little disappointing but I had fun making it so probably no updates on that one.
I’m still having fun with Pico’s I figured out how to build Fuzix (unix) for it. The most common question people seems to ask is “But what do you do with it now?” Fuzix is a text based unix like system built to run on tiny hardware (pico being one) so once it starts up it just goes.
#
Then waits for you do something.
I got a few games to run which was interesting. I’m from 1990’s computer land so I decided to build a text based multi user business program to run on it just like the good old days. I should be able to get 3 users going at once on text based terminals. I even found a serial terminal I can run from another pico direct to a VGA screen and USB keyboard.
For the application I decided on a Mechanic Booking System which is just the kind of project I used to get at Tech College but the same principle and code structure could be used for anything.
My C programming is a little bit (a lot) rusty so I have Chat GPT helping me. It’s like having a loose cannon mentor that gets things right about 80% of the time. But I’m having fun and it forces me to learn. I might post a project here or just start a thread so people who like that stuff can find it.
David
I really think it is important to “know” what pins you are using for what and how to set those in your projects. Waveshare saying its pins 20/21 may be correct/default, but considering you can map the I2C to different pins, and there are many good reasons to do so, then knowing what Pins you are using (you connected the wires is a start) is important, as you then can tell the code.
Also most micro controllers can have more then 1 I2C bus, each will have their own pins.
When Im working on a project, I normally assign things the MUST be on a fix pin first, then I review what pins a left and will assign them to best meet the connections/track routing.
e.g.
what would you do if you needed the use SPI0 and I2C1. only one can be on the default pins.