ESPhome low power sonsor - problem when wifi not reachable

Hello, I reboot by wifi router every night and it messes up sensors. HA becomes unavailable and the ESPhome sensor does not go to deep sleep because it is connecting to wifi, or MQTT, or HA, or creates AP and drains the battery.

Is it possible to check connection to wifi or MQTT broker and if either of that is not accessible, then go to deep sleep and try at next run?

Thanks

Why not fix or replace your router?

1 Like

Thank you tom. I like the router, it just somehow gets stuck after few days, so I better reboot it regularly. I would like to come up with systematic approach that whole life of low power sensors is not dependent on one-time wifi inaccessibility. Instead of buying new router, I can use LoRa radio node v1.0 for $12 and lora-mqtt gateway, which will not suffer with this problem, takes 76uA and works well outside of wifi. But I still want to make ESPhome sensors better :slight_smile:

It shouldn’t be getting stuck. Find and fix the problem rather than the symptom. It’s probably an IP lease issue, and you running out of addresses.
Try setting static ips for all devices and ensure IP address pool is large enoigh

1 Like

Hello I use static IP. I think the problem is here - when not connected for 5 min, the sensor can only reboot, but not go to deep sleep. It could be great if I can create lambda that checks for reset cause and if it is not timer boot then goes to deep sleep. But I am afraid that esp8266 cannot distinguish between software reset and deep-sleep wakeup…

wifi:
  ssid: "IoT2"
  password: "...."
  manual_ip:
    static_ip: 10.0.0.48
    gateway: 10.0.0.138
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4
  reboot_timeout: 5min

there’s not much to like then!

So this only happens when the esp wakes up when the router is rebooting?