#include #include #include // https://github.com/tzapu/WiFiManager WiFiManager wm; WiFiUDP Udp; void doSomeWifi() { Udp.begin(31337); Udp.beginPacket("255.255.255.255", 31337); Udp.write("Hello from ESP!\n"); Udp.endPacket(); } void setup() { WiFi.mode(WIFI_STA); Serial.begin(115200); wm.setConnectTimeout(60); //Autoconnect to Wifi (or do soft AP) bool res; res = wm.autoConnect(); if(!res) { Serial.println("Failed to connect"); } else { Serial.println("connected..."); } //Start webPortal std::vector menu = {"wifi","info","param","sep","erase", "restart"}; wm.setMenu(menu); wm.startWebPortal(); doSomeWifi(); } const unsigned long AWAKE_SECONDS = 10; static uint32_t millis_last_reset = 0; void loop() { wm.process(); //Stay awake for a few seconds if (millis()-millis_last_reset > AWAKE_SECONDS * 1000) { Serial.println("Going to sleep"); //Sleep until RESET pin is triggered ESP.deepSleep(0); } }