Goal
I’m trying to build a really simple battery powered photoframe with the fantastic Inky Frame 7.3. I use a SD card to store the pictures and I want to update the picture one time per day (every 24 hours).
My code seems to work correctly when it’s connected over USB
Apparently, the sleep_for function does not work if I want an update every 24 hours
I don’t really understand how to use the RTC chip and how to activate the deep sleep. I’ve seen some examples from inky_frame_news.py and from the popular slideshow.py but it’s not really clear for me.
Can you help me better understand how to use RTC and deep sleep?
Also, how can I wake up the Frame only every 24 hours?
It might be a bit confusing at first (due to the misnaming of the method), but technically the pico does not use deep-sleep, but powers down. A button-press or an interrupt from the rtc enables power again, and the pico boots and your program runs again from the beginning.
When on USB, the pico is not powered down but running idle and your while-loop is running. Otherwise the while-loop is only executed once.
When on battery, I suppose you have tried to wake up the inkyframe once using a button (necessary) and then waited for the next startup?
It seems to work like expected, however I would like to use a value > 255 (here it’s 255min). The RTC seems like it’s limited to 255 because it’s 8 bit? 🤔
Do you know how to use the RTC with a much bigger value like 24 hours or many days?
The rtc supports countdown-timer(s) and alarms. The former is based on a 8-bit register, the latter not.
The timer counts down the value supplied in tick-intervals, the longest tick-interval is 1/60 Hz, i.e. one tick per minute. So for timers, 255 minutes is the absolute limit.
In contrast to timers, which fires when the countdown reaches zero, the alarm fires when certain conditions are met. E.g. you could configure an alarm to fire every time the minute is 5 (i.e. once per hour at xx:05). Or when the minute is 15 and the hour is 12 (i.e. once a day at 12:15). Or when the day is 1 and the hour is 8 and the minute is 0 (i.e. on every first of a month at 08:00).
The function for this is rtc.set_alarm(). A few things to watch out for:
take care that the rtc-clock is set to the correct value. You must update the rtc-clock from a reliable source, e.g. a time-server. If you just want to wake up once a day and don’t care about the exact time, this is not strictly necessary.
don’t confuse the external pcf85063a-rtc of the InkyFrame with the builtin internal rtc of the Raspberry Pi Pico. Ideally, you would update the internal rtc of the pico at every start from the external rtc. The latter will be powered even if the pico is shut down and therefore won’t loose it’s value
make sure that you clear any alarm at boot. This is usually the first thing what I do in my program. This also prevents some nasty problems when you use a button once in a while to start the pico