sleepBlink Example – eS2 Pro

< All Topics

This is an example sketch designed to demonstrate the power sleep functionality of the energyShield 2 Pro. In this example, the sketch blinks an LED three times and then commands the energyShield to turn the power off for four seconds. After four seconds the energyShield re-enables the power and the sketch restarts.

For more information or to download the Arduino Library check out the eS2 Pro Arduino Library Reference.

// Cached on 04/03/2018
/*************************************************************
  sleepBlink - energyShield2                              
  by NightShade Electronics V1.0                          
                                                         
  This sketch blinks the pin 13 LED three times and       
  sleeps for 4 seconds. These results is an approximate   
  20% duty cycle for power comsumption. That means that   
  this blink sketck will run 5 times as long as the       
  standard blink sketch will run on the same battery.         
                                                          
  Created by Aaron D. Liebold                             
  on January 30, 2017

  Distributed under the MIT license
  Copyright 2017 NightShade Electronics
  https://opensource.org/licenses/MIT         
*************************************************************/

// Includes enegyShield2 library files
#include <NS_energyShield2.h>
#include <NS_eS2_Utilities.h>

// Defines NS_energyShield2 class object "es2"
NS_energyShield2 es2;

void setup() {
  es2.begin(); // Initialize energyShield  
  if (es2.readVMPP != -1) es2.setVMPP(-1, 1); // Disable VMPP regulation to allow charging from any source (7V - 23V) and prevent excessive EEPROM writes
  
  pinMode(13, OUTPUT);
}

void loop() {
  // Blinks three times
  blink();
  blink();
  blink();

  // Sleeps power for 4 seconds
  es2.sleepSeconds(4);
}

// Blinks LED
void blink() {
  digitalWrite(13, HIGH);
  delay(166);
  digitalWrite(13, LOW);
  delay(166);
}
 
Previous solarLCD Example – eS2 Pro
Next readAll Example – eS2 Pro
Table of Contents