Hello
I want to sense temp and send it to my server and want my device to sleep for some seconds(or minutes) and then, back to sense temp and get back to sleep ... repeat those process forever.
void setup(){
wifiManager.autoConnect("AutoConnectAP");
}
void loop()
{
 timer.run();
if (!client.connected()) {
  Serial.println("client connected");
 Â
    timer.setInterval(10000,repeat);
 Â
  client.connect("ESP8266Clienttnnttt", mqtt_user, mqtt_password);
  client.subscribe(mqtt_topic);
Â
 }
 if(client.connected()){
  client.loop();
 }
}
void repeat(){
Â
//Â Here , I sense temp and do http request well.
 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");
 Serial.println("Going to sleep now");
 Serial.flush();
 esp_deep_sleep_start();
 Serial.println("This will never be printed");
}
when device goes to deep sleep for TIME_TO_SLEEP seconds, device restart and connect to my ssid automatically, but after sleep and wake up for 2 times,
Serial monitor says
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 5
*WM: SET AP STA
*WM:
*WM: Configuring access point...
*WM: AutoConnectAP
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
which is not connected to my ssid anymore.
how can I use wifimanager ,setInterval and deepsleep ???