Arduino POWER 200 nano Amps current SLEEP - 2000 Year Battery Life!
I'll show how it's possible to power an Arduino constantly for over 2000 years using the energy in a single 18650 Lithium Ion Cell.
#ArduinoPower
#AtmelPower
#BestBatteryLife
#Arduino
#LongLifeBattery
Code below - CHANGE INCLUDES to use ANGLE BRACKETS and use 'less than' in place of" i!=5"
Sleep pin interrupt :
// see https://gist.github.com/JChristensen/5616922 for this and other chip sleep function
#include "avr/sleep.h"
#define LED 4 //LED on pin 4, PB4, DIP pin 3
#define BODS 7 //BOD Sleep bit in MCUCR
#define BODSE 2 //BOD Sleep enable bit in MCUCR
ISR(INT0_vect)
{
GIMSK = 0; //disable external interrupts (only need one to wake up)
}
void setup(void)
{
//to minimize power consumption while sleeping, output pins must not source
//or sink any current. input pins must have a defined level; a good way to
//ensure this is to enable the internal pullup resistors.
for (byte i=0; i!=5; i++) { //make all pins inputs with pullups enabled
pinMode(i, INPUT);
digitalWrite(i, HIGH);
}
pinMode(LED, OUTPUT); //make the led pin an output
digitalWrite(LED, LOW); //drive it low so it doesn't source current
}
void loop(void)
{
goToSleep();
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(LED, LOW);
// delay(5000);
}
void goToSleep(void)
{
byte adcsra, mcucr1, mcucr2;
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
MCUCR &= ~(_BV(ISC01) | _BV(ISC00)); //INT0 on low level
GIMSK |= _BV(INT0); //enable INT0
adcsra = ADCSRA; //save ADCSRA
ADCSRA &= ~_BV(ADEN); //disable ADC
cli(); //stop interrupts to ensure the BOD timed sequence executes as required
mcucr1 = MCUCR | _BV(BODS) | _BV(BODSE); //turn off the brown-out detector
mcucr2 = mcucr1 & ~_BV(BODSE); //if the MCU does not have BOD disable capability,
MCUCR = mcucr1; // this code has no effect
MCUCR = mcucr2;
sei(); //ensure interrupts enabled so we can wake up again
sleep_cpu(); //go to sleep
sleep_disable(); //wake up here
ADCSRA = adcsra; //restore ADCSRA
}
Current test of digitalRead() for comparison:
// test of current consumption while scanning pin - TD
const byte Button = 2; // dip pin 7
void setup() {
pinMode (4, OUTPUT); // dip pin 3
pinMode (Button, INPUT);
digitalWrite(Button, HIGH);
}
void loop(){
while (1){
if (digitalRead(Button) == LOW) {
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
delay(100);
}
}
}
Видео Arduino POWER 200 nano Amps current SLEEP - 2000 Year Battery Life! канала Tom Donnelly
#ArduinoPower
#AtmelPower
#BestBatteryLife
#Arduino
#LongLifeBattery
Code below - CHANGE INCLUDES to use ANGLE BRACKETS and use 'less than' in place of" i!=5"
Sleep pin interrupt :
// see https://gist.github.com/JChristensen/5616922 for this and other chip sleep function
#include "avr/sleep.h"
#define LED 4 //LED on pin 4, PB4, DIP pin 3
#define BODS 7 //BOD Sleep bit in MCUCR
#define BODSE 2 //BOD Sleep enable bit in MCUCR
ISR(INT0_vect)
{
GIMSK = 0; //disable external interrupts (only need one to wake up)
}
void setup(void)
{
//to minimize power consumption while sleeping, output pins must not source
//or sink any current. input pins must have a defined level; a good way to
//ensure this is to enable the internal pullup resistors.
for (byte i=0; i!=5; i++) { //make all pins inputs with pullups enabled
pinMode(i, INPUT);
digitalWrite(i, HIGH);
}
pinMode(LED, OUTPUT); //make the led pin an output
digitalWrite(LED, LOW); //drive it low so it doesn't source current
}
void loop(void)
{
goToSleep();
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(LED, LOW);
// delay(5000);
}
void goToSleep(void)
{
byte adcsra, mcucr1, mcucr2;
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
MCUCR &= ~(_BV(ISC01) | _BV(ISC00)); //INT0 on low level
GIMSK |= _BV(INT0); //enable INT0
adcsra = ADCSRA; //save ADCSRA
ADCSRA &= ~_BV(ADEN); //disable ADC
cli(); //stop interrupts to ensure the BOD timed sequence executes as required
mcucr1 = MCUCR | _BV(BODS) | _BV(BODSE); //turn off the brown-out detector
mcucr2 = mcucr1 & ~_BV(BODSE); //if the MCU does not have BOD disable capability,
MCUCR = mcucr1; // this code has no effect
MCUCR = mcucr2;
sei(); //ensure interrupts enabled so we can wake up again
sleep_cpu(); //go to sleep
sleep_disable(); //wake up here
ADCSRA = adcsra; //restore ADCSRA
}
Current test of digitalRead() for comparison:
// test of current consumption while scanning pin - TD
const byte Button = 2; // dip pin 7
void setup() {
pinMode (4, OUTPUT); // dip pin 3
pinMode (Button, INPUT);
digitalWrite(Button, HIGH);
}
void loop(){
while (1){
if (digitalRead(Button) == LOW) {
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW);
delay(100);
}
}
}
Видео Arduino POWER 200 nano Amps current SLEEP - 2000 Year Battery Life! канала Tom Donnelly
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Arduino Power Saving Tutorial: Clock Pre-Scale and SleepBaiway Configurable Multi-chemistry Battery Meter. 3.2-70V#379 The All-New Arduino IDE 2.0: Introduction and TestThe BEST Way TO Perform a Parasitic Draw TestArduino Nano Every: Honest Review and actual info!You can learn Arduino in 15 minutes.How a CPU is madeLow Power Arduino - Sleeping at 0.3mA perfect for batteries (Arduino Nano deep sleep)DIY USB microscope demoCan you regenerate a dead power tool battery?How Long Can An Arduino Run On Batteries? I Tested 6 Of The Most Common BoardsProfessional SMT Soldering: Hand Soldering Techniques - Surface MountWill Batteries Power The World? | The Limits Of Lithium-ionElectronic Basics #24: Stepper Motors and how to use themArduino Project to Product Part 4: Optimizing Operating Voltage – Maker.io Tutorial | Digi-KeySolar Panel Systems for Beginners - Pt 1 Basics Of How It Works & How To Set UpDisplay examples - which one to use?$300 DIY Tesla Powerwall - Solar storage 18650 lithium ion home BatteryUltra Low Power Microcontroller DesignBuild a Simple Power Supply