For the last 50 the test was your Low_Power method.
/*
- HelTec Automation⢠Low_Power test code, witch includ
- Function summary:
-
-
- Vext connected to 3.3V via a MOS-FET, the gate pin connected to GPIO21;
-
-
- OLED display and PE4259(RF switch) use Vext as power supply;
-
-
- WIFI Kit series V1 donât have Vext control function;
-
-
-
-
-
- by lxyzn from HelTec AutoMation, ChengDu, China
-
- www.heltec.cn
-
- this project also realess in GitHub:
-
https://github.com/HelTecAutomation/Heltec_ESP32
*/
#include âheltec.hâ
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds /
#define TIME_TO_SLEEP 10 / Time ESP32 will go to sleep (in seconds) */
#define BAND 433E6 //you can set band here directly,e.g. 868E6,915E6
RTC_DATA_ATTR int bootCount = 0;
/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason(){
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case 1 :
{
Serial.println(âWakeup caused by external signal using RTC_IOâ);
delay(2);
} break;
case 2 :
{
Serial.println(âWakeup caused by external signal using RTC_CNTLâ);
delay(2);
} break;
case 3 :
{
Serial.println(âWakeup caused by timerâ);
delay(2);
} break;
case 4 :
{
Serial.println(âWakeup caused by touchpadâ);
delay(2);
} break;
case 5 :
{
Serial.println(âWakeup caused by ULP programâ);
delay(2);
} break;
default :
{
Serial.println(âWakeup was not caused by deep sleepâ);
delay(2);
} break;
}
}
void setup(){
//WIFI Kit series V1 not support Vext control
Heltec.begin(true /DisplayEnable Enable/, true /LoRa Disable/, true /Serial Enable/, true /PABOOST Enable/, BAND /long BAND/);
//Increment boot number and print it every reboot
++bootCount;
Serial.println("Boot number: " + String(bootCount));
delay(2);
//Print the wakeup reason for ESP32
print_wakeup_reason();
/*
First we configure the wake up source
We set our ESP32 to wake up every 5 seconds
*/
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
Serial.println(âSetup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +
" Secondsâ);
delay(10);
/*
Next we decide what all peripherals to shut down/keep on
By default, ESP32 will automatically power down the peripherals
not needed by the wakeup source, but if you want to be a poweruser
this is for you. Read in detail at the API docs
http://esp-idf.readthedocs.io/en/latest/api-reference/system/deep_sleep.html
Left the line commented as an example of how to configure peripherals.
The line below turns off all RTC peripherals in deep sleep.
*/
//esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
//Serial.println(âConfigured all RTC Peripherals to be powered down in sleepâ);
/*
Now that we have setup a wake cause and if needed setup the
peripherals state in deep sleep, we can now start going to
deep sleep.
In the case that no wake up sources were provided but deep
sleep was started, it will sleep forever unless hardware
reset occurs.
*/
LoRa.end();
LoRa.sleep();
delay(100);
pinMode(5,INPUT);
pinMode(14,INPUT);
pinMode(15,INPUT);
pinMode(16,INPUT);
pinMode(17,INPUT);
pinMode(18,INPUT);
pinMode(19,INPUT);
pinMode(26,INPUT);
pinMode(27,INPUT);
delay(100);
Serial.println(âGoing to sleep nowâ);
delay(2);
esp_deep_sleep_start();
Serial.println(âThis will never be printedâ);
}
void loop(){
//This is not going to be called
}