ESPHome crashes and gets stuck on reboot loop only after adding a few certain lines of code

I have a NodeMCU loaded with ESPHome that I use to manage and automate the filling and pumping of water between the 2 water tanks in my house. I also use it to control several lights that I have in the yard.

The YAML is pretty long, reaching 744 lines. I program all the automations locally on ESPHome so that if home assistant is down, the whole automation system is uninterrupted. Getting the automation right is a process of trial, error, and constant revisioning so I keep adding new features to the YAML every few days.

The problem began when I added some new features to the YAML. After finishing compiling, the upload process failed (update was via OTA). I then plugged the NodeMCU directly to the HA server and managed to update it successfully. The subsequent updates would only be succesful if it’s plugged directly to the server. It wouldn’t work via OTA anymore.

Then, the next few days after that as I’m adding more features, after compiling and and successfully uploading, the NodeMCU is stuck at a reboot loop, and the logs via the serial monitor showed something that after doing a quick search tells me that the ESPHome had crashed because after a few moments after booting the logger started showing “--------------- CUT HERE FOR EXCEPTION DECODER ---------------”.

Here’s the complete error log (cropped to just show the exception decoder):

[15:52:50]
[15:52:50]--------------- CUT HERE FOR EXCEPTION DECODER ---------------
[15:52:50]
[15:52:50]Exception (29):
WARNING Exception type: unknown
[15:52:50]epc1=0x40229bb6 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000008 depc=0x00000000
WARNING Decoded 0x40229bb6: esp8266::MDNSImplementation::MDNSResponder::stcMDNS_RRAnswer::stcMDNS_RRAnswer(esp8266::MDNSImplementation::MDNSResponder::_enuAnswerType, esp8266::MDNSImplementation::MDNSResponder::stcMDNS_RRHeader const&, unsigned int)
WARNING Decoded 0x40229bb6: esp8266::MDNSImplementation::MDNSResponder::stcMDNS_RRAnswer::stcMDNS_RRAnswer(esp8266::MDNSImplementation::MDNSResponder::_enuAnswerType, esp8266::MDNSImplementation::MDNSResponder::stcMDNS_RRHeader const&, unsigned int)
[15:52:50]
[15:52:50]>>>stack>>>
WARNING Found stack trace! Trying to decode it
[15:52:50]
[15:52:50]ctx: sys
[15:52:50]sp: 3fffe9f0 end: 3fffffb0 offset: 0190
[15:52:50]3fffeb80:  3fffebb0 3fffec50 3fffecb2 00000004  
[15:52:50]3fffeb90:  3fff20c0 3fffeddc 00000000 4022e9ac  
WARNING Decoded 0x4022e9ac: operator new(unsigned int)
[15:52:50]3fffeba0:  3fffb6c4 3fffeddc 3fff20c0 4022ae94  
WARNING Decoded 0x4022ae94: esp8266::MDNSImplementation::MDNSResponder::_readRRAnswer(esp8266::MDNSImplementation::MDNSResponder::stcMDNS_RRAnswer*&)
[15:52:50]3fffebb0:  3a30612b 323a3831 37353a38 3a66373a  
[15:52:50]3fffebc0:  66403936 3a303865 3132613a 38323a38  
[15:52:50]3fffebd0:  663a6666 3a373565 39366637 70615f0e  
[15:52:50]3fffebe0:  2d656c70 64626f6d 04327665 7063745f  
[15:52:50]3fffebf0:  636f6c05 00006c61 00000000 00000000  
[15:52:50]3fffec00:  00000000 00000000 00000000 00000000  
[15:52:50]3fffec10:  00000000 00000000 00000000 00000000  
[15:52:50]3fffec20:  00000000 00000000 00000000 00000000  
[15:52:50]3fffec30:  00000000 00000000 00000000 00000000  
[15:52:50]3fffec40:  00000000 00000000 00000000 00000000  
[15:52:50]3fffec50:  00000000 00000000 00000000 00000000  
[15:52:50]3fffec60:  00000000 00000000 00000000 00000000  
[15:52:50]3fffec70:  00000000 00000000 00000000 00000000  
[15:52:50]3fffec80:  00000000 00000000 00000000 00000000  
[15:52:50]3fffec90:  00000000 00000000 00000000 00000000  
[15:52:50]3fffeca0:  00000000 00000000 00000000 00000000  
[15:52:50]3fffecb0:  00210047 00008001 00000078 40220012  
WARNING Decoded 0x40220012: WiFiClient::connect(IPAddress, unsigned short)
[15:52:50]3fffecc0:  3fff20c0 3fffbc24 00000001 402288a6  
WARNING Decoded 0x402288a6: esp8266::MDNSImplementation::MDNSResponder::_parseResponse(esp8266::MDNSImplementation::MDNSResponder::stcMDNS_MsgHeader const&)
[15:52:50]3fffecd0:  00000000 00000000 00000000 00000000  
[15:52:50]3fffece0:  00000000 00000000 00000000 00000000  
[15:52:50]3fffecf0:  00000000 00000000 00000000 00000000  
[15:52:50]3fffed00:  00000000 00000000 00000000 00000000  
[15:52:50]3fffed10:  00000000 00000000 00000000 00000000  
[15:52:50]3fffed20:  00000000 00000000 00000000 00000000  
[15:52:51]3fffed30:  00000000 00000000 00000000 00000000  
[15:52:51]3fffed40:  00000000 00000000 00000000 00000000  
[15:52:51]3fffed50:  00000000 00000000 00000000 00000000  
[15:52:51]3fffed60:  00000000 00000000 00000000 00000000  
[15:52:51]3fffed70:  00000000 00000000 00000000 00000000  
[15:52:51]3fffed80:  00000000 00000000 00000000 00000000  
[15:52:51]3fffed90:  00000000 00000000 00000000 00000000  
[15:52:51]3fffeda0:  00000000 00000000 00000000 00000000  
[15:52:51]3fffedb0:  00000000 00000000 00000000 00000000  
[15:52:51]3fffedc0:  00000000 00000000 00000000 00000000  
[15:52:51]3fffedd0:  00000000 00000000 3f000001 00000000  
[15:52:51]3fffede0:  0000000a 3fffee80 3fffee30 4022aff4  
WARNING Decoded 0x4022aff4: esp8266::MDNSImplementation::MDNSResponder::_readMDNSMsgHeader(esp8266::MDNSImplementation::MDNSResponder::stcMDNS_MsgHeader&)
[15:52:51]3fffedf0:  40258400 3fffee80 3fffee80 000014e9  
WARNING Decoded 0x40258400: ieee80211_phy_type_get
[15:52:51]3fffee00:  3fff28c4 3fffb544 3fff20c0 40228984  
WARNING Decoded 0x40228984: esp8266::MDNSImplementation::MDNSResponder::_parseMessage()
[15:52:51]3fffee10:  00000000 00000000 00000000 00000000  
[15:52:51]3fffee20:  00000000 00000000 00000000 40244b60  
WARNING Decoded 0x40244b60: dns_call_found at /local/users/gauchard/arduino/arduino_esp8266/esp8266-lwip/tools/sdk/lwip2/builder/lwip2-src/src/core/dns.c:996
[15:52:51]3fffee30:  00210000 00070000 00030000 40100b08  
WARNING Decoded 0x40100b08: ets_post
[15:52:51]3fffee40:  3fff1120 3fffb544 3fff20c0 40228d01  
WARNING Decoded 0x40228d01: esp8266::MDNSImplementation::MDNSResponder::_process(bool)
[15:52:51]3fffee50:  40000069 00290b8e 3fff2cbc 40228d1c  
WARNING Decoded 0x40228d1c: esp8266::MDNSImplementation::MDNSResponder::_callProcess()
[15:52:51]3fffee60:  00000011 00000001 00000010 40232f5f  
WARNING Decoded 0x40232f5f: std::_Function_handler<void (), std::_Bind<std::_Mem_fn<bool (esp8266::MDNSImplementation::MDNSResponder::*)()> (esp8266::MDNSImplementation::MDNSResponder*)> >::_M_invoke(std::_Any_data const&)
[15:52:51]3fffee70:  000000b0 00000000 00000020 40220590  
WARNING Decoded 0x40220590: UdpContext::_s_recv(void*, udp_pcb*, pbuf*, ip4_addr const*, unsigned short)
[15:52:51]3fffee80:  3fffb576 00000000 3fffa13c 3fffb544  
[15:52:51]3fffee90:  3fffb576 00000000 3fffa13c 40247980  
WARNING Decoded 0x40247980: udp_input at /local/users/gauchard/arduino/arduino_esp8266/esp8266-lwip/tools/sdk/lwip2/builder/lwip2-src/src/core/udp.c:404
[15:52:52]3fffeea0:  000014e9 3fff2804 3fff2804 3fff300c  
[15:52:52]3fffeeb0:  00000000 00000000 00000020 3fff28b4  
[15:52:52]3fffeec0:  3fff2804 3fffb562 3fffb544 4024c8bc  
WARNING Decoded 0x4024c8bc: ip4_input at /local/users/gauchard/arduino/arduino_esp8266/esp8266-lwip/tools/sdk/lwip2/builder/lwip2-src/src/core/ipv4/ip4.c:1461
[15:52:52]3fffeed0:  00000014 3fff2804 00000167 3fff300c  
[15:52:52]3fffeee0:  00000000 3fff2f6c 00000020 40101617  
WARNING Decoded 0x40101617: free
[15:52:52]3fffeef0:  4025eb30 3fff29cc 3fff2f6c 3fff300c  
WARNING Decoded 0x4025eb30: ppRecycleRxPkt
[15:52:52]3fffef00:  00000008 3fff2804 3fffb544 40243779  
WARNING Decoded 0x40243779: ethernet_input_LWIP2 at /local/users/gauchard/arduino/arduino_esp8266/esp8266-lwip/tools/sdk/lwip2/builder/lwip2-src/src/netif/ethernet.c:188
[15:52:52]3fffef10:  3fffdc80 3fff2f6c 3fff29cc 40243598  
WARNING Decoded 0x40243598: esp2glue_ethernet_input at /local/users/gauchard/arduino/arduino_esp8266/esp8266-lwip/tools/sdk/lwip2/builder/glue-lwip/lwip-git.c:469
[15:52:52]3fffef20:  40268fee 3fff2f6c 3fff29cc 40268fff  
WARNING Decoded 0x40268fee: ethernet_input at /local/users/gauchard/arduino/arduino_esp8266/esp8266-lwip/tools/sdk/lwip2/builder/glue-esp/lwip-esp.c:365
WARNING Decoded 0x40268fff: ethernet_input at /local/users/gauchard/arduino/arduino_esp8266/esp8266-lwip/tools/sdk/lwip2/builder/glue-esp/lwip-esp.c:373
[15:52:52]3fffef30:  3fffb554 3fffb544 00000000 3ffe85c4  
[15:52:52]3fffef40:  4025e75b 00000000 3fff29cc 402647f3  
WARNING Decoded 0x4025e75b: ppPeocessRxPktHdr
WARNING Decoded 0x402647f3: ets_snprintf
[15:52:52]3fffef50:  40000f49 3fffdab0 3fffdab0 40000f49  
[15:52:52]3fffef60:  40000e19 00000005 00082700 00000000  
[15:52:52]3fffef70:  3fffefc0 aa55a

After rolling back to the previous version before the last revision that made it crash, the ESPHome worked like normal. This is problematic because I’m not able to add new features anymore.

I am using this NodeMCU, the one with 4MB of memory and uses the CP2102 (not CH340) USB chip.

I tried uploading the same code to a Wemos like this one, but the serial monitor showed the same error.

At this point, I’m thinking that I’m reaching the end of what my wemos or NodeMCU is capable of in terms amount of lines of code. I could be wrong with my theory though, so feel free to correct me. It could be just a memory issue (4MB is not enough), or this is as far as an ESP8266 could go in terms of processing power. So I’m thinking of 2 options here:

  1. Get an ESP8266 with bigger memory (16MB or 32MB)
  2. Upgrade to ESP32

Which option would you guys think should avoid the crashes? If it’s upgrading to ESP32, would it be necessary to get the one with bigger memory than just 4MB?

And just 1 more question: Do you have any recommended ESP32 boards that would work stably with ESPHome? I’m thinking of getting this one:

Thanks guys!

I’d try this:

https://www.aliexpress.com/item/32817842070.html

I got an ESP32 and uploaded the program there, no crashes so far. Thanks!
Oh, but I got the “NodeMCU-like” model (the one which I posted the picture of) instead of the “Wemos-like” model that you recommended since I needed to be able to use it on a breadboard.

1 Like