Загрузка страницы

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
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
29 сентября 2018 г. 20:40:09
00:11:35
Яндекс.Метрика