How to run an Arduino (clone) on (AA) batteries for over a year – Part 2

A short while ago, I wrote a blog post about running an Arduino on batteries. That post was well received and got many upvotes, likes, tweets and comments (Thanks everyone!). That post discussed among other things getting rid of energy suckers, low-quiescent current regulators and the use of sleep-mode. This post will discuss how to connect your Arduino (clone) to simple AA/AAA or coin cell batteries, how to use interrupts to wake Arduino from sleep mode and how to make sure that other components like sensors are not eating all the energy from your battery. 

Running an Arduino of AA/AAA or coin cell battery

As some of you commented, apart from running an Arduino of a 9V battery, one can easily run an Arduino of 3V or 4.5V with AA/AAA or coin cell batteries (given that you sensors or other electronics don’t need a higher voltage). This has the advantage that you don’t need a low-quiescent current power regulator (LDO) and that the battery life of your project will be even longer. The table below shows an overview of the currents available for different configurations (alkaline assumed):BatteryPack
• 9V Alkaline battery: 550 mAh
• AA batteries: 2700 mAh
• AAA Batteries: 1200mAh
• CR2032 coin cell: 225mAh
Assuming you have a circuit that takes an average of 0.49mA, like the one described in the previous post (which is quite high by itself), you can extend the battery life from 38 days to over 6 months with just two serial AA batteries (to create 3V). With four batteries, you can extend this even further to over a year!

Using interrupts with Arduino

Given that I use a so called PIR motion detector in one of my products, I needed to create a circuit and Sketch that would have the Arduino asleep all of the time and have it wake up when a motion was detected. Now these sensors are excellent for that: They consume only 50uA when looking for motion and give a high data-out signal, when motion is detected.
One way to archive this is to use one of the two interrupt pins of the ATMEGA328p to awake the Arduino. But since two was not enough in this particular design, I started a journey to find a way to use the pin-change interrupt functionality in the chip: The Arduino wakes up only when one of the regular pins changes value. This was quite a struggle, but after a while I got it working:

// Based on: http://arduino.cc/playground/Main/PinChangeIntExample
// More info on uA's: http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/
#include <Ports.h>
#include <RF12.h>
#include <avr/sleep.h>
#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>

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

#define PIR               5
#define BUTTON            4

void setup() {
  Serial.begin(57600);
  Serial.println("Interrupt example:");

  pinMode(PIR, INPUT);
  pinMode(BUTTON, INPUT);
  digitalWrite(BUTTON, HIGH);

  PRR = bit(PRTIM1);                           // only keep timer 0 going
  ADCSRA &= ~ bit(ADEN); bitSet(PRR, PRADC);   // Disable the ADC to save power
  PCintPort::attachInterrupt(PIR, wakeUp, CHANGE);
  PCintPort::attachInterrupt(BUTTON, wakeUp, CHANGE);
}

void wakeUp(){}

void loop() {
  if (digitalRead(PIR) == HIGH) {
    Serial.println("Motion detected");
  }
  else if (digitalRead(BUTTON) == LOW) {
    Serial.println("Button pressed");
  }
  Sleepy::powerDown();
}

Low power components and usage

A last thing that one has to keep in mind is the selection and usage of the other components in the design. It is very easy to have the Arduino running on uA’s for years on end, but to kill your battery with a power hungry sensor, networking module (like GSM, Zigbee or something similar) or a blinking LED (happened to me). Luckily, if you can read through a datasheet and watch yourself a bit, this shouldn’t be a problem.xbeezb

Let’s take for instance the motion detector that I was talking about. If you browse the web, you will find cheap ones that have a rest current of 1-5 mA. This means that in a typical scenario, you circuit can run for a max of (2700mAh/3mA/24hrs = 38 days) about a month. If you look further however (and test that the specified value is really reached when you get the part), you can find other versions that run on 50uA, yielding a theoretical battery life for sensor + Arduino of 5 years! (2700mAh/(50uA+10uA)/24hrs = 1875 days). In reality it probably is shorter, but this gives us a good starting point at least.
As for transmitters, etc, you can often put those to sleep and awake with some pin. Datasheets typicaly explain this quite good, as the designers know that people use this feature often to conserve battery life.

LED are power suckers

Also notorious are blinking LEDs, given that they consume between 5 -20 mA when on, one can easily eat a battery in less than a week (it happened to me).Let’s do some calculations with our two AA batteries (assuming 6mA Arduino current):
• LED (20mA) on all day: 4 days [avg current = 26mA]
• LED on/off (1s/1s): 7 days [avg current = 16mA]
• Same but with sleeping Arduino: 9 days [avg current = 13mA]
• LED on/off (0.5s/1.5s): 17 days [avg current = 6.5mA]
• Same with 10mA LED current: 28 days [avg current = 4mA]
• Same with 10s intervals between 3 pulses: 50 days [avg current = 2.4mA]

Conclusion

It is certainly possible to run your Arduino on batteries, even longer than a year. By using AA batteries, you will get more than four times the life span as with 9V batteries, and eight times in you use two sets in parallel. Interrupts allow your circuit to be asleep all of the time and only awake when there is action going on (button pressed, motion detected, packet arrived). But keep your eye on the power suckers like sensors and (blinking) LEDs.

Need a product developed or Want more Arduino and Hardware tips in your inbox?

Next to our own projects, we also develop for other companies (often with wifi, Ethernet, bluetooth, GSM/GPRS). Do you want us to develop or built a prototype for you? Feel free to contact us: hans@cloudsensor.us

Do you want to hear more about Arduino, embedded hardware and hardware startups? Click on the “Follow” button on the right, I appreciate it.

About these ads

One comment

  1. [...] A short while ago, I wrote a blog post about running an Arduino on batteries. That post was well received and got many upvotes, likes, tweets and comments (Thanks everyone!). That post discussed among other things getting …  [...]

Follow

Get every new post delivered to your Inbox.

Join 448 other followers

%d bloggers like this: