Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials_sleep [2018/08/24 06:23] theo created |
tutorials_sleep [2018/08/24 07:01] (current) theo |
||
---|---|---|---|
Line 1: | Line 1: | ||
======= Sleep and Low Power ======= | ======= 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. | ||
+ | |||
+ | You can download SleepLibrary code from [[https://github.com/TheodorUngureanu/SparrowV/tree/master/SleepLibrary|here]]. | ||
+ | |||
+ | Bellow you can see and example on how to use sleep library. | ||
+ | |||
+ | <code C> | ||
+ | /* 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); | ||
+ | } | ||
+ | </code> |