Yes, that's a good idea. For maximum power saving, actually turn the pin into an input with digitalRead(powerPin) to turn it off (then you're not using power pulling it down to 0).
However I'd look at the datasheet for the device to make sure. Some of them can be put into low power modes using software, so you could save a bit of wiring :)
Just so you know - setDeepSleep actually only sets a flag that says "go to deep sleep when possible". You don't actually need setDeepSleep(0); and setDeepSleep(1); - you just need to call setDeepSleep(1); once, at some point in your code :)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Yes, that's a good idea. For maximum power saving, actually turn the pin into an input with
digitalRead(powerPin)
to turn it off (then you're not using power pulling it down to 0).However I'd look at the datasheet for the device to make sure. Some of them can be put into low power modes using software, so you could save a bit of wiring :)
Just so you know -
setDeepSleep
actually only sets a flag that says "go to deep sleep when possible". You don't actually needsetDeepSleep(0);
andsetDeepSleep(1);
- you just need to callsetDeepSleep(1);
once, at some point in your code :)