ESPHome devices lose their connection

Good point I’l be testing this as well

Config. right now is :

esphome:
  name: garaazi_andurid
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "ssid"
  password: "pass"
  power_save_mode: none
  manual_ip:
    static_ip: 192.168.200.56
    gateway: 192.168.200.254
    subnet: 255.255.255.0
    dns1: 194.126.97.30
    dns2: 1.1.1.1

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

sensor:
    
  - platform: uptime
    name: Uptime garaaz

let’s see what happening.

-NO same - with this config still connection is losing.

So it still disconnects with mostly bare config, interesting.

Do you still have any abort/crash messages in logs? (It looked like they were coming from temperature sensor code that you removed, but who knows if they’d be caused somewhere else)

The bare minimum configuration you quoted above should work fine, what you’re experiencing means that either something is wrong with your particular device (unlikely but possible)

… or there’s a software problem, ie. something is wrong with the code that many others are relying on, but many others might be lucky to not hit the same set of conditions as you are… This latter option, even though it’s less likely makes the issue you’re experiencing worth investigating.

You could perhaps run it with log_level: VERBOSE or log_level: VERY_VERBOSE.

Perhaps you could strip down the config even further, I’m thinking along the lines of disabling dns and gateway, removing ota since you have serial, perhaps even removing API component, which makes it impossible for it to talk to home assistant but it should still be able to hold its wifi and not reboot.

At that point I’d say you’d have enough useful information to file an official bug with @OttoWinter.

If nothing else, Otto might be able to narrow it down even more, or perhaps sprinkle some more logging to make this easier to debug.

Perhaps we should include some general debugging/troubleshooting workflows in a doc/post somewhere.
A couple of example scenarios and what ifs.

Hi, did you disconnect all your gpio inputs before trying ?
As I noticed in your original post your using gpio 2

Can you share the code for how you implemented the uptime sensor? I’m having the exact same issue with all my NodeMCUs. I’d like to track iuptime as well to see just how bad it is. I really like the ESPhome features, especially the ease of deployment and monitoring. It would be a real shame to have to go back to MQTT, but this is driving me nuts.

1 Like

It’s just this one: https://esphome.io/components/sensor/uptime.html .

When you say “exactly the same issue”, do you mean crashes/aborts in logs, or wifi disconnects, or reboots, or stuckness, … there’s a couple of people with different underlying problems in this thread. Also, which version of nodemcu do you have, what do you have currently connected to your GPIO?

The disconnects which then resets the device- at least that’s what shows in the log. I have a dozen of these: CP2102 ESP-12E, they are ESP8266 Boards. Absolutely Rock solid using NodeMCU firmware and MQTT, even several hundred feet away from WiFi on 2.4 or 5ghz.

Right now the one under test just has a 3v relay and a push button and an led indicator. I keep it toggled on, but it randomly toggles off by itself. I installed the dev branch 1.15.0 last nite at 2am just for kicks, and toggled the switch on. It was still on at 8am when I just checked it.

I used to get log entries of connect/disconnect every few minutes but it cluttered the log so I suppressed those msgs. If it helps, I can reenable the log and post it here.
Uptime Sensor installed successfully.
Jeff

More investigation has revealed that the relay/gpio I set up is cycling exactly 5 minutes all by itself. On,off,on,off,etc. no automation or script is tied to this device. The uptime sensor is at 100%, so it doesn’t appear to be WiFi or connection related.

Im very vexed. And perplexed. It happed even if I swap out the esp module with another one.

INFO Reading configuration /config/esphome/coop.yaml...
INFO Configuration is valid!
esphome:
  name: coop
  platform: ESP8266
  board: nodemcuv2
  platformio_options: {}
  esp8266_restore_from_flash: false
  arduino_version: [email protected]
  libraries: []
  build_path: coop
  includes: []
  board_flash_mode: dout
sensor:
- platform: uptime
  name: ESP8266 Uptime Sensor
  force_update: false
  unit_of_measurement: s
  icon: mdi:timer
  update_interval: 60s
  accuracy_decimals: 0
wifi:
  power_save_mode: NONE
  manual_ip:
    static_ip: 192.168.1.145
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns2: 0.0.0.0
    dns1: 0.0.0.0
  ap:
    ssid: MBR
    password: Xxxx
    ap_timeout: 1min
  reboot_timeout: 15min
  fast_connect: false
  domain: .local
  output_power: 20.0
  networks:
  - ssid: Shop
    password: Xxxxxx
    priority: 0.0
  use_address: 192.168.1.145
captive_portal: {}
logger:
  level: DEBUG
  baud_rate: 115200
  hardware_uart: UART0
  esp8266_store_log_strings_in_flash: true
  logs: {}
  tx_buffer_size: 512
api:
  port: 6053
  reboot_timeout: 15min
  password: ''
ota:
  port: 8266
  safe_mode: true
  password: ''
switch:
- platform: gpio
  name: Relay 1
  inverted: true
  pin:
    number: 5
    inverted: false
    mode: OUTPUT
  restore_mode: RESTORE_DEFAULT_OFF
  interlock_wait_time: 0ms
binary_sensor:
- platform: gpio
  name: Switch 1
  pin:
    number: 4
    inverted: true
    mode: INPUT_PULLUP

Any ideas?

What firmware? Tasmota?

https://nodemcu-build.com/

I used Various configurations, displays, sensors, relays, etc. a royal pain to upload and modify/debug but I used this for a year before I discovered home assistant. Rock solid using mqtt.

Jeff

I finally figured out how to overcome this annoying bug. I documented how to reproduce it here.

Try and disable logger and see if that resolves your network connection issues.

#logger:

I have many Sonoff Basics running ESPHome and suffered with network connection issues for a long time and went deep down the rabbit hole of troubleshooting. I finally read a thread where Otto recommended trying to disable logger. That fixed my issue. Seems logger was causing something to crash/restart that affects network, but not the uptime counter for the device. My NodeMCU and D1 Mini devices with more RAM didn’t have this issue. Good luck!

BTW, trying all the power_save_mode and fast_connect options did nothing to help this issue for me. https://esphome.io/components/wifi.html

can confirm that 2 of my Wemos D1 mini and one Sonoff RF work ok with logger enabled.

try playing around with output_power in the wifi component I cannot find it in the docs but here’s a PR

Hi I removed/disabled logger, but still same :frowning:
Screenshot 2020-02-24 10.29.00

I was having similar device unavailable issues.
Since updating ESPHome to 1.15.0-dev, running Clean Build Files and then updating the node firmwares, I have no problems.

Tried this with mine but still having the same issues unfortunately

HA version 105.5?

HA version is now 105.5 but the problem was with 102 or 103 version.

can You show how You exactly put it in your Config. file

I got some error if I try change the confgi ( esphome_version: 1.15.0-dev)

Try disable “logger” in yaml device config.