by watermelon59 · 3y ago · 0 comments
This has been my experience so far trying to build my own devices at home. They all assume I’ll connect things to a USB port or have a power adapter. Material on how to deal with battery voltage dropping over time, determining battery level, etc. is really scattered. Makes me wish I was an EE major instead of CS.
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.
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.
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.
That said, we're still in that early-ish phase. Four-ish years from now, there's probably going to be a post where I start off with something like
"Ahh the Nordic NRF52832. Of all the chips to show up on HN today. This chip I know not half as much as I'd like to and half as much I wish I didn't have to..."
It's sort of a vicious cycle.