Making The Arduino Sleep The Long Sleep

Earlier this week, I showed you [Naim Busek’s] kickstarter for his turn signal helmet. In that article I explained that, while the helmet is a neat idea, I was really interested in what [Naim] had told me about his power consumption.  To put it the shortest way, he has made his arduino sleep so efficiently, it can be waiting for input longer than the battery’s optimum shelf life.

After that article, [Naim] wrote in to give me the details on what he did to achieve such an efficient system. You can read his entire explanation, un altered here.

Have been searching off and on for a particular app note that I wanted to share with you but could not for the life of me find it. Seeing your post I bit the bullet and spent the last few hours searching and finally located it. The document is Designing With Logic from Texas Instruments. The interesting part is Figure 5 (will explain why a little later).

A dive into the low power operation of Arduino hardware

Started with the basics. Made sure all LED driver pins were in the off state by default. The removed the load resistors for all of the feedback LEDS I could not switch off like the one connected to VCC that wastes power any time the battery is connected. As an implementation note, I actually turned SMT resistor sideways and left them connected by one pad. Makes it easy to reinstall it if I want them later.

I had planned to not use the onboard voltage regulator from the beginning because the quiessent current it use is huge 100+ uA. The shield I designed and built used a lower current (50mA vs. 250mA) regulator since I was planning to use it only for the control electronics and sensors. The high current LEDs would run directly off of the higher voltage without any regulation. Since the micro and sensors draw 12-15mA max when fully on 50mA was way more than enough.

The expected current draw for my system was:

  • Voltage regulator: ~5-6uA
  • ATMega328p: ~1uA
  • CMA3000 (@10Hz w/ wakeup): ~10uA

Total: ~16uA

Note: The testing below was done on both an Arduino Pro Mini and an Arduino Fio with similar results. The bike helmet prototype was built on top of an Arduino Fio.

To get the device into low power I started with the Arduino example sleep sketch and went through the guidelines from the datasheet to try and figure out why it was drawing so much power. The Arduino was using ~420uA when the chip is while the data sheet claims

Knowing that I went ahead and bypassed disconnected the supply from Arduino battery input, connected it to the input of my ultra low quiescent voltage regulator and connected the output of that directly to the Arduino VCC. Current system draw went UP to ~155uA. WTF???

Next thing I looked for was pullups on the digital lines for I2C and/or SPI. Not just pins configured as outputs and driven the wrong way but also looking at what weak pullups were intentionally (or accidentally) enabled. I have seen this catch out a number of Arduino developers. If the output value of a pin is configured high, when it is switched to being an input it does not just switch to being a high impedance input. If the digital output register is set a weak pullup (for the AVR Rpu = 20-50kOhms) is enabled on that pin. If a peripheral then decides to make that signal on that input low, the system suddenly sees an increase of VCC/Rpu of current that would not be there if the pullup were not enabled. Whenever I see a system that is some weird multiple of VCC/Rpu off of where it’s sleep current is supposed to be I will look for an input pullup that should not be enabled. In this case with a 3.3V rail a pullup would cause 60-150uA draw. Reviewed all of my code, probed the pins and did not find anything configured wrong. Happy that I didn’t screw anything up but unhappy that i Still have 140uA (of 150uA) disappearing into the ether and sucking my battery dry.

Then I started looking for some of the more obscure types of failures that could be causing this. One of those things that I discovered (then had a crash course on how to fix) is something call “back-powering of digital output pins” or sometimes “pin powering” or “port powering” of a device. Now back to Designing With Logic. Looking at Figure 5, if a chip that has digital I/O is powered down (VCC disconnected) then voltage is applied externally to that I/O that voltage can cause D1 on the input or D3 on the output to reverse bias, allow current to flow and feed the internal VCC of the chip with that voltage (minus a diode drop). Then really weird things can start happening. Most current digital chips can easily run at 1.8V (0.9V for some of the newer ones) so if a an external pin is driven at 3.3V and enough current can sneak through the diode, the part will happily keep running on the 2.7-3.0V it gets internally. Found this out the hard way with a peripheral that would never shut down and reset. Was right on the edge and drew too much current to startup by back powering but once running would happily keep running by back powering. Gave it 3.3V and it turned on took it away and it just kept on running. Was super confusing, since could turn it on but not off???

While the output of the regulator is not a digital I/O pin I got to thinking that something might still be going on with the output circuitry. So I cut the output trace from the regulator on the Fio (I just removed the regulator completely from the Pro Mini) and the current draw dropped to 34uA. This gave me a more than 10x decrease in sleep current for a 10x battery life increase. Running off of 1900mAHr AA batteries it should sleep, still doing 10Hz sampling to detect motion, for 6-7 years. With the 9V batteries in my prototype at 590mAHr it is just shy of two years.

At this point I moved forward with the kickstarter comfortable that I could hit the lifetime targets I had set. The current was still about double my back of the envelope calculations but was not going to be a showstopper. It was still weighing on me that there was something in the system that I did not know exactly how and why it was happening. Just yesterday when I was thinking about this again, I found the spark fun tutorial Adventures in Low Power Land. While I had independently done the same initial steps while going through this process I did not get to the point of looking at the brown out detection (BOD) and changing the fuses. Given that the BOD consumes 15-20uA I am now very happy with my 34uA sleep meaning that with BOD disabled I should be at 14-19uA. :) For 1900mAHr battery that gives a 10-12 year sleep time. That is well beyond the 5-7 year shelf life of a normal alkaline battery. Any time I am exceeding the storage the storage life and approaching the self depletion time of the battery I am very happy. :)

23 thoughts on “Making The Arduino Sleep The Long Sleep

      1. A low frequency RTC would be 32.768kHz. In answer to the original question, external crystals are expensive. RTC crystals with 20 or 50ppm even more so. In some cases the SMT ones can cost as much (or more) than the low end microcontrollers which is why you will commonly see an SMT main crystal and the RTC in a metal can. Another option is to use something like the Very Low Frequency internal oscillator in the MSP430. It gives a 12-16kHz and is unusable for accurate timing but can be used for slow/low power computation.

  1. Would it not be easier/cheaper to design a circuit with an astable multivibrator circuit and a couple of tilt switches? It would probably last longer too, or am I missing something?

    1. It uses a DSP to filter the inputs so that the helmet signals only when you tilt your head to the side for 0.5s but not when you are turning your head to look around. The tilt switches work in theory but in practice they are more finicky to work with.

  2. A while ago I built some simple temperatur sensors based on an Attiny 45 they send out their temperature readings per radio ever 3 minutes.

    A rough guestimation put them at an average 2.2µA power draw. I will see if I can to a write up on the code and schematics.

  3. I have always wanted to make a time capsule like device, that could be buried for 15 years. and after 15 years sent a radio signal.

    and that there is also has a lock, so power optimization is great and with this i could almost do it, except for the fact that a 15 year power supply is almost impossible. (as far as i know)

    1. Well according to:

      The best batteries currently have a self-discharge rate of ~3% per year. If you use a low power µC to count the 15 years, with maybe 2 µA you will need 18 mAh per year. For 15 years you will need 270 mAh. The battery will have discharged by another 45 % due to self discharge.
      So an alkaline battery with 600 mAh would be enough to wake up after 15 years.

      The big question is how much power you would need to send out the radio signal. This would be at least in the order of 20 – 200 mA and to have any chance of getting found you would need to send the signal for at least a few days.
      Lets say you need 24 Ah for the radio transmission. That would mean you need at least an 48 Ah battery to power the capsule.

      Your in luck:

      But you will have to check if the self-discharge rate for these is still 3% per year.

    2. Stick a plug on it, and in 15 years time dig it up and supply 5v thru a wire. Boring, I know, but reliable. If you want a connector that’ll still be here in 15 years, I suggest the humble DC barrel plug. As a second choice, 3.5mm audio connectors are gonna be here for as long as there’s separate stereo headphones. Finally, for an almost-eternal connector, the PP3 battery connector. Use one of those on your capsule, and there’ll always be something to plug it into in the future.

      Boring, but reliable. And judging by the rate data and signalling formats have evolved, and continue to evolve evolving, the power connector’ll be the only bit in 15 years that anyone’ll be able to make any sense of.

      1. Especially since you can easily have a realtime clock keep time for multiple years.

        The purpose of this real time clock could be extremely simple. All it does is ensure that any voltage placed though the ‘open me’ terminal, will not open the unlock solonoid(or explosive latch) before the date. (This can be done by a simple FET. Get one that allows current to pass only when the gate is energized. This is so that a dead circuit will still open.)

        You will require multiple redundancies in just the ‘FET’ in case of over-voltage.

  4. Wonder if he gave any thought to the TI MSP430 series as these were designed from the ground up to be low power.

    HaD have had a few articles about their low power abilities.

    1. Have extensive experience with the MSP430 and like it a lot. Used it in thousands of sensor networking nodes building the systems at Streetline networks. Would plan to use one of the Value Line (G series) MSP430 chips in the final design.
      The pico power AVR chips (the ones with a “p” on the end) can get to similar sleep currents but only with brown out detection (BOD) disabled. Most of the new MSP chips include nano power BOD and that alone would push me towards using it. For a long lived battery powered device it is kind of important to know when voltages drop below usable when sitting on the shelf.

  5. Caleb and Naim Great post. On a pro mini I too get about 210 uA in sleep mode that is with no digital lines connected.

    Naim you said you removed the regulator on the pro mini, how did you supply voltage to the pro mini? Somehow you eventually need to supply power even in sleep mode.

    I would love to drop it to 34 uA.


Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.