I’ve got my Badger 2040 W and it works great - but I cannot activate or even find the promised deep sleep functionality, i.e., sleep_for and other functions. Could somebody show me some working code or tell me when this functionality - which was why I bought the badger - will be implemented.
Are you using the new Badger-dedicated release, from GitHub - pimoroni/badger2040: Examples and firmware for Badger 2040 and Badger 2040 W?
That should include
sleep_for() and friends (documented in badger2040/reference.md at main · pimoroni/badger2040 · GitHub)
I had problems figuring out which version my new Badger W had, but I saw the code and thought it looked experimental - with the weird limitation that the sleep may not last a whole minute but only 15 at least seconds.
I was also hoping the parameter specified seconds instead of minutes?
After experimenting with it I am also pusled that for instance the LED light does not turn off. I thought that was the whole point? What is the difference between sleep_for and sleep?
sleep_for() powers the Pico(w) down, although for reasons I don’t fully comprehend the alarm is only set on the minute.
sleep() idles your program but doesn’t power off the Pico(w)
As for why
sleep_for() works in minutes rather than seconds… I imagine the thinking is that there’s not much benefit in powering off for 5 seconds (presumably powering up comes at a cost and you’re better off just plain
sleep()ing for short periods).
I can’t comment on the experimental nature of any actual code; to be fair the whole RP2040 ecosystem is a bit of a writhing mess :-)
Actually, working with the system, the one minute sleep period actually seems to work for me, but yeah you may be right that the
sleep_for() may actually use so much power(?) that it is not worth using it instead of
sleep() - but my original plan was 30-40 seconds sleeping - but as I said 60 is actually ok.
My original plan was to make
switzer_lib.py. A small library which could
switz (using sleep ;-) ) between the programs, making Badger 2040 W a more lively badge which would attrack attention. Unfortunately it chrashes after cykling through 4-10 programs (
qrgen.py, …) over and over again - even though I cleared memory using
What I have done instead is appending all the code into one file and that actually seems to work - except - when I attached the batcher to a battery my program restarted instead of continuing where it left off when going to sleep - but that was easy to fix - so now that works - and the LED goes off as I expected.
Now I am ready to go on searching for a job…