Skip to content

Instantly share code, notes, and snippets.

@ItHasU
Created March 29, 2018 09:38
Show Gist options
  • Save ItHasU/6cfdc8160ca3bf9407ef351b1a6454d7 to your computer and use it in GitHub Desktop.
Save ItHasU/6cfdc8160ca3bf9407ef351b1a6454d7 to your computer and use it in GitHub Desktop.
#include <esp_wifi.h>
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for u seconds to seconds */
#define TIME_TO_SLEEP 10 /* Time ESP32 will go to sleep (in seconds) */
//const int PIN_LED = 22; // LOLIN32 lite
const int PIN_LED = 5; // LOLIN32
void setup()
{
pinMode(PIN_LED, OUTPUT);
digitalWrite(PIN_LED, LOW);
}
void loop()
{
delay(TIME_TO_SLEEP * 1000);
esp_wifi_deinit();
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
esp_deep_sleep_start();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment