ESPHome devices don’t connect on Boot

Hey Everyone,

I have a bunch of ESP8266 (D1 mini) devices on an off grid installation.

I’m getting a weird issues when the battery runs out, when the sun comes out again, and the battery starts providing power, none of my ESPHome devices come up automatically, maunally rebooting the ESPHome device works, (removing, reattaching power) It pops right up in the HA front end.

I think this is because the ESPHome devices boot almost immediately, but the router takes a minute to boot up, so the ESPHome devices are not ever “trying again” to reconnect to WiFi.

I have removed the ap config, specified a reboot_timout; 300s in the WiFi config, and done a clean install. But nothing seems to help.

Any pointers on how to force a D1mini to reboot after a period when it can’t connect to WiFI would be great, thanks!

Config:

esphome:
  name: bedroom
  friendly_name: Bedroom

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "REMOVED"

ota:
  - platform: esphome
    password: "REMOVED"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 300s

captive_portal:

light:
  - platform: monochromatic
    name: "Bedroom Lights"
    output: output_component1

output:
  - platform: esp8266_pwm
    id: output_component1
    pin: GPIO15

switch:
  - platform: gpio
    pin: GPIO0
    name: "Relay 1"
  - platform: gpio
    pin: GPIO2
    name: "Relay 2"

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO16
      mode:
        input: true
      inverted: true
    name: "Bedroom Button"
    id: bedroom_button
    on_multi_click:
      - timing:
          - ON for at most 400ms
        then:
          - homeassistant.event:
              event: esphome.button_short_press
              data:
                id: bedroom
      - timing:
          - ON for at least 500ms
        then:
          - homeassistant.event:
              event: esphome.button_hold
              data:
                id: bedroom
    on_release:
      then:
        - homeassistant.event:
            event: esphome.button_release
            data:
              id: bedroom

i2c:
  sda: GPIO4
  scl: GPIO5
  scan: true
  id: bus_a

sensor:
  - platform: bme280_i2c
    temperature:
      name: "Bedroom Temperature"
      id: bme280_temperature
    pressure:
      name: "Bedroom Pressure"
      id: bme280_pressure
    humidity:
      name: "BedRoom Relative Humidity"
      id: bme280_humidity
    address: 0x76
    update_interval: 15s

I wonder how you charge your batteries? Lithium cells when discharged it can be risky to charge at too high a current until voltage has risen a bit. Charging circuits may charge eg TP4056 at 10th the normal level. Your esp may be trying to run at that low current but it will likely collapse the voltage. Your esps may not be booting up at all, just sitting there glitching. Even briefly disconnecting the device may allow them to run again. Does your circuit have a power path?
You didnt specifically say but Im assuming you are using solar power as you mentioned the sun.
It might be better to show your entire hardware setup for the esps.

If that’s the case, you could start esp with

wifi:
  enable_on_boot: false

and then enable wifi few minutes delayed.

on_boot:
  then:
    - delay: 2min
    - wifi.enable

Ahhh this is a really good point, its a 3kwh lithium battery with a BMS, I’m running the ESPs a step removed from VBAT (12.8V) though a boost buck to 12V for LED lighting, and a buck from 12V to 5V for the D1 Mini.

The solar power is a Victron MPPT, and the battery only accepts a small current until it “wakes up” from overdischagre protection.

ESPs sitting there glitching lines up with the observed behaviour. Will take a look at the power chain

This could well be the solution, Will try to implement!

Verify the behavior while you have full battery, disconnect esps and router and reconnect again.

I would say connect an FTD to USB adapter)(you gotta have one of these if you are gonna flash esps connecting Tx, RX and GND to the esp. I use the esp home flasher 1.4.0 to connect and show the output. It’ll show if esp is loading at all or if wifi is the only thing not connecting.