ESP8266 dropping wifi connection

I know there’s several threads for similar issues but they’re a bit older and they don’t alway seem to be caused by the same thing. I’m still fairly new to HA so please bear with me.

I deployed 2 ESP32’s and an ESP8266, all Adafruit Feather boards. The ESP32’s seem rock stable but the ESP8266 seems to drop the connection every 30-45 minutes or so, sometimes shorter, sometimes longer. Usually it comes back up with in 10 seconds but there has been occasions where it took 20 minutes. Doesn’t matter how close or far I have it from the AP and I’ve tried it with multiple power supplies.

Here is my YAML file for that device.

esphome:
  name: bedroom_midea_ac
  platform: ESP8266
  board: huzzah

wifi:
  ssid: "[Redacted]"
  password: "[Redacted]"

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

captive_portal:


# Enable Home Assistant API
api:

ota:
sensor:
  - platform: wifi_signal
    name: "Bedroom AC Wifi signal"
    update_interval: 60s
  - platform: uptime
    name: "Bedroom AC uptime"


# Example configuration entry

# Disable logging over UART (required)
logger:
  baud_rate: 0


# UART settings for Midea dongle (required)
uart:
  tx_pin: 3
  rx_pin: 1
  baud_rate: 9600

# Optional (if you want modify settings)
midea_dongle:
  strength_icon: false

# Main settings
climate:
  - platform: midea_ac
    name: "Bedroom A/C"
    visual:
      min_temperature: 18 °C
      max_temperature: 25 °C
      temperature_step: 0.1 °C
    beeper: false
    swing_both: true
    outdoor_temperature:
      name: "Outside Temp"
    power_usage:
      name: "Power"

Here’s what I’m seeing in the logfile

2021-05-14 22:34:52 WARNING (MainThread) [homeassistant.components.esphome] Can't connect to ESPHome API for bedroom_midea_ac (192.168.1.193): Error connecting to ('192.168.1.193', 6053): [Errno 113] Connect call failed ('192.168.1.193', 6053)

2021-05-14 22:50:12 WARNING (MainThread) [homeassistant.components.esphome] Can't connect to ESPHome API for bedroom_midea_ac (192.168.1.193): Error connecting to ('192.168.1.193', 6053): [Errno 113] Connect call failed ('192.168.1.193', 6053)

2021-05-15 00:43:53 WARNING (MainThread) [homeassistant.components.esphome] Can't connect to ESPHome API for bedroom_midea_ac (192.168.1.193): Error connecting to ('192.168.1.193', 6053): [Errno 113] Connect call failed ('192.168.1.193', 6053)

2021-05-15 04:42:03 WARNING (MainThread) [homeassistant.components.esphome] Can't connect to ESPHome API for bedroom_midea_ac (192.168.1.193): Timeout while connecting to ('192.168.1.193', 6053)

And this is what the ESP8266 itself spits out when I look at the live logs (when it’s actually working)

[18:47:46][I][app:105]: ESPHome version 1.17.1 compiled on May 16 2021, 12:21:06
[18:47:46][C][wifi:443]: WiFi:
[18:47:46][C][wifi:303]:   SSID: [redacted]
[18:47:46][C][wifi:304]:   IP Address: 192.168.1.193
[18:47:46][C][wifi:306]:   BSSID: [redacted]
[18:47:46][C][wifi:307]:   Hostname: 'bedroom_midea_ac'
[18:47:46][C][wifi:311]:   Signal strength: -71 dB ▂▄▆█
[18:47:46][C][wifi:315]:   Channel: 10
[18:47:46][C][wifi:316]:   Subnet: 255.255.255.0
[18:47:46][C][wifi:317]:   Gateway: 192.168.1.1
[18:47:46][C][wifi:318]:   DNS1: 192.168.1.1
[18:47:46][C][wifi:319]:   DNS2: (IP unset)
[18:47:46][C][uart_esp8266:075]: UART Bus:
[18:47:46][C][uart_esp8266:077]:   TX Pin: GPIO3
[18:47:46][C][uart_esp8266:080]:   RX Pin: GPIO1
[18:47:46][C][uart_esp8266:081]:   RX Buffer Size: 256
[18:47:46][C][uart_esp8266:083]:   Baud Rate: 9600 baud
[18:47:46][C][uart_esp8266:084]:   Data Bits: 8
[18:47:46][C][uart_esp8266:085]:   Parity: NONE
[18:47:46][C][uart_esp8266:086]:   Stop bits: 1
[18:47:46][C][uart_esp8266:090]:   Using software serial
[18:47:46][C][uptime.sensor:030]: Uptime Sensor 'Bedroom AC uptime'
[18:47:46][C][uptime.sensor:030]:   Unit of Measurement: 's'
[18:47:46][C][uptime.sensor:030]:   Accuracy Decimals: 0
[18:47:46][C][uptime.sensor:030]:   Icon: 'mdi:timer-outline'
[18:47:46][C][logger:185]: Logger:
[18:47:46][C][logger:186]:   Level: DEBUG
[18:47:46][C][logger:187]:   Log Baud Rate: 0
[18:47:46][C][logger:188]:   Hardware UART: UART0
[18:47:46][C][captive_portal:169]: Captive Portal:
[18:47:46][C][ota:029]: Over-The-Air Updates:
[18:47:46][C][ota:030]:   Address: bedroom_midea_ac.local:8266
[18:47:46][C][api:095]: API Server:
[18:47:46][C][api:096]:   Address: bedroom_midea_ac.local:6053
[18:47:46][C][wifi_signal.sensor:009]: WiFi Signal 'Bedroom AC Wifi signal'
[18:47:46][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[18:47:46][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dB'
[18:47:46][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0

Before I just go ahead and return this ESP8266 and swap it out for another ESP32 is there anything I should try first?

What do you use precisely as power supply for the problematic ESP ? as it looks pretty much as a power supply problem !

Air conditioner USB port. I’ve got 3 of them and it doesn’t matter which one it’s plugged into. I can plug one of the ESP32’s in where this 8266 is having trouble and it’ll work just fine.

Oki so please use first a real USB power supply enough powerful for your board and then we’ll see how it goes ! Fact that it works with one board and not the other is just normal as they probably don’t have same power consumption (unable to find that basic info on Adafruit website…) not even speaking about using USB port of an AC…

Maybe not the reason if it’s disconnecting that quickly, but try setting a static IP.

Also, you “shouldn’t” use 2.4GHz wifi channel 10: stick with 1, 6 and 11 unless you have good reason not to — this won’t be related to your problem though.

I’ll probably try powering it off of an iPad charger later for a while to see what happens. Lots of other people are using 8266’s in this same application without any problem, which is why I was thinking it was a software config issue. If it is a power supply issue then I might as well just swap it for an ESP32 since this is where it needs to work.

Also I’ll try and reconfigure my AP. I don’t remember setting to channel 10, or any channel at all really. Either this is what it automatically does or that’s it’s default setting.

yep but even if you swap be careful as difference of consumption between both is not important I think ! a good USB charger may be a good solution (check on it sticker/engravings as some are not really powerful even if bulky…)

Something also regarding the AP be careful it doesn’t have an option to select Wifi channel automatically as it’s often a problem for IoT devices :frowning:

Well I tried powering it off of a 2.1a USB charger and keeping it about 10 ft from the AP in the same room. Same thing. I ended up swapping it for an ESP32 and it’s working perfectly like the others. Not sure if maybe my 8266 was defective or not but that’s what it took to solve this issue.

Perhaps a dodgy clone? My several 8266s are rock solid.

It was an Adafruit board I bought at Microcenter so I’d imagine it would be pretty legit.

If your sensor has anything like a poll_interval option, try increasing it.
There’s a possibility that the sensor polling is taking too much time and the loop isn’t returning soon enough from your code and thus isn’t able to service the WiFi connection’s CPU-time needs sufficiently.