This is an old revision of the document!


Sleep and Low Power

We want to collect data from sensors and then periodically send packets of data. When we do not want to do this at a high frequency, we have some dead times. This leads to high energy consumption, which can have a significant impact on the battery life of sparrow when it is powered by a battery.

Bellow you can see and example on how to use sleep library.

/* This is an example for SparrowVSleep library.
    You need to call SparrowV_SleepInit function.
    The funciton has 2 params.
    1st param: integer (> 1 second, greater than 1 second) (represent time in seconds, how long the board will sleep)
    2nd param: bool (true - with data retention, false - with no data retention)
               In case of no data retention the board can sleep max 8 secons and it will
    reboot after time end.
*/
 
#include <SparrowVsleep.h>
 
void setup() {
  Serial.begin(9600);
}
 
void loop() {
  // put your main code here, to run repeatedly:
  Serial. println("****************************");
  Serial.println("Start");
  Serial.flush();
 
  //sleep for 25 seconds with data retention
  SparrowV_SleepInit(25, true);
 
  Serial.println("Stop");
  Serial. println("****************************");
  Serial. println();
  Serial.flush();
  delay(5000);
}