I have built a CO2 sensor using an ESP8266, SCD41 sensor, and TM1637 display. After adding it to ESPHome, it works as planned, except the ESP8266 periodically resets. The period is approximately every 15 minutes, but it varies, occasionally running for up to 30 minutes. I built another one with identical components, and it exhibits the same issue. Suggestions on where to look would be appreciated.
Post a ESPHome compile & run log here (formatted please).
esp-idf or arduino?
Have you considered a ESP32 instead as you may he running short of resources on the ESP8266?
ESP8266 has a weaker wifi stack than the ESP32. They’re a little better than the Libretiny chips, but not by much. Some things you can try doing on your network to help with stability are forcing the device to the closest AP using MAC filtering. Enabling IGMP snooping on your wifi SSID, enabling multicast to unicast, disabling packet steering, and disabling inactivity polling if any of these things are options on your router/AP. Of course these things don’t come without their advantages/disadvantages and as such I always recommend investigating each topic to understand what you are enabling/disabling.
reboot_timeout (Optional, Time): The amount of time to wait before rebooting when no client connects to the API. This is needed because sometimes the low level ESP functions report that the ESP is connected to the network, when in fact it is not - only a full reboot fixes it. Can be disabled by setting this to 0s. Defaults to 15min.
As @Spiro asked, are you sure you need/want api. I will bet that is the problem. But, as @Karosm said the logs will tell you. You need the serial log directly from the device to see the reboot due to no connection.
Dropping the api did not make a difference. Using ESPhome for over a year, I was unaware the ramifications of using it with MQTT or not using it at all. That really needs to be documented. I’ve left it in since I usually pick up the values from the api for HA screens - the MQ posts are for other systems.
Moving to a ESP32 did solve the problem. I left it on an ESP8266 because it didn’t seem to need a ESP32 and I try to use the smaller ones - mostly just to use them up.
This was meant to be a quick solution (yes, I’m acquainted with Mr. Murphy) - I’ll try to debug the ESP8266 issue later when i have time.