Arduino low power

From emboxit
Jump to: navigation, search

Marco Schwartz

 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.

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:

Sleepy::loseSomeTime(5000);

<cpp>

  1. 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);

}</cpp>

  • 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


Wake up from interrupt <cpp> // 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/

  1. include <Ports.h>
  2. include <RF12.h>
  3. include <avr/sleep.h>
  4. include <PinChangeInt.h>
  5. include <PinChangeIntConfig.h>

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

  1. define PIR 5
  2. 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();

} </cpp>


jeelib



Whisper Node - AVR

Input Voltage	Mode	                                Current
3V	        All Sleeping	                        3.7µA
3V	        All Sleeping + RTC	                9.6µA
3V	        MCU Running, Flash and Radio Sleeping	7.8mA