-
• #2
Hi Tobias,
Well, one very simple method is to detect when the battery voltage goes below ~3v. Basically as the battery voltage lowers, the voltage regulator stops being able to supply 3.3v to the STM32 chip in Espruino - and you can detect that.
You can use E.getAnalogVRef() to see what voltage Espruino thinks it is at, so for instance you could do:
setInterval(function() { if (E.getAnalogVRef()<3.0) doSomething(); }, 60000); // every 60 sec
To go to sleep, you'll want to have called
setDeepSleep(true)
- but then you should probably do that anyway if running off a battery as it'll decrease power draw massively. Then, it's just a matter of making sure you don't have any calls tosetInterval
orsetTimeout
that might wake Espruino up.
Hello everyone,
do you know an easy and elegant way to monitor the battery charge (remaining voltage) of the power source of the Espruino and react when the battery is low and put the Espruino into sleep mode?
Best,
Tobias