How to Run an Arduino for Years on a Battery

How to Run an Arduino for Years on a Battery

If you found this article after doing a search on Google, welcome! On this website you will find plenty of content around DIY home automation using open-source hardware. Enjoy the article!

For most of the Arduino tutorials you will find on this website, power is usually not an issue as the Arduino is powered by the USB cable coming from the computer. However, sometimes you want to build systems that are going to be autonomous and powered by a battery.

For example, you want to power the wireless motion detector just by using a set of batteries. The first idea would be to connect directly an Arduino board like the Arduino Uno R3 to a battery. Easy, right ? Well, it would work, but your battery would be depleted in a matter of days because some components like voltage regulators are always sucking power. So we need something better.

The first thing we need is to build our own Arduino system with just the minimal set of components. This will be similar to a previous article, but with even less components. The second part is to optimize the software so that the system only consumes power when it is actually doing something. And that’s exactly what we will see in this article.

Hardware & Software Requirements

You need several components to build you own Arduino system. The main piece of this project is of course the microcontroller that will run your Arduino sketches, like the Atmel ATmega328. You will need a chip with the Arduino bootloader. Buy your chip with it, it will make your life easier.

How to Run an Arduino for Years on a Battery

In a previous project I used a FTDI breakout board to program the Arduino chip directly on the breadboard. But for this project I won’t have any external power running on the breadboard so I will just use an Arduino Uno board to program the microcontroller.

To power the Arduino, you will need a battery. The best is to power the Arduino directly from the battery, so you don’t have to use any voltage regulators that will suck some power. I used a set of two AA batteries (1.5V each) with a battery holder thus powering the microcontroller with around 3V, which is fine according to the ATmega328 documentation.

You will also need several components around the chip. You will need one 10uF capacitortwo 22pF capacitorsone 10K Ohm resistorone 220 Ohm resistorone green LED, and one 16MHz crystal clock.

Finally, you will need a breadboard and some jumper wires.

This is the list of the components that were used in this article:

On the software side, you just need the usual Arduino IDE. Note that in this tutorial, we will only cover a tiny part of the possibilities offered by the Arduino platform. [Arduino course]

Hardware Configuration

This project is a bit complex to build, so be sure to follow the instructions. This is how it should look like at the end:

How to Run an Arduino for Years on a Battery

First, put the microcontroller in the center of the breadboard. You can then take care about the power: connect power lines on each side, connect the negative power rail to the two GND pins of the microcontroller, and the positive power rail to VCC, AVCC, and AREF. Also, add the 10uF capacitor between two power rails. Finally, add the battery to the system.

You also have to add the crystal between the X1 and X2 pins, with 22pF capacitors going from each pin to the ground. Also, you need to connect the RST pin to the positive power rail using a 10K Ohm resistor. To see if the system is working, connect the green LED in series with a 220 Ohm resistor to the digital pin 13 of the Arduino board, the other side going to the ground.

This is the complete schematics of the project:

How to Run an Arduino for Years on a Battery

Testing your Arduino system

It’s now time to test if the hardware part is working. What I did in this project is to use the Arduino Uno board to program the chip, and then I just “transplanted” the chip on the breadboard. You can just use the default “blink” sketch to program the microcontroller. After this is done, just replace the chip on the breadboard, and plug your battery (my battery pack even has a nice on/off switch). The LED should just goes on and off every second as expected.

Optimizing for Low-power

So now, we have an autonomous Arduino system. But it still consuming way too much power. Indeed, even when the LED is off, the Arduino chip is still active and consumes power. But there are functions on the microcontroller to put it to sleep during the time it is inactive, and re-activate the chip when we need to change the state of an output or to perform some measurements. I tested many solutions to really reduce the power to the lowest value possible, and the best I found is the JeeLib library. You can just download it and install it by placing the folder in your Arduino/libraries/ folder.

This is the sketch I used:

#include <JeeLib.h> // Low power functions library
int led_pin = 13;
ISR(WDT_vect) { Sleepy::watchdogEvent(); } // Setup the watchdog

void setup() {
 pinMode(led_pin, OUTPUT);

void loop() {

 // Turn the LED on and sleep for 5 seconds
 digitalWrite(led_pin, HIGH);

 // Turn the LED off and sleep for 5 seconds
 digitalWrite(led_pin, LOW);

You basically just have to include the JeeLib library with:

#include <JeeLib.h>

Then initialize the watchdog with:

ISR(WDT_vect) { Sleepy::watchdogEvent(); }

Finally, you can put the Arduino to sleep for a given period of time with:


Upload the sketch with the Arduino IDE and replace the chip on the breadboard. You should see your Arduino having the same behavior as before (with 5 seconds intervals). But the difference is that now when the LED is off, the Arduino chip doesn’t use a lot of power. To finish this article, I wanted to actually quantify the power consumption of the system we just built. You can do the exact same by placing a multimeter between one of the power lines. For example, I connected the positive pin of the battery to one pin of my multimeter, and the other pin to the positive power rail of the breadboard. Here are the results:

  • LED off, without the JeeLib library: 6.7 mA
  • LED on, without the JeeLib library: 8.8 mA
  • LED off, with the JeeLib library: 43 uA (!)
  • LED on, with the JeeLib library: 2.2mA

From these results, we can see that our breadboard-Arduino consumes 6.7 mA when doing nothing without caring about putting it to sleep. For information, that will drain your two batteries in about a month. Which is actually not so bad, but we can do better. With the sleep functions, this can be reduced to 43 uA, which is a 150x improvement.

Let’s do some calculations to see how it will impact a real project, for example a temperature sensor. It takes about 500 ms to perform a measurement, at about 2.5 mA of current. Then, the systems sleeps for 10 seconds and the loop starts again. The “mean” is then 0.16 mA over a complete loop. With batteries rated at 2500 mAh, it means in theory the system will last … nearly 2 years without changing the batteries! Of course, some other effects will actually modify this number, but it gives you an idea.

How to Go Further

Really, you can adapt this idea to every system where the active time is small compared to the sleep time, and make your Arduino last for years without changing the battery! If you want to learn more about the topic, note that there is a complete guide on how to build your own systems from scratch in our Home Automation with Arduino product.

Want to learn more? Get my free eBook about Arduino!

Arduino is an amazing platform that you can use to build all sorts of projects. Download today my free eBook "Building a Simple Alarm System with Arduino". Simply click on the button below!

Leave a Comment

Cikgu Aze 10 months ago
I have built same project a few years ago with microchip 12fxx series. Consume only 12uA during sleep. I use ucurrent gold from eevblog for current measurement. Scroll down this blog you will find ultra low current led flasher
Gustav Gullstrand a year ago
Why can't I read the article even though I follow the Get startet button and signing up on the newsletter?
brandan a year ago
Thanks for the great article. Thanks to you I now build most of my uno like projects myself starting with the chip. On a recent build I needed a regulated power for an external device and I started messing around with a MCP1700 power regulator and I found that using regulated power which lowered the voltage from the ~4v with the 3 AA batteries that I have been using to a solid 3.3v actually reduced my total power usage. So might reconsider the voltage regulators, but need to get the right kind.Brandan
Rudi a year ago
What good is it that the Arduino can run so long on a set of batteries? The example, with a temperature sensor doesn't really mean much - since you would probably want to do ^something^ with the temperatures collected, whether you want to write it to an microSD card, or transmit (wireless / 3G / bluetooth / LAN / ??) somewhere to be processed.While I do understand that one can run an MCU at really low power, I can't quite see the practical use of it.
Joe B Rudi a year ago
I plan on using it to create an alarm. So it will sit dormant for months without being used and only run when a switch is activated.
Gabriel a year ago
congratulations for the article! what will be the logic levels when you feed the microcontroler with 3v? HIGH will be 5v? 3v? thanks!
AdrianZ41 2 years ago
Great article!! just what i needed for my project. Quick question though. If I wasnt to use 4 AA batteries within my project (as I need to run a 4-6v Pump) do I need to put any voltage protection in place to not overload the chip?
Ronaldo Brandão 2 years ago
Good Morning. I made the assembly of the standalone with the sleep mode, but can not get consumption below 2mA. You can help?the ATMEGA328P-PU is configured with internal clock 8Mhz.
Luis Minvielle 2 years ago
Hi Marco, the whole guide looks appealing. I'm not savvy on electronic issues but I'll be trying to replicate this tutorial. At least I'll learn, even if its by tidbits.Marco, I've been using a controller to move a servo motor via the Internet, using a web server. So, I've been connecting the controller to the internet (via Ethernet), and to a wall outlet for power purposes (12v, 2Am). This is, my controller has 2 cables, one for power and the other for connecting it to the internet.I have to do connect this same controller once again, but wirelessly. So, I've been thinking of shifting to Arduino and following your tutorial to ditch the power supply.But what about connecting to WiFi? Ain't it too power-demanding? I've been checking the "WiFi shields".What I need to do with my device is connecting it to a Web Server (thru Internet) so as to tell the Arduino: "move a Servo motor". That's it. The Web Server should be always online, but maybe Arduino shouldn't be!As I'm clueless on the electronics universe, I can't make the reasoning behind this implementation. Do you think it's possible? Making the batteries last for a couple of months, then changing them, is completely fine to me.
Marco Schwartz Luis Minvielle 2 years ago
Hi Luis, interesting question. The whole 'trick' in this project is that it is only adapted for projects that can be on for a short time, and off for a long period of time. So even with a WiFi shield that will suck a lot of power, it's ok if your project just need to send data for a few seconds before sleeping again.
nadc 2 years ago
Help! I followed the instructions exactly, I uploaded the "Blink" program to the ATMEGA238P-PU from another Arduino then I installed the chip on the breadboard and connected all the components exactly as described. The led is off and not flashing. See attached image.Things I already tried:- Had the ATMEGA + led + 220 ohm resistor installed on the Arduino Uno board. It starts blinking as expected, the ATMEGA chip doesn't seem to be dead.- Connecting the led + 220 ohm resistor to VCC and GND. It works, so the led and the resistor are good.- Swapped every component out with another identical one, one at a time. That did not help.What else can I try? If anyone has any suggestions, it would be greatly appreciated!
nadc nadc 2 years ago
I figured out my solution thanks to help from StackExchange: http://electronics.stackexc.... I had to add a 3rd battery.
AndrewS 2 years ago
This seems to be an interesting solution to run "Arduino" on batteries: to the documentation the whole board consumes less than 4uA when sleeping and can be powered by a single AA.
Moebius L. AndrewS 2 years ago
Cool, I got a few of those boards from here: and it's already working for at least three months reporting temperature and humidity from my attic. I'm using 2 AAs and the voltage only dropped from 3.14 to 3.09... expect it to run for a few years! :)
Grant Anderson 2 years ago
Great article! I didn't know about the JeeLib libraries at all. What an eye opener. I should mention something interesting about battery life. As everyone is aware, as the battery ages it will lose it's voltage and continually decline to a point where it's not producing enough voltage to run the Arduino. However, it still contains plenty of energy and more than enough to power the Arduino for a long time to go. So how do you get the extra bit of energy? Simple. If one attaches a tiny little device known as a joule thief, it will sustain the full voltage through out it's entire life and will even draw out all of the energy of the battery until it's absolutely depleted. Look on Youtube for Joule thief circuit and a video of it's inventor (or at least the guy who realized it's potential and gave it the name "joule thief." It's incredibly easy to make with a little piece of iron ferrite and some thin insulated wire and a transistor. The voltage can be "smoothed," by adding a 100uf to 680uf capacitor at it's output.
D.M. Raspberry 2 years ago
dear all...Is this still working or are there better solution's???Some have this working with mysensors????And will share his sketch??thanks!!
Marco Schwartz D.M. Raspberry 2 years ago
Still working :)
Stanislav Marencik 2 years ago
I prefer Arduino Pro Mini clone. Led diodes can be destroyed.For sleeping I use LowPower library. In sleeping 28uA is no problem.Here is my article Consumption of Arduino Pro Mini
Ivaylo Trepetanov 3 years ago
HI, i have a problem with this library. I use Sleeping Beauty Bare Bone V3 ( and i get results 6mA / 3mA. i removed the leds from the board and i still get the same results, what could be the problem? the avr is 1284p. is this library working with the latest Arduino IDE 1.6.6 and that chip? Does the voltage matter cause i try to run it on 16 MHZ at 4.5 V ?
Marco Schwartz Ivaylo Trepetanov 3 years ago
Hi! Maybe an issue with the chip you are using indeed. I'd try contacting the guys at Jeelib to check if it is compatible with the 1284p as well.
Paul 3 years ago
Thank you, this is a really interesting post. Do you have any advice on the least power intensive way of saving the data to memory. Say you have a years worth of data is an SD card the best approach?
Marco Schwartz Paul 3 years ago
Thanks Paul! That's something I didn't really experiment with, but I invite you to first measure how much the Arduino would use when writing to a SD card :)
Nick Jay 3 years ago
Hi all, I designed a barebones ATmega1284p-pu breakout board. Which is current selling on e-bay and Tindie in both bareboard and kit form. Somebody who bought one off me said that they had recorded very low current consumption in sleep mode. So I set about testing it for myself. The results were quite remarkable, using the example above, but with an ultrabright 3mm blue led. I recorded 4.6μA in sleep led off, and 469/470μA led on. See This video
James Heires 3 years ago
Marco, Thanks for posting. Have you looked into interfacing your low power ATMega circuit to a wireless (say, BLE) module? I want to use a wireless module to talk to my ATMega with a smartphone over bluetooth (or wifi, but wifi is probably too power hungry)... Any thoughts?
Marco Schwartz James Heires 3 years ago
Hey! I did indeed, not on this blog but in my book about Arduino & Android that I co-wrote with a friend. The link:
Ali Ahmer 3 years ago
Its Really Working.... Thanks Sir, for share this.... Its really consume too much power.
Guillaume Sartenaer 3 years ago
hello great article!i hace a simple ... what is the purpose of capacitor on battery?
Marco Schwartz Guillaume Sartenaer 3 years ago
Thanks! It's here to regulate the voltage so the Arduino gets a stable power supply.
Jacob Thomas 3 years ago
Thanks for the Great tutorial!Wanted to know your recommendations for a wireless radio module. I'm building a project to monitor a garden with various sensors, temperature, moisture, humidity and I want to run the whole thing on regular batteries.
Marco Schwartz Jacob Thomas 3 years ago
Thanks! Have a look at XBee modules they work great with Arduino.
Guillermo 3 years ago
Edit: problem solved, I feel really stupid now. I am using a long breadboard and I had another IC which I forgot to disconnect :o Dumb dumb dumb. I compiled it without errors too. Now it goes down to 5uA!!!Thank you for the article.I get a compilation error on lineISR(WDT_vect) { Sleepy::watchdogEvent(); } // Setup the watchdogerror: expected unqualified-id before string constantIf I remove the line, the code works and it consumes to 10mA while running LoseSomeTime(). Even if lower than regular delay function (15mA), it is still very high. Could it be that line the cause of the problem?
Christian Lee 3 years ago
Wow, awesome. Will this save power even if using the library with a standard Arduino Uno board? Thanks!
Marco Schwartz Christian Lee 3 years ago
It will save power, but don't expect to run an Arduino Uno for years with a single battery :)
Jean-Philippe Encausse 3 years ago
Thanks for this article and explanation !Where can we buy that kind of arduino board ?I'd love to make an Arduino with a PIR (motion detector) and a camera taking very short shoot.
Marco Schwartz Jean-Philippe Encausse 3 years ago
Thanks! Well to find all the components used in the article simply follow the links to Amazon by clicking on them :)
Arun chandran 3 years ago
GreetingsFirst of all thanks a lot for introducing me to jeelib. Its such a great article , although im relatively new with arduino.My issue is that im trying to build a key finder using ble modules and for this to happen im serially communicating with my ble module using arduino at a baud of 9600 ,my ble doesnt seem to respond to the arduino at any other baud. it works without using the jeelib libraries. Now i wanted to take it to the next level by optimizing the usage of Battery. but while using the jeelib library im not able to serially communicate wit the ble module. Is there any way i can change the baud at the jeelib libraries so that i can successfully reduce my battery usage and communicate with my ble ?RegardsArun
Marco Schwartz Arun chandran 3 years ago
Hi Arun! BLE + jeelib is not something I tried, but maybe somebody here will have a solution for you :)
Nic 4 years ago
Hi there, I feel like I'm missing something here. I built the circuit as you stated and I am not seeing the LED blink. But when I connect the ATmega328 to a arduino uno board the LED blinks just fine. When measuring the voltage on D13 (when the ATmega is on the breadboard) it is very low 50mV. But when I do the same measurement on the arduino board I get a measurement of 4.95V on D13. I realize the aduino board is being feed more voltage and thats why D13 has a 4.95V but I would expect to see something similar on the breadboard (i.e. 2.95V on D13). I would appreciate any help thanks.
Marco Schwartz Nic 3 years ago
Hi Nic, I just checked the project again and it's working fine. Probably a missing connection somewhere (especially check the power supply connections), or a lack of a good power supply for the breadboard project.
ani 4 years ago
hi mentioned that with With the sleep functions, this can be reduced to 43 uA, which is a 150x improvement....can you talk about the sleep functions, because i would like my batteries to atleast last 5 months...thanks...and i have applied jeelib in my code....i will be posting my code you mind checking whether i have applied it correctly or not ..thanks...
Marco Schwartz ani 4 years ago
The sleep functions are exactly the one I used with the JeeLib library. Basically you extend the battery by having very little up times (for data acquisition for example) vs very long sleep times.
littleguy 4 years ago
Great article! Would this be suitable for building an LCD countdown timer?The resolution will be 1 second, so I'd have to pause at least once per second.Is there a better way for my particular projects?
Marco Schwartz littleguy 4 years ago
That would definitely work!
Ben Hearsum 4 years ago
I've tried out your example and it doesn't seem to work quite right for me. I'm using an Arduino Micro, so perhaps things are different.When I call Sleepy::loseSomeTime(5000); my device wakes up almost immediately. Reading the code, it appears that the interrupt handler is getting called very quickly, which of course calls watchdogEvent(), which causes loseSomeTime to bail out early.If I attach a multimeter to pin 13, I see it bouncing back and forth between HIGH and LOW very rapidly (a few times a second at least).Any help interpreting this would be greatly appreciated.
Marco Schwartz Ben Hearsum 4 years ago
That could definitely come from the Arduino Micro. I am not maintaining or developing this library, and so far I only tested with the Arduino Uno microcontroller (ATMega328p). I would suggest to contact the JeeLib guys to report your issue.
Heron 4 years ago
That 10uf capacitor link goes to a 450v version on Amazon. Is that correct?
Marco Schwartz Heron 4 years ago
Yes it is, it is just that the capacitor is rated up to 450V. But of course you can use a capacitor rated for 50V or less only :)
Bruno 4 years ago
Hi, Great Project!I've a question for you, It's possible to add a power booster circuit in order to power this miniduino with only 1.5v ? I saw people that is using a DC to DC converter to obtain more power from almost nothing as input.If you've some information about that would be great!Thanks!Best Regards!
Marco Schwartz Bruno 4 years ago
Hello Bruno, sure it is possible! Check:
Micah 4 years ago
I have the same setup except I am running from a 9V battery with a 5V regulator. I am showing about 56mA while the LED is on and 37mA while it is off. This seems too high even though I'm running 5v. Any remarks?Thanks,Micah
Marco Schwartz Micah 4 years ago
Hello Micah, I guess what you are seeing is the consumption of the 5V regulator that always sucks power. I would recommend using a battery in the 3-5V range to power up the Arduino with intermediate components.
David 4 years ago
A really nice writeup. Tried it out on a ATtiny85 project. The results - staggering.Standby power draw before: 4.5mA. Standby power draw after including JeeLib: 0.008mA. The device does a digitalRead every second while on "standby". I calculated the battery to last 35 hours before and 27 months (!!!) after optimizing for power.
Marco Schwartz David 4 years ago
Hello David,Thanks for your message, and congratulations for building up the project!
Camillo 4 years ago
Hi, can I get the same results (2x1.5V batteries for 1 year) using an Arduino Pro Micro at 3V from SparkFun? you!
Marco Schwartz Camillo 4 years ago
No, as there are devices like a voltage regulator and some LEDs that will continuously suck some power from the battery. You can definitely use batteries with this board, but they won't last 1 year for sure.
Raaj 5 years ago
The Atmega328p doc says that when operating at 3V, you should run it at 10Mhz or below to prevent brown out and data corruption
Paul 5 years ago
This was a nice article and kudos for using the JeeLib libraries. JCW @ has done an amazing job at simplifying the use of the ATmega's low-power modes. I just wanted to point out one thing: while the ATmega will probably work ok at 3.0V using a 16MHz clock, it is technically over clocking it. See this page for a discussion about operating voltage ranges for the ATmega: As the 2xAA cells discharge down to < 2.0V, you are really only supposed to run the chip at about 4MHz. Using the internal oscillator (@ 8MHz or less) as suggested previously would be safer from a reliability perspective. The downside is that you could not use the Uno board definition and would instead need to use/create a new one to use the device properly in the Arduino IDE.
tes 5 years ago
hi all, i'm trying to build a perimeter security system with pir sensor and arduino my questions are 1. can i use arduino uno programs to run in arduino mini 2. can i have the arduino board sleep but the sensor still active so that when ever it detects motion the board will then go back to workand 3) since im trying to build three devices with transmitter so can i use only one receiver for the three devices? thank you in advance.
Marco Schwartz tes 5 years ago
Hello,1. In most of the cases it will be no problem. Just keep in mind that the Arduino mini runs at 3.3V, so some sensors might no work with the mini (or differently)2. For that you will need to use interrupt pins to wake up the Arduino when something happens on the sensor. You'll find plenty of documentation about that on the Arduino website.3. That depends on the technology you are using. With Zigbee for example you will no problem doing that.If you need additional help, don't hesitate to get in touch via email!
lucid dream 5 years ago
Hello, all is going well here and ofcourse every one is sharing facts, that's genuinely fine, keep up writing.
Martin 5 years ago
Thanks for the tutorial! Just a minor comment: When wiring batteries in series, the voltage adds and the capacity stays the same as for a single battery. I guess a standard alkaline AA battery has a typical capacity of 2500mAh and 1.5V, so two of them hooked up in series will also have 2500mAh, but (of course) 3.0V.
Marco Schwartz Martin 5 years ago
You're totally right, this mistake has been fixed in the article, thanks for your comment.
klas löfstedt 5 years ago
Your configuration will consume even less power if you skip the external crystal and go with just the built in, since you don't need the performance of the 16MHz for easier tasks.
Marco Schwartz klas löfstedt 5 years ago
Thanks, that's an excellent remark! I will definitely try that out.
Ken klas löfstedt 5 years ago
Second that. Very little you can't do at 8Mhz that you could at 16. Less parts and a significant drop in power consumption.
das klas löfstedt 4 years ago
Is the built in stable enough ? I have no experience with it .Thanks
Thomas 5 years ago
Hi,thanks for showing this optimization.How can I detect that a battery will be exhausted soon?Thomas
Marco Schwartz Thomas 5 years ago
Hi Thomas,For now there is no circuit to detect that the battery will be exhausted soon, but you could imagine reading the battery voltage via a voltage divider to check it constantly.
Kyle 5 years ago
Thanks. This always frustrated me with the ATmega chip. This is going to really change how I do projects!
Amir 5 years ago
I love how you put this terms in such simple explanation. thank you.
How to Run an Arduino for Years on a Battery How to Run an Arduino for Years on a Battery How to Run an Arduino for Years on a Battery How to Run an Arduino for Years on a Battery How to Run an Arduino for Years on a Battery How to Run an Arduino for Years on a Battery
Someone from Belgium
Recently signed up
13 hours ago
Someone from Greece
Recently signed up
7 days ago
Someone from Turkey
Recently signed up
11 days ago
Someone from the United States
Recently signed up
2 months ago
Someone from France
Recently signed up
2 months ago
Someone from Belgium
Recently signed up
2 months ago
Someone from Colombia
Recently signed up
2 months ago
Someone from Nigeria
Recently signed up
2 months ago
Someone from the United States
Recently signed up
2 months ago
Someone from Serbia
Recently signed up
2 months ago
38 people recently viewed this page