Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Badger2040w RTC example #4

Open
North101 opened this issue Mar 10, 2023 · 6 comments
Open

Badger2040w RTC example #4

North101 opened this issue Mar 10, 2023 · 6 comments
Milestone

Comments

@North101
Copy link

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

@Gadgetoid
Copy link
Member

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
Copy link
Member

Okay, some basic RTC functions and docs added here - #2

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

@bjohas
Copy link

bjohas commented Mar 25, 2023

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
Copy link

bjohas commented Mar 26, 2023

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.

1 similar comment
@bjohas
Copy link

bjohas commented Mar 26, 2023

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
Copy link

bjohas commented Apr 1, 2023

pimoroni/pimoroni-pico#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants