ESP8266/ D1 mini shuts down after minute when flashed with ESPhome

When I flash my D1 mini clone with ESPHome, it seem to work, my board becomes visible in HA and I can connect to its webserver, but the board shuts down after a minute or so. When I reset it comes up again and after a minute shuts down again.
While when I use the Arduino IDE, the same board, it works and stays on.

Any idea what the issue could be?

Please post the YAML config you’re using, and
have you tried running it with a very minimal config just to see if something in that config is troubling it?

And the log.

This is the YAML config - I also tried with a minimal config - same problem

substitutions: 
  name: ac-2nd-bedroom
  friendly_name: AC in 2nd bedroom
  id: ac_2nd_bedroom

esphome:
  name: ${name}

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0

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

ota:
  password: "pw"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Ac-2Nd-Bedroom Fallback Hotspot"
    password: "l06ZWfYUZIjI"

captive_portal:


# Enable Web server.
web_server:
  port: 80

  # Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

# Text sensors with general information.
text_sensor:
  # Expose ESPHome version as sensor.
  - platform: version
    name: ${name} ESPHome Version
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: ${name} IP
    ssid:
      name: ${name} SSID
    bssid:
      name: ${name} BSSID

# Sensors with general information.
sensor:
  # Uptime sensor.
  - platform: uptime
    name: ${name} Uptime

  # WiFi Signal sensor.
  - platform: wifi_signal
    name: ${name} WiFi Signal
    update_interval: 60s

external_components:
  - source: github://geoffdavis/esphome-mitsubishiheatpump

climate:
  - platform: mitsubishi_heatpump
    name: "${friendly_name}"
    id: ${id}

    # ESP32 only - change UART0 to UART1 or UART2 and remove the
    # logging:baud_rate above to allow the built-in UART0 to function for
    # logging.
    hardware_uart: UART0

For the logs - the logs from the board:

INFO Reading configuration /config/esphome/ac-2nd-bedroom.yaml...
INFO Detected timezone 'America/New_York'
INFO Starting log output from ac-2nd-bedroom.local using esphome API
INFO Successfully connected to ac-2nd-bedroom.local
[21:21:35][I][app:102]: ESPHome version 2022.6.2 compiled on Jul 24 2022, 11:13:01
[21:21:35][C][wifi:491]: WiFi:
[21:21:35][C][wifi:353]:   Local MAC: 58:BF:25:DB:75:1B
[21:21:35][C][wifi:354]:   SSID: 'xxxx'[redacted]
[21:21:35][C][wifi:355]:   IP Address: 192.168.0.32
[21:21:35][C][wifi:356]:   BSSID: xxxx[redacted]
[21:21:35][C][wifi:358]:   Hostname: 'ac-2nd-bedroom'
[21:21:35][C][wifi:360]:   Signal strength: -63 dB ▂▄▆█
[21:21:35][C][wifi:364]:   Channel: 3
[21:21:35][C][wifi:365]:   Subnet: 255.255.255.0
[21:21:35][C][wifi:366]:   Gateway: 192.168.0.1
[21:21:35][C][wifi:367]:   DNS1: 75.75.75.75
[21:21:35][C][wifi:368]:   DNS2: 75.75.76.76
[21:21:35][C][logger:275]: Logger:
[21:21:35][C][logger:276]:   Level: DEBUG
[21:21:35][C][logger:277]:   Log Baud Rate: 0
[21:21:35][C][logger:278]:   Hardware UART: UART0
[21:21:35][C][uptime.sensor:031]: Uptime Sensor 'ac-2nd-bedroom Uptime'
[21:21:35][C][uptime.sensor:031]:   State Class: 'total_increasing'
[21:21:35][C][uptime.sensor:031]:   Unit of Measurement: 's'
[21:21:35][C][uptime.sensor:031]:   Accuracy Decimals: 0
[21:21:35][C][uptime.sensor:031]:   Icon: 'mdi:timer-outline'
[21:21:35][C][homeassistant.time:010]: Home Assistant Time:
[21:21:35][C][homeassistant.time:011]:   Timezone: 'EST5EDT,M3.2.0,M11.1.0'
[21:21:35][C][version.text_sensor:021]: Version Text Sensor 'ac-2nd-bedroom ESPHome Version'
[21:21:35][C][version.text_sensor:021]:   Icon: 'mdi:new-box'
[21:21:35][I][MitsubishiHeatPump:062]: ESPHome MitsubishiHeatPump version 2.4.0
[21:21:35][I][MitsubishiHeatPump:504]:   Supports HEAT: YES
[21:21:35][I][MitsubishiHeatPump:505]:   Supports COOL: YES
[21:21:35][I][MitsubishiHeatPump:506]:   Supports AWAY mode: NO
[21:21:35][I][MitsubishiHeatPump:507]:   Saved heat: -1.0
[21:21:35][I][MitsubishiHeatPump:508]:   Saved cool: -1.0
[21:21:35][I][MitsubishiHeatPump:509]:   Saved auto: -1.0
[21:21:35][C][captive_portal:088]: Captive Portal:
[21:21:35][C][web_server:125]: Web Server:
[21:21:35][C][web_server:126]:   Address: ac-2nd-bedroom.local:80
[21:21:35][C][mdns:084]: mDNS:
[21:21:35][C][mdns:085]:   Hostname: ac-2nd-bedroom
[21:21:35][C][ota:085]: Over-The-Air Updates:
[21:21:35][C][ota:086]:   Address: ac-2nd-bedroom.local:8266
[21:21:35][C][ota:089]:   Using Password.
[21:21:35][C][api:138]: API Server:
[21:21:35][C][api:139]:   Address: ac-2nd-bedroom.local:6053
[21:21:35][C][api:141]:   Using noise encryption: YES
[21:21:35][C][wifi_info:009]: WifiInfo IPAddress 'ac-2nd-bedroom IP'
[21:21:35][C][wifi_info:011]: WifiInfo SSID 'ac-2nd-bedroom SSID'
[21:21:35][C][wifi_info:012]: WifiInfo BSSID 'ac-2nd-bedroom BSSID'
[21:21:35][C][wifi_signal.sensor:009]: WiFi Signal 'ac-2nd-bedroom WiFi Signal'
[21:21:35][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[21:21:35][C][wifi_signal.sensor:009]:   State Class: 'measurement'
[21:21:35][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dBm'
[21:21:35][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0

don’t see anything specific in ESPHome logs

Is that log right up until the time it crashes? I suspect not.

Can you try keeping the logging open until it crashes please.

… and up the log level:

logger:
  level: VERBOSE     # default is DEBUG

Define “shut down”.

Do you really need the AP fallback? The next time it crashes look at 192.168.4.1 to see if it is in fallback mode.

Personally, I never use the fallback mode. If it isn’t communicating, I want to know why. I would delete these lines (but that’s just me. Maybe someone else can convince me to put them back into my code).

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Ac-2Nd-Bedroom Fallback Hotspot"
    password: "l06ZWfYUZIjI"

captive_portal:

Do you have anything connected (Wired) to the D1
something could be pulling the 5Vdc down causing a reboot

1 Like

Handy if you move, or change SSID’s/passwords in a hurry (i.e. before you have a chance to reprogram/reflash all your devices).
But that’s a fairly extreme situation, so no, I can’t think of a compelling reason for the fallback AP.
In a retail product it would make sense (so the owner could retake control and access to the device) but in your home, not so much.
Plus, if your AP does go offline for a while, you don’t want your neighbors suddenly finding themselves seeing SSIDs like “bedroom heat lamp fallback” and so forth. :wink:

Device appears offline in ESPHome GUI, can’t access the logs and I can’t access the webserver on the ESP home any more

when I try to read log hostname cannot be resolved

INFO Starting log output from ac-2nd-bedroom.local using esphome API
WARNING Can't connect to ESPHome API for ac-2nd-bedroom.local: Error resolving IP address: [Errno -5] No address associated with hostname

When I keep the logs running local it seems to keep rebooting - getting online again

I tried again with verbose logging:

INFO ac-2nd-bedroom.local: Ping timed out!
INFO Disconnected from ESPHome API for ac-2nd-bedroom.local
WARNING Disconnected from API
INFO Successfully connected to ac-2nd-bedroom.local
[22:13:50][C][mdns:084]: mDNS:
[22:13:50][C][mdns:085]:   Hostname: ac-2nd-bedroom
[22:13:50][V][mdns:086]:   Services:
[22:13:50][V][mdns:088]:   - _esphomelib, _tcp, 6053
[22:13:50][V][mdns:090]:     TXT: version = 2022.6.2
[22:13:50][V][mdns:090]:     TXT: mac = 58bf25db751b
[22:13:50][V][mdns:090]:     TXT: platform = ESP8266
[22:13:50][V][mdns:090]:     TXT: board = esp01_1m
[22:13:50][C][ota:085]: Over-The-Air Updates:
[22:13:50][C][ota:086]:   Address: ac-2nd-bedroom.local:8266
[22:13:50][C][ota:089]:   Using Password.
[u][u][22:13:50][W][ota:094]: Last Boot was an unhandled reset, will proceed to safe mode in 4 restarts[/u][/u]
[22:13:50][C][api:138]: API Server:
[22:13:50][C][api:139]:   Address: ac-2nd-bedroom.local:6053
[22:13:50][C][api:141]:   Using noise encryption: YES
[22:13:50][C][wifi_info:009]: WifiInfo IPAddress 'ac-2nd-bedroom IP'
[22:13:50][V][wifi_info:009]:   Unique ID: '58bf25db751b-wifiinfo-ip'
[22:13:50][C][wifi_info:011]: WifiInfo SSID 'ac-2nd-bedroom SSID'
[22:13:50][V][wifi_info:011]:   Unique ID: '58bf25db751b-wifiinfo-ssid'
[22:13:50][C][wifi_info:012]: WifiInfo BSSID 'ac-2nd-bedroom BSSID'
[22:13:50][V][wifi_info:012]:   Unique ID: '58bf25db751b-wifiinfo-bssid'
[22:13:50][C][wifi_signal.sensor:009]: WiFi Signal 'ac-2nd-bedroom WiFi Signal'
[22:13:50][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[22:13:50][C][wifi_signal.sensor:009]:   State Class: 'measurement'
[22:13:50][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dBm'
[22:13:50][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[22:13:50][V][wifi_signal.sensor:009]:   Unique ID: '58bf25db751b-wifisignal'
[22:13:51][D][api:102]: Accepted 192.168.0.36
[22:13:51][V][component:199]: Component api took a long time for an operation (0.35 s).
[22:13:51][V][component:200]: Components should block for at most 20-30ms.
[22:13:51][V][api.connection:843]: Hello from client: 'ESPHome Logs 2022.6.2 (192.168.0.36)'
[22:13:51][D][api.connection:861]: ESPHome Logs 2022.6.2 (192.168.0.36): Connected successfully
[22:13:51][D][time:041]: Synchronized time: 2022-07-26 22:13:51
[22:14:15][V][json:031]: Attempting to allocate 512 bytes for JSON serialization
[22:14:15][V][json:051]: Size after shrink 64 bytes
[22:14:15][V][json:031]: Attempting to allocate 512 bytes for JSON serialization
[22:14:15][V][json:051]: Size after shrink 156 bytes
[22:14:15][V][json:031]: Attempting to allocate 512 bytes for JSON serialization
[22:14:15][V][json:051]: Size after shrink 152 bytes
[22:14:15][V][json:031]: Attempting to allocate 512 bytes for JSON serialization
[22:14:15][V][json:051]: Size after shrink 200 bytes
[22:14:15][V][json:031]: Attempting to allocate 512 bytes for JSON serialization
[22:14:15][V][json:051]: Size after shrink 144 bytes
[22:14:15][V][json:031]: Attempting to allocate 512 bytes for JSON serialization
[22:14:15][V][json:051]: Size after shrink 144 bytes
[22:14:15][V][json:031]: Attempting to allocate 512 bytes for JSON serialization
[22:14:15][V][json:051]: Size after shrink 156 bytes
[22:14:15][V][json:031]: Attempting to allocate 512 bytes for JSON serialization
[22:14:15][V][json:051]: Size after shrink 444 bytes
[22:14:18][V][sensor:074]: 'ac-2nd-bedroom Uptime': Received new state 44.720001
[22:14:18][D][sensor:124]: 'ac-2nd-bedroom Uptime': Sending state 44.72000 s with 0 decimals of accuracy

and

INFO ac-2nd-bedroom.local: Ping timed out!
INFO Disconnected from ESPHome API for ac-2nd-bedroom.local
WARNING Disconnected from API
WARNING Can't connect to ESPHome API for ac-2nd-bedroom.local: Error connecting to ('192.168.0.32', 6053): [Errno 111] Connect call failed ('192.168.0.32', 6053)
INFO Trying to reconnect to ac-2nd-bedroom.local in the background

and then it stoped

–

thanks for the feedback - tbh - just copy-pasted from the source

nothing connected yet - only USB for power

looks like some component you’re including has a bad memory leak.
Try omitting the third-party components. See if it runs stable. Then add them back incrementally.
I’m guessing/hypothesizing one of them is leaking memory/heap quite badly.
Your JSON rendering lib is dying without space in which to work.

Yes and you need to capture that for us!

And disable the webserver, it eats memory.

Memory leaks are remarkably rare. If there were one in our libraries then many other users would have seen the same issue.

Turned off external components

get a different error:

INFO ac-2nd-bedroom.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for ac-2nd-bedroom.local
WARNING Disconnected from API
INFO ac-2nd-bedroom.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Successfully connected to ac-2nd-bedroom.local

turned off the webserver - in the ESP Home dashboard it still alternates between online and offline, but in the logs no errors any more.
Don’t know why it is showing offline.

Will add back the components again tomorrow to see if it was indeed the webserver

the only thing that I saw in the logs is what I shared, it looks like a boot sequence - repeated a couple of times. Also this log entry suggest the reboot:
Last Boot was an unhandled reset, will proceed to safe mode in X restarts
Were X counted down… - also saw the led flashing as an indication of rebooting.
But other than that I didn’t see crashes or any other info in the logs

Read the yaml, he is using an external component.

Have you tried using this board?

esp8266:
  board: d1_mini

yes, that seems to be the solution. Thanks!