Homey Community Forum

Homeyduino - Deepsleep

Hello!

I can´t get homeyduino to work with deepsleep on ESP32. I want to send temperature every 60s.
In order to get values to homey I need to have power for 10s until i go to deepsleep. Another problem is when i reboot homey I then need to also reboot the homeyduino app afterward until values are reported to homey?

Part of code that work, but I want shorter up time since I want to minimize power.

void loop() {
  wifi();
  Homey.loop();
  unsigned long currentMillis = millis();
  if(millis()>10000){
    updateSensor(); 
    ESP.deepSleep(60 * 1000000);
  }
}

I don’t think the original developers of Homeyduino every considered supporting deep sleep.

From what I understand from the code, Homeyduino works by the ESP device sending HTTP requests to a server running on Homey, passing data, so not sure why it’s taking 10 seconds to get value updates. Either the Homeyduino app (on Homey) or the library (on the ESP) might be getting confused by the sleep (if I were to guess, I think it might be the library).

Hi Andreas,

If I remember well deepsleep on an ESP32 doesn’t work with a common loop. I think everything should be in the setup function. You could google “deepsleep Andreas Spies” to see a video about this matter.

Gr.,
Lars

Starting a deep sleep from loop works just fine on an ESP32.

The video from Andreas is showing a deep sleep example from Espressif, which starts the deep sleep from setup, so it makes sense that in that particular example, loop is never called. But there are no inherent issues with starting a deep sleep from it (just that you have to be aware that it will not continue the loop once it wakes up, but it’ll call setup again).

O, good to know. Thanks.

Could it be that with deep sleep the ESP32 loses it’s memory settings?

Thanks for the answer.
The ESP32 reads the temperature just fine every 60s but as stated before Homey won´t recieve the data. I have tried with and without loop but only succes with a loop of >10s until deepsleep is activated.

It looks like you might be able to define DEBUG_ENABLE before including Homey.h to enable some debug logging from the Homeyduino library. Perhaps that will give a clue why you need to wait 10 seconds.