ESPHome crashes homeassistant, ESP32's can't connect to wifi at times

I’m pretty newto home assistant for around a month and have been playing with some esp8266’s and esp32 for around a week. I have spent a couple of days experimenting with ESP32’s ( IZOKEE Development Board for ESP32 2.4 GHz Dual Core WLAN WiFi + Bluetooth 2-in-1 Microcontroller with CP2102 Chip for Arduino (3pcs)), adafruit neopizels, dht22, and Xiaomi LYWSDCGQ BLE Sensor.

First issue: More than half the time I try to compile, esphome says process terminated, and home assistant reboots. I am running home assistant in a vm in unraid, I started with this image: hassos_ova-4.12.qcow2, it has been updated to 0.114.4 and I have cpu 6/7 and thread 14/15 from a threadripper 1900X pinned to the vm. Initial memory is 1024MB, max is 2048.

When I do get past compiling, I am able to get something to work, provided that thing is only one something, and I spent a whole day and a half trying to get dht-22 to work, then figured out that I needed the beta version of esphome to get past a bug. I’m pretty much just playing around, but trying to figure out what I will ultimately use, which is why I purchased 2 Xiaomi sensors, and 2 dht-22’s. I have a “working” nodemcu set up for both of those sensor types, but it is only getting the dht-22 values, here is the last part of the yaml from that:

esp32_ble_tracker:
sensor:
  - platform: xiaomi_lywsdcgq
    mac_address: redacted
    temperature:
      name: "Upstairs Temperature"
    humidity:
      name: "Upstairs Humidity"
    battery_level:
      name: "Upstairs Battery Level"
  - platform: dht
    pin: GPIO27
    model: DHT22
    temperature:
      name: "OfficeN Temperature"
    humidity:
      name: "OfficeN Humidity"
    update_interval: 60s
 
time:
  - platform: homeassistant
    on_time:
      - seconds: 0
        minutes: 0
        hours: 2
        days_of_week: MON-SUN
        then:
           - switch.toggle: restart_switch

switch:
  - platform: restart
    name: "Auto Restart"
    id: restart_switch

I have another unit that I am trying to set up an led on, and another xiami sensor, and it doesn’t seem to get past trying to connect to wifi.

[13:57:48]ets Jun 8 2016 00:22:57
[13:57:48]
[13:57:48]rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[13:57:48]configsip: 0, SPIWP:0xee
[13:57:48]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[13:57:48]mode:DIO, clock div:2
[13:57:48]load:0x3fff0018,len:4
[13:57:48]load:0x3fff001c,len:1044
[13:57:48]load:0x40078000,len:8896
[13:57:48]load:0x40080400,len:5828
[13:57:48]entry 0x400806ac
[13:57:49][I][logger:166]: Log initialized
[13:57:49][C][ota:366]: There have been 5 suspected unsuccessful boot attempts.
[13:57:49][I][app:029]: Running through setup()…
[13:57:49][C][light:097]: Setting up light ‘NeoPixel Light’…
[13:57:49][D][light:264]: ‘NeoPixel Light’ Setting:
[13:57:49][D][light:277]: Brightness: 100%
[13:57:49][D][light:286]: Red=100%, Green=100%, Blue=100%
[13:57:49][D][light:289]: White Value: 0%
[13:57:50][D][esp32_ble_tracker:148]: Starting scan…
[13:57:50][C][wifi:033]: Setting up WiFi…
[13:57:50][D][wifi:324]: Starting scan…

yaml:

esp32_ble_tracker:
sensor:
  - platform: xiaomi_lywsdcgq
    mac_address: redacted2
    temperature:
      name: "DeansOffice Temperature"
    humidity:
      name: "DeansOffice Humidity"
    battery_level:
      name: "DeansOffice Battery Level"

light:
  - platform: neopixelbus
    pin: GPIO14
    num_leds: 1
    type: RGB
    name: "NeoPixel Light"
    
time:
  - platform: homeassistant
    on_time:
      - seconds: 0
        minutes: 0
        hours: 2
        days_of_week: MON-SUN
        then:
           - switch.toggle: restart_switch

switch:
  - platform: restart
    name: "Auto Restart"
    id: restart_switch

I must be doing something wrong, or a number of things, probably something fundamental that I don’t understand. There must be something wrong with my VM as well, but it isn’t obvious to me what. I moved the storage off of my unraid array and on to cache, and that hugely improved home assistant boot times. I would like to move to a NUC, but have no funds for it currently. Help with any of this would be greatly appreciated.

Compiling Esp home takes a lot of memory. Double the size of your ram and see if you still get reboots.

Awesome, thanks! I found an unraid thread suggesting min max memory ballooning wasn’t great, so I set both to 4GB, uploaded to the unit with the 2 different temperature sensors, and now I have both! Is it possible that the compiler was running out of memory and somehow coming up with something kind of flashable despite this? Seems unlikely, but I’m just guessing. Will try bluetooth temp sensor and LED soon.

edit: bluetooth temp and LED are not working:

esphome:
  name: rgb_notify
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: "redacted"
  password: "redacted"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Rgb Notify Fallback Hotspot"
    password: "redacted"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "redacted"

ota:
  password: "redacted"

# Enable Bluetooth scanning for this ESP32
esp32_ble_tracker:
sensor:
  - platform: xiaomi_lywsdcgq
    mac_address: redacted
    temperature:
      name: "DeansOffice Temperature"
    humidity:
      name: "DeansOffice Humidity"
    battery_level:
      name: "DeansOffice Battery Level"

light:
  - platform: neopixelbus
    pin: GPIO14
    num_leds: 1
    type: RGB
    name: "NeoPixel Light"
    
time:
  - platform: homeassistant
    on_time:
      - seconds: 0
        minutes: 0
        hours: 2
        days_of_week: MON-SUN
        then:
           - switch.toggle: restart_switch

switch:
  - platform: restart
    name: "Auto Restart"
    id: restart_switch

Logs:

[15:26:35][C][ota:366]: There have been 4 suspected unsuccessful boot attempts.
[15:26:35][I][app:029]: Running through setup()...
[15:26:35][C][light:097]: Setting up light 'NeoPixel Light'...
[15:26:35][D][light:264]: 'NeoPixel Light' Setting:
[15:26:35][D][light:277]:   Brightness: 100%
[15:26:35][D][light:286]:   Red=100%, Green=100%, Blue=100%
[15:26:35][D][light:289]:   White Value: 0%
[15:26:36][D][esp32_ble_tracker:148]: Starting scan...
[15:26:36][C][wifi:033]: Setting up WiFi...
[15:26:36][D][wifi:324]

I commented out the light part and now it works…

I would like to use the light on this unit, did I find a bug, am I doing something wrong? This was using the beta, should I use the non-beta? Can I have the beta and non beta installed at the same time safely?

Hi,

I also had a problem with my ESP32 which couldn’t connect to WiFI. It stops at:

INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB2 with baud rate 115200
[19:39:02][I][logger:166]: Log initialized
[19:39:02][C][ota:366]: There have been 6 suspected unsuccessful boot attempts.
[19:39:02][I][app:029]: Running through setup()...
[19:39:02][C][light:097]: Setting up light 'kellertreppe'...
[19:39:02][D][light:265]: 'kellertreppe' Setting:
[19:39:02][D][light:278]:   Brightness: 100%
[19:39:02][D][light:287]:   Red=100%, Green=100%, Blue=100%
[19:39:02][C][wifi:033]: Setting up WiFi...
[19:39:02][D][wifi:324]: Starting scan...

After reading your post I removed the light section, compiled and uploaded again. Then it connects to WiFi. So I can confirm your behaviour and think it’s a bug.

Regards,
Michel

Same here,

All seems to work but as soon as i Add a neopixelbus “light”
the esp32 crashes during boot en logger stops

hope someone can help us

My HA installed on a rpi3 is experiencing compiling issue where home assistant disconnects ( I am assuming it rebooted) and never recovers from a reboot.

Is it possible to stop some of the add-ons to perform OTA compiling of esphome?

Update: I tried the little experiment of shutting down some add-ons to see if HA will crash due to high memory usage when compiling. These are the add-on I have currently and the ones I disabled before compiling and it seems to work.
disable_addon

excellent worked for me also on Raspberry Pi 3B as well. Thanks

I’m having the same problem, and noticed your UI card where you can quickly start/shutdown (?) add-ons. Would you mind sharing the code of that?

Hi. Sure. You will need to create a switch template for every addon you wish to have. Here is one of them Samba Backup. You can find out the id from the image below. Make sue to reload the template entities to take effect.

switch


  - platform: template
    switches:
      sambabackup:
        value_template: "{{ is_state('sensor.sambabackup', 'started') }}"
        turn_on:
          service: hassio.addon_start
          data:
            addon: 15d21743_samba_backup
        turn_off:
          service: hassio.addon_stop
          data:
            addon: 15d21743_samba_backup

2 Likes