The energy cost of powering down vs deep sleep - Page 1
Forum section: electronics / beginners

author: Peabody
author_rank: Super Contributor
timestamp: September 27, 2019, 09:32:56 pm
content: I'm working on a mailbox notifier using a Wemos (Lolin) D1 Mini powered by an 18650. I have a two-transistor circuit that completely shuts down the battery supply to the circuit when the mailbox door is closed. I figured - no matter how little current is used in sleeping, I could prevent that by shutting down the power altogether.But then I saw a video by Andreas Spiess that basically concluded you should add a 1000µF aluminum electrolytic capacitor to Vcc to provide power for the current spikes that happen during wireless traffic. That's fine, but it occurs to me that when I power down, whatever charge is stored in that capacitor is going to be lost - wasted - as it dissipates. So if that capacitor is really needed, then I need to consider the power lost when I shut down versus the power that would be required to just put the Mini into deep sleep with the power still on.I will be able to measure the sleep current, and it's my understanding that Minis don't sleep very soundly, so I'm looking at something like tens of microamps. But I don't know how to calculate how many microamp seconds are in that capacitor.There will be two power-up cycles per day - once when the carrier puts the mail in the box, and once when the box is emptied - I don't know, but I would guess maybe 5 seconds each time to make the WiFi connection and send the notice. The other 23 hours, 59 minutes and 50 seconds of the day would be spent either powered down or sleeping. If the sleep current is, say, 20µA, then thats 86,390 seconds per day at 20µA, or 1,727,800 microamp-seconds, which if my math is right is 0.48mAh drawn from the battery per day while sleeping.What about the capacitor loss if I power down? And by the way, I think the calculation needs to be based on charging to 4.2V because of the heat dissipated by the regulator while charging the capacitor to 3.3V. The loss on discharge is really the energy it took to charge it, which would include that heat.So hopefully there's a math major out there who can tell me the equivalent mAh's wasted by discharging the 1000µF capacitor twice a day.

author: mariush
author_rank: Super Contributor
timestamp: September 27, 2019, 09:53:56 pm
content: I don't think the capacitor is needed... an 18650 can give the current needed by the wireless.Considering the application, you should consider having some solar cell on the side on the mailbox ... and slowly charge the Li battery ... use a 5v ldo to regulate the solar cell voltage and feed that into some cheap charger IC like MCP73831 (~0.5$) that you can set to charge the battery.

author: Peabody
author_rank: Super Contributor
timestamp: September 28, 2019, 05:07:21 am
content: The 18650 might provide enough current for the spikes, but it appears the regulator will not. As shown in the Spiess video, the regulator just can't respond quickly enough to prevent a significant voltage drop.Anyway, I'd still like to know how to calculate the mAh needed to charge a capacitor.

author: ledtester
author_rank: Super Contributor
timestamp: September 28, 2019, 05:29:11 am
content: Q = C*V, so for C = 1000 uF and V = 3.3V, Q = 3.3 milli-couloub = 3.3 milliamp*sec = 3.3/3600 milliamp hours =~ 1/1000 milliamp hours.

author: james_s
author_rank: Super Contributor
timestamp: September 28, 2019, 06:22:19 am
content: It shouldn't really matter, something like a Moteino can run for multiple years from a pair of AAs if you're careful with the code. Modern microcontrollers consume microamps in sleep mode.

author: magic
author_rank: Super Contributor
timestamp: September 28, 2019, 06:36:02 am
content: Quote from: Peabody on September 27, 2019, 09:32:56 pmCharge doesn't magically dissipate from capacitors. If you disconnect power supply and the capacitor discharges, that's because of current drawn from it by your circuitry and by the cap's internal leakage. If the battery remains connected, the same currents still exist and drain power directly from the battery.It probably makes no difference, until you power off for long enough that the capacitor is discharged to zero. Then leakage stops and you start to save energy until the device is powered on again.Also, IIRC, leakage of electrolytic capacitors can be on the order of a microamp. If you want to squeeze out the last remaining X% of battery life, see if capacitance could be reduced down to MLCC territory and still work. I believe ceramic caps have much lower leakage.

author: Peabody
author_rank: Super Contributor
timestamp: September 28, 2019, 02:24:40 pm
content: Quote from: ledtester on September 28, 2019, 05:29:11 amThanks very much. I didn't want to use the power shut-off option if it actually used more battery juice recharging the capacitor than just letting it sleep with the power on. But I think your answer makes it clear. If I recharge the capacitor twice a day, and the power is off long enough for it to fully discharge, then that would be on the order of 0.002mAh per day to recharge it. But if my earlier calculation of sleep current is correct, letting it sleep at 20µA would use 0.48mAh per day, or 240 times as much battery drain. Now it may be that neither one is a significant load, but at least I know I'm not making it worse by shutting off the power. Even if the sleep current is only 1µA, power shutoff still looks good.

author: Peabody
author_rank: Super Contributor
timestamp: September 28, 2019, 02:30:36 pm
content: Quote from: james_s on September 28, 2019, 06:22:19 amI don't know anything about Moteinos. Are they anything like the ESP8266?

author: Peabody
author_rank: Super Contributor
timestamp: September 28, 2019, 02:41:14 pm
content: Quote from: magic on September 28, 2019, 06:36:02 amYes, I'm assuming an electrolytic will fully discharge in the minimum 6-8 hours that the power would be off. If nothing else, I believe there is a resistor divider in the regulator that would eventually discharge it. But if it doesn't fully discharge, that just makes the power-off option even better.If Spiess is right about needing 1000µF, I don't know what choices I would have. At this point I don't know for sure if the cap is needed at all, but his video strongly suggests that it is, and that 330µF isn't enough. He doesn't test 470 or 680.

author: james_s
author_rank: Super Contributor
timestamp: September 28, 2019, 03:52:20 pm
content: Quote from: Peabody on September 28, 2019, 02:30:36 pmThey're just an arduino with an onboard RF module and a really low quiescent voltage regulator.

author: ledtester
author_rank: Super Contributor
timestamp: September 29, 2019, 03:01:49 am
content: Quote from: Peabody on September 28, 2019, 02:24:40 pmTo properly compare the two you should take into account the amount of energy required to get your software up and running from power on -- i.e. initialize its state. This is work that won't have to be done if you just wake the microcontroller from deep sleep.

author: james_s
author_rank: Super Contributor
timestamp: September 29, 2019, 03:30:45 am
content: Just to put things in perspective, a 1uA draw would take 200,000 hours (~22 years) to drain a tiny little 200mAh CR2032 coin cell. Just about any battery you would conceivably use will die from self discharge or leakage before a 1uA draw would become noticeable.

author: Peabody
author_rank: Super Contributor
timestamp: September 29, 2019, 02:26:02 pm
content: Quote from: ledtester on September 29, 2019, 03:01:49 amAs I said, I'm new to ESP8266, but my understanding is that waking one up requires a reset. There is no pin change wakeup from deep sleep. It that's the case, then the same initialization would be required either way.

author: Peabody
author_rank: Super Contributor
timestamp: September 29, 2019, 02:50:35 pm
content: Quote from: james_s on September 29, 2019, 03:30:45 amYes, I just wanted to be sure that powering down wasn't somehow worse than that.But I do need to look at the deep sleep option and see how the mailbox door reed switch could reset the 8266. I'm thinking maybe an inline capacitor like DTR has on AVRs.

author: james_s
author_rank: Super Contributor
timestamp: September 29, 2019, 03:37:16 pm
content: The proper way to do this is have a timer interrupt that wakes up the mcu periodically and polls the pin, or use a hardware interrupt pin.

author: Peabody
author_rank: Super Contributor
timestamp: September 29, 2019, 04:24:58 pm
content: A timer interrupt would not be appropriate. An efficient mail carrier might have the mailbox door open for 2-3 seconds once a day, so the timer setting would either waste a lot of effort checking the door sensor every second, or check less frequently at the risk of missing the event entirely.So I think there would have to be a reset that occurs when the door is opened. I just haven't looked into how to do that yet.

author: james_s
author_rank: Super Contributor
timestamp: September 29, 2019, 05:07:56 pm
content: Don't be so sure. It's common to have a timer interrupt wake up a CPU anywhere from 10-100 times a second, run a handful of instructions that takes a tiny amount of time with the CPU running at several MHz and then go back to sleep. What matters is duty cycle, even waking up 100 times a second and polling a pin it could still be sleeping 99.99% of the time.It's been a while since I've messed with the code but my Moteino based mailbox notifier polls at I think 10Hz and it has been running for months now on a pair of AA cells that are still over 3V.