badger2040 icon indicating copy to clipboard operation
badger2040 copied to clipboard

Badger2040w RTC example

Open North101 opened this issue 2 years ago • 6 comments

Might be useful to the document the badger2040w RTC and link to the example https://github.com/pimoroni/pimoroni-pico/blob/main/micropython/examples/pcf85063a/pico_rtc.py

Would it be worth having the micropython machine.RTC call the pcf85063a functions? https://docs.micropython.org/en/latest/library/machine.RTC.html

North101 avatar Mar 10 '23 02:03 North101

I think it’s possible but quite tricky to redirect machine.RTC, since we’d have to patch the relevant files in the port (MicroPython source) itself. I found the dual RTC stuff a bit weird on Inky Frame so maybe it’s worth looking into how tricky.

I should be able to port the stuff I’ve recently written for Inky Frame to Badger. That should cover off most basic RTC use cases, since it gives you a function to wake up after a number of minutes.

Gadgetoid avatar Mar 10 '23 10:03 Gadgetoid

Okay, some basic RTC functions and docs added here - https://github.com/pimoroni/badger2040/pull/2

If you get the build from GitHub Actions you should be able to give these a try.

Gadgetoid avatar Mar 10 '23 14:03 Gadgetoid

Hi @North101 and @Gadgetoid ,

How would this example https://github.com/pimoroni/pimoroni-pico/blob/main/micropython/examples/pcf85063a/pico_rtc.py work with halting the Badger 2040 W?

I'd like to take a temperature reading every 5 minutes, and shut the Pico off for those periods.

As an alternative, I've tried machine.deepsleep(), but the rtc seems to get reset (on battery power). Is that expected?

bjohas avatar Mar 25 '23 18:03 bjohas

In fact,

display = badger2040.Badger2040()
display.halt()

also forgets the rtc setting. If I start the clock.py application, close it, and restart, it looks for the time again.

bjohas avatar Mar 26 '23 10:03 bjohas

In fact,

display = badger2040.Badger2040()
display.halt()

also forgets the rtc setting. If I start the clock.py application, close it, and restart, it looks for the time again.

bjohas avatar Mar 26 '23 10:03 bjohas

https://github.com/pimoroni/pimoroni-pico/issues/449

The catch is that Badger 2040 doesn't rely on the not-great sleep states of the Pico, but rather cuts the power entirely. Connected battery or not, it'll lose the time since it's truly off. The buttons actually trigger the power being turned back on, in addition to being readable by the RP2040. Rather ingenious save this one unfortunate side-effect.

This explains the behaviour.

bjohas avatar Apr 01 '23 20:04 bjohas

Closed as resolved.

thirdr avatar Jan 08 '25 14:01 thirdr