Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Hardware Modification


Image AddedImage Added

Stage

idel Power

Feature lost by modification
Initial0.121W120W-
w/o 78M050.096WOption to use 6v-12v external power
w/o Power LED0.081WPower indicator
w/o diods diods and LED0.072WExtra protection from mess with -/+
software sleep0.002WSimple code


Software optimization


Image Added

Image Added

Code with delay()

0.072W0.120W
Code with cpu_sleepuse sleep_cpu()0.002W0.041W


Blinking Led

Code Block
languagecpp
void setup()
{
  pinMode(1, OUTPUT);
}
void loop()
{
  digitalWrite(1, HIGH);
  delay(1000);
  digitalWrite(1, LOW);
  delay(1000);
}


Low Power Blinking LED Example

Code Block
languagecpp
#include <avr/wdt.h>
#include <avr/sleep.h>
#include <avr/interrupt.h>

#define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC (before power-off)
#define adc_enable()  (ADCSRA |=  (1<<ADEN)) // re-enable ADC

void setup()
{
  // Power Saving setup
  for (byte i = 0; i < 6; i++) {
    pinMode(i, INPUT);      // Set all ports as INPUT to save energy
    digitalWrite (i, LOW);  // Might help if ther is some sensors on pins? No impact in this demo
  }
  adc_disable();          // Disable Analog-to-Digital Converter

  wdt_reset();            // Watchdog reset
  wdt_enable(WDTO_1S);    // Watchdog enable Options: 15MS, 30MS, 60MS, 120MS, 250MS, 500MS, 1S, 2S, 4S, 8S
  WDTCR |= _BV(WDIE);     // Interrupts watchdog enable
  sei();                  // enable interrupts
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Sleep Mode: max
}

void loop()
{
  //Set the LED pins to HIGH. This gives power to the LED and turns it on
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);  
  digitalWrite(0, HIGH);
  digitalWrite(1, HIGH);

  sleep_enable();
  sleep_cpu();
  
  //Set the LED pins to LOW. This turns it off
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);  
  digitalWrite(0, LOW);
  digitalWrite(1, LOW);
  //Wait for a second

  sleep_enable();
  sleep_cpu();      
}

ISR (WDT_vect) {
  WDTCR |= _BV(WDIE); // разрешаем прерывания по ватчдогу. Иначе будет реcет.
}


Source: https://alexgyver.ru/pump-sleep/

...