Best ways to power a Arduino according to your need

In this post I will describe what is the best way to power a Arduino according to your needs.

Of course according to your needs, the way you power your Arduino system, is very important. If you want to make a system connected to a wall plug it is much easier than running an autonomous system on batteries for a while.

 

Regulate power without power contraint

Power adapter for Arduino board

If you want to run your system over an Arduino board (typically Arduino Uno), It’s really simple. You juste need to plugin a DC Power adapter supply (5V to 12V). Less than $6 on Amazon


 

 5V regulator for standalone Atmega

If you want to run Atmega in a standalone mode (as I described in a previous post), You’ll need to regulate power in order to provide 5v to the Atmega. The best way to do is to use a 7805 Chip:

It is easy to use in order to regulate any input voltage to 5V output voltage. In addition to the 7805 regulator you’ll need 2 capacitors to avoid noise.

 

Here is the schema for create this kind of regulation

 

7805

 

Autonomous system

Making an autonomous system is more tricky. First you have to take care to reduce power consumption and then you have to use batteries to make your system free of wire.

Why using a classic Arduino board is not a good idea?

Arduino (Arduino Uno) board are not designed to be used in a such mode  because:

  • Integrated linear regulator consumes around 0.35W to convert 12V to 5V: This regulator is a NCP1117ST50T3G low dropout linear regulator. This regulator consumes  50mA to drop down 12V to 5V.
  • Some LEDs are always powered on the board. A led can use up to 1mA
  • Board has a 16mhtz oscillator built-in: Arduino can run at 8Mhz with a lower consumption (more than twice less)
  • Atmega  is powered at 5V : At 3.3V, the chip uses  only 40% of the power used at 5V.

 

What kind of solution should I use?

So the best way to go is to bypass regulator and use directly 3.3V batteries to power your arduino, use a 8Mhz oscillator, and avoid useless LED.

Here is an exemple of a low consumption Atmega system – capacitor is used to avoid noise on powering :

power-2

 

Well what can I do if I want to use 5V regulator anyway?

In some cases you’ll need to use 5V – because of sensors or actuators you want to use on your project. In this case avoid to use a LM7805 regulator and choose a  low dropout positive voltage regulator such as MCP1702. This regulator has a 2.0 µA quiescent current instead of 5mA for LM7805. Here is a sample with a 9V battery:

power9V-2

 

How can I build a system with a rechargeable battery?

When you want make an autonomous system, you often want to make it rechargeable and why not with a solar panel.

Here is a really useful system to manage Li-Po battery with a solar panel: Li-po rider

lpr1301_02

 

Optimizing code

Most of time on Arduino project is spent on delay function. All this time spent is power consuming.

Arduino has some sleeping mode as explain is this blog: http://donalmorrissey.blogspot.fr/2010/04/putting-arduino-diecimila-to-sleep-part.html

Putting Arduino on one of this sleep mode reduce a lot power consumption. It is possible to consume les than 50uA :

  • SLEEP_MODE_IDLE – the least power savings
  • SLEEP_MODE_ADC
  • SLEEP_MODE_PWR_SAVE
  • SLEEP_MODE_STANDBY
  • SLEEP_MODE_PWR_DOWN – the most power savings

According to the sleeping mode, some feature of the controller are stopped:

Picture 1
When the micro-controller is entered into sleep mode by your code, the execution of code will pause at that point. In order to resume execution of your code, the micro-controller must then be woken from sleep mode by one of it’s internal hardware modules, e.g. timer expiring, external interrupt, WDT, etc.

Anyway, the blog http://donalmorrissey.blogspot.fr/2010/04/putting-arduino-diecimila-to-sleep-part.html explains perfectly how to play with sleeping mode.

So I will focus here on a given library named Sleepy (http://jeelabs.org/2011/12/13/developing-a-low-power-sketch/)

Sleepy

Here are some exemples on how to use Sleepy lib.Why Sleepy? because it is really easy to use!

Documentation is here: http://jeelabs.net/pub/docs/jeelib/classSleepy.html

Simply replace delay by Sleepy

#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);
 Sleepy::loseSomeTime(5000);
 
 // Turn the LED off and sleep for 5 seconds
 digitalWrite(led_pin, LOW);
 Sleepy::loseSomeTime(5000);
}

Wake up on interrupt
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();
}

Summary – tips and tricks

noregu
Bypass power regulator or if you want to regulate to 5V use MCP1702 instead of LM1705
no5V
Power your project directly with 3.3V

noled
Remove useless LED

no16
Use a 8Mhz resonator instead of 16Mhz

yessleep
Make your atmega sleep as long as possible

yespower
While sleeping put output to input with low state. If ADC is not used turn it off

nosensor

Turn off actuator and sensor as soon as possible

Sources

11 Comments

  1. I’m not well versed in electronics so excuse the maybe-simple questions.

    1.- What is the device connected to AVCC and Ground?
    2.- What’s the capacity of the capacitor?
    3.-I don’t understand what the oscillator is for, think you could expand on that?

    Reply
  2. great job

    I use 4 x 1.20v rechargeable bateries, I dont worry about use near empty batts because we can use any volt between 3 and 5 or more, the only you can take care its that logic ttl depends on power supply voltage. all this extends the use of a battery.

    Reply
  3. Hi,

    I like the article, just to point a slight thing out, that when running at 8MHZ you dont need any external component (resonator / crystal) because default running frequency is already 8MHz. My last project that used barebone chip is now running for 3 months and counting.

    Reply

Leave a Comment.