Hacker News new | ask | show | jobs
by anigbrowl 1250 days ago
I got into ESP32 hacking a few months back, and I'm glad I happened to start with a battery-powered device (an M5stack StickC) because it imposed this awareness very early - the device has an internal battery, but it's only good for about half an hour running flat out. So after building a little wifi detector the first patch was adding a battery meter and an auto-dimmer to save a few mAh. Now every project starts out with some ideas about what I'd like the device to do, followed by questions about how much temporal resolution I really need, when and how to dump or store data etc. as well as the more obvious constraints of tiny memory and storage capacity.

It's...kinda fun? Perhaps more so as I only have to please myself rather than an employer or client. You can just query the ESP32 about battery voltage/current/charge state/temperature which of course makes things very easy. On the assumption that specifications and quality vary a lot and that voltage doesn't fall off in a convenient linear fashion, I've just been experimenting with it like any other environmental variable to decide between performance, economy, or panic modes.

1 comments

The key to low power is to put the micro in a sleep state as much as possible. You have to rethink running things in a loop and make it interrupt / event driven.

Set it up to wake from sleep on some interrupt, do your processing, then go back to sleep. You can setup a timer interrupt to wake periodically to do processing as well.

My experience programming for the Watchy (epaper watch on esp32) exactly. Basically the only way of programming it is being woken up every minute by the RTC, running as little as possible, setting up the next interrupt by the RTC and going back to sleep.

I got mine to last about a week on the stock battery, i know of people who have done better but being a minute-resolution clock helps a lot.

Excellent advice! I'll try that out and see how long I keep it running between charges.