amc2022:grouph:here
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| amc2022:grouph:here [2022/09/09 17:46] – gustavo001 | amc2022:grouph:here [2023/01/05 14:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| {{ : | {{ : | ||
| + | //**figure 4.1**// Deep-Sleep set up for ESP32/ | ||
| + | ====== | ||
| {{ : | {{ : | ||
| - | ====== | + | //**figure 4.2**// Graph depicting Deep-Sleep schematics set up for ESP32/ |
| - | <Code c++> | ||
| - | #define uS_TO_S_FACTOR 1000000 | ||
| - | #define TIME_TO_SLEEP | ||
| - | RTC_DATA_ATTR int bootCount | + | ====== Code & Description====== |
| + | <code c++> | ||
| + | *//There are 2 ways to wake up a system, those are called Interrupts. | ||
| + | *//hardware Interrupts are based on external events where signals are sent to the GPIO. | ||
| + | *//Software Interrupts occur when we program the device, like through a wake up alarm or timer. | ||
| - | void print_wakeup_reason(){ | + | #define uS_TO_S_FACTOR 1000000 |
| + | #define TIME_TO_SLEEP | ||
| + | |||
| + | RTC_DATA_ATTR int bootCount = 0; | ||
| + | |||
| + | *//Data has to be stored in the Real time Clock (RTC) fast memory because the CPU memory is wiped on every boot. | ||
| + | *// The amount of data has to be minimal due to size limitations : 8bit fast memory and 8bit Slow memory. | ||
| + | |||
| + | *//Power outages and resetting the board will erase the RTC memory, therefore its use should be limited to non essential information. | ||
| + | *// | ||
| + | |||
| + | |||
| + | |||
| + | **************Wake Up Print ************************************************************** | ||
| + | |||
| + | void print_wakeup_reason(){ | ||
| esp_sleep_wakeup_cause_t wakeup_reason; | esp_sleep_wakeup_cause_t wakeup_reason; | ||
| - | wakeup_reason = esp_sleep_get_wakeup_cause(); | + | wakeup_reason = esp_sleep_get_wakeup_cause(); |
| - | switch(wakeup_reason) | + | switch(wakeup_reason) |
| { | { | ||
| case ESP_SLEEP_WAKEUP_EXT0 : Serial.println(" | case ESP_SLEEP_WAKEUP_EXT0 : Serial.println(" | ||
| case ESP_SLEEP_WAKEUP_TIMER : Serial.println(" | case ESP_SLEEP_WAKEUP_TIMER : Serial.println(" | ||
| - | default : Serial.printf(" | + | default : Serial.printf(" |
| } | } | ||
| } | } | ||
| - | void setup(){ | + | *//We made the system wake up due to the internal timer and a pushed button, |
| + | *// the reason for the push button is that in the case we can take a measurement at our will without having to wait for the timers. | ||
| + | *//An external clock could be added to the device, however Grafana already designates time and date of transferred data. | ||
| + | |||
| + | void setup(){ | ||
| Serial.begin(115200); | Serial.begin(115200); | ||
| - | delay(1000); | + | delay(1000); |
| + | |||
| + | pinMode(32, | ||
| + | |||
| + | pinMode(33, | ||
| + | |||
| + | | ||
| + | *//it avoids the use of external resistors | ||
| + | | ||
| + | | ||
| - | pinMode(32, | ||
| - | pinMode(33, | ||
| - | for(int i=0; | + | for(int i=0; |
| { | { | ||
| - | digitalWrite(32, | + | digitalWrite(32, |
| delay(1000); | delay(1000); | ||
| digitalWrite(32, | digitalWrite(32, | ||
| Line 45: | Line 74: | ||
| ++bootCount; | ++bootCount; | ||
| - | Serial.println(" | + | Serial.println(" |
| + | *//easy way to know if there are issues internal or battery | ||
| + | | ||
| | | ||
| print_wakeup_reason(); | print_wakeup_reason(); | ||
| Line 52: | Line 82: | ||
| | | ||
| - | esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, | + | esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, |
| + | *//During Sleep only Pins connected to the RTC are operational | ||
| + | *//A General Purpose Input/ | ||
| + | *//By default those pins have no predefined purpose. | ||
| + | *//The pin used has to be named after their GPIO | ||
| - | | + | |
| + | |||
| + | |||
| + | | ||
| - | Serial.println(" | + | Serial.println(" |
| " Seconds" | " Seconds" | ||
| - | Serial.println(" | + | Serial.println(" |
| delay(1000); | delay(1000); | ||
| - | Serial.flush(); | + | Serial.flush(); |
| + | | ||
| esp_deep_sleep_start(); | esp_deep_sleep_start(); | ||
| | | ||
| Line 69: | Line 107: | ||
| </ | </ | ||
| - | ====== | + | |
| + | *** There is no loop section in our coding because the micro controller will go into deep sleep before reaching that part// | ||
| + | of the code, which means everything has to be written in the void set up section of the sketch.// | ||
| + | |||
| ====== | ====== | ||
| {{ : | {{ : | ||
amc2022/grouph/here.1662738401.txt.gz · Last modified: 2023/01/05 14:38 (external edit)