Difference between revisions of "Arduino low power"
From emboxit
m (1 revision) |
|||
Line 1: | Line 1: | ||
+ | ==Marco Schwartz== | ||
*[http://www.openhomeautomation.net/arduino-battery/ How to Run an Arduino for Years on a Battery] | *[http://www.openhomeautomation.net/arduino-battery/ How to Run an Arduino for Years on a Battery] | ||
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. | 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. | ||
Line 78: | Line 79: | ||
} | } | ||
</cpp> | </cpp> | ||
+ | <br> | ||
+ | |||
+ | |||
+ | ==jeelib== | ||
+ | *[https://github.com/jcw/jeelib/blob/master/JeeLib.h jcw/jeelib] | ||
+ | <br> | ||
+ | |||
+ | |||
+ | ==Whisper Node - AVR== | ||
+ | *[https://bitbucket.org/talk2/whisper-node-avr/overview Whisper Node - AVR in Bitbucket] | ||
+ | <pre> | ||
+ | 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 | ||
+ | </pre> | ||
+ | <br> | ||
+ | |||
{{Cat1|WSN|Arduino}} | {{Cat1|WSN|Arduino}} |
Revision as of 21:32, 3 April 2017
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>
- 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
- Be prepared to new Ultra Low Power Arduino Wireless Sensor Node
- RFM69 library for RFM69W, RFM69HW, RFM69CW, RFM69HCW (semtech SX1231, SX1231H)
- Low power libraries for Arduino – Control sleep with single function calls
- Rocket Scream: Lightweight Low Power Arduino Library
- Best ways to power a Arduino according to your need
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/
- 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();
}
</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