Can't connect to ESPHome device after initial install

Hi all, a couple months ago I created my first ESPHome device with a simple DHT22 sensor on an ESP8266. It works, everything’s gravy - only thing of note is I had to use a static IP to get around mDNS. I’m running the latest HassOS on an rPI 4.

I tried to create a second device but have not had any luck. Even when I use the same config (obv changing name, IP, etc) as the first device, this weird behaviour happens. I’ve tried 3 different, brand new ESP8266s.

Config:

esphome:
  name: office-temp-humid-motion
  platform: ESP8266
  board: nodemcuv2

# Enable logging
logger:
  
# Enable Home Assistant API
api:

ota:
  password: "password"

wifi:
  ssid: "iot_2G"
  password: "password"

  manual_ip:
    static_ip: 192.168.8.150
    gateway: 192.168.8.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Office-Motion"
    password: "password"

captive_portal:

sensor:
  - platform: dht
    model: dht22
    pin: D4 
    temperature:
      name: "Office Temperature"
    humidity:
      name: "Office Humidity"
    update_interval: 60s

Everything compiles and installs fine, and the initial logs shows that the ESP has connected to wifi - can see the device in DHCP server when not using static IP and I can even see the DHT22 send its sensor data at the specified interval. However, I cannot ping the device and the ESPHome dashboard shows as “Offline”. If I try Logs → Wireless, it never connects.

Only significant thing that has changed in my setup recently was an upgrade to Wifi6 APs.

I haven’t shown the logs, because I’m not sure which parts are relevant. Happy to share if anyone can provide that direction.

Cheers!

I have found my wemos mini is also becoming inaccessible from ESP Home dashboard. Despite all sesnsors still sending data to front end. I solved by turning my router and HA on and off. But need a better solution,

Interesting… I’ve tried 2 NodeMCUs and 1 D1 mini. Just restarted HASS and no change. I’d be shot if I rebooted my router, so I agree, better solution needed. :wink:

Weird part is the original ESPHome device works perfectly. Even ran an OTA update.

Put everything but needs logs to diagnostic !
Also what is the new Wifi6 Aps you installed ?

on my part i switched from a “Reserved IP” on the Router for each D1 Wemo to a fixed manual IP on the Wemo itself. So far it seems to be doing the trick and all showing up. Give it another week to see

Full logs below. Nice to see it auto-redacts Wifi info! The new wifi6 APs are Ubiquiti Long Range (U6-LR-US).

The first connection to Wifi seems to always fail. You can also see (at bottom) that the DHT22 sensor is trying to send data. But if I return to the ESPHome dashboard, it’s offline and behaves as described in original post.

INFO Reading configuration /config/esphome/office-temp-humid-motion.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing office-temp-humid-motion (board: nodemcuv2; framework: arduino; platform: platformio/espressif8266 @ 2.6.3)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|-- <ESPAsyncWebServer-esphome> 2.1.0
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <DNSServer> 1.1.1
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
Compiling /data/office-temp-humid-motion/.pioenvs/office-temp-humid-motion/src/main.cpp.o
Linking /data/office-temp-humid-motion/.pioenvs/office-temp-humid-motion/firmware.elf
Building /data/office-temp-humid-motion/.pioenvs/office-temp-humid-motion/firmware.bin
RAM:   [====      ]  39.1% (used 32016 bytes from 81920 bytes)
Flash: [====      ]  39.7% (used 414356 bytes from 1044464 bytes)
esp8266_copy_factory_bin(["/data/office-temp-humid-motion/.pioenvs/office-temp-humid-motion/firmware.bin"], ["/data/office-temp-humid-motion/.pioenvs/office-temp-humid-motion/firmware.elf"])
========================= [SUCCESS] Took 15.53 seconds =========================
INFO Successfully compiled program.
esptool.py v3.2
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: e8:db:84:c4:79:5d
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00000000 to 0x00066fff...
Compressed 418512 bytes to 290694...
Wrote 418512 bytes (290694 compressed) at 0x00000000 in 6.8 seconds (effective 494.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB0 with baud rate 115200
[13:52:51]
[13:52:51]SDK:2.2.2-dev(38a443e)/Core:2.7.3-3-g2843a5ac=20703003/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50/BearSSL:5c771be
[13:52:51][I][logger:214]: Log initialized
[13:52:51][C][ota:458]: There have been 0 suspected unsuccessful boot attempts.
[13:52:51][I][app:029]: Running through setup()...
[13:52:51][V][app:030]: Sorting components by setup priority...
[13:52:51][C][dht:011]: Setting up DHT...
[13:52:51][C][wifi:037]: Setting up WiFi...
[13:52:51][V][wifi_esp8266:068]: Disabling AP.
[13:52:51]bcn 0
[13:52:51]del if1
[13:52:51]usl
[13:52:51]mode : null
[13:52:51][V][wifi_esp8266:058]: Enabling STA.
[13:52:51]mode[V][wifi_esp8266:535]: Event: Changed Mode old=AP new=OFF
[13:52:51]wifi evt: 8
[13:52:51] : sta(e8:db:84:c4:79:5d)
[13:52:51]add if0
[13:52:51][V][wifi_esp8266:535]: Event: Changed Mode old=OFF new=STA
[13:52:51]wifi evt: 8
[13:52:51]sleep disable
[13:52:51][D][wifi:370]: Starting scan...
[13:52:51][W][dht:167]: Requesting data from DHT failed!
[13:52:51][W][dht:060]: Invalid readings! Please check your wiring (pull-up resistor, pin number).
[13:52:51][V][sensor:074]: 'Office Temperature': Received new state nan
[13:52:51][D][sensor:125]: 'Office Temperature': Sending state nan °C with 1 decimals of accuracy
[13:52:51][V][sensor:074]: 'Office Humidity': Received new state nan
[13:52:51][D][sensor:125]: 'Office Humidity': Sending state nan % with 0 decimals of accuracy
[13:52:57]scandone
[13:52:57][D][wifi:385]: Found networks:
[13:52:57][I][wifi:429]: - 'iot_2G' [redacted]▂▄▆█
[13:52:57][D][wifi:430]:     Channel: 11
[13:52:57][D][wifi:431]:     RSSI: -46 dB
[13:52:57][I][wifi:429]: - 'iot_2G' [redacted]▂▄▆█
[13:52:57][D][wifi:430]:     Channel: 1
[13:52:57][D][wifi:431]:     RSSI: -62 dB
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:57][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][D][wifi:434]: - [redacted] [redacted]▂▄▆█
[13:52:58][I][wifi:245]: WiFi Connecting to 'iot_2G'...
[13:52:58][V][wifi:247]: Connection Params:
[13:52:58][V][wifi:248]:   SSID: 'iot_2G'
[13:52:58][V][wifi:251]:   BSSID: 7A:45:58:B3:F7:6D
[13:52:58][V][wifi:271]:   Password: [redacted]
[13:52:58][V][wifi:276]:   Channel: 11
[13:52:58][V][wifi:283]:   Manual IP: Static IP=192.168.8.150 Gateway=192.168.8.1 Subnet=255.255.255.0 DNS1=0.0.0.0 DNS2=0.0.0.0
[13:52:58][V][wifi:287]:   Hidden: NO
[13:52:58][V][wifi_esp8266:493]: Event: Changed AuthMode old=OPEN new=WPA2 PSK
[13:52:58]wifi evt: 2
[13:52:58]scandone
[13:52:59]state: 0 -> 2 (b0)
[13:52:59]state: 2 -> 3 (0)
[13:53:00]state: 3 -> 0 (4)
[13:53:00][W][wifi_esp8266:483]: Event: Disconnected ssid='iot_2G' bssid=[redacted] reason='Association Expired'
[13:53:00]wifi evt: 1
[13:53:00]STA disconnect: 4
[13:53:00][W][wifi:533]: Error while connecting to network.
[13:53:00][W][wifi:568]: Restarting WiFi adapter...
[13:53:00][V][wifi_esp8266:060]: Disabling STA.
[13:53:00]del if0
[13:53:00]usl
[13:53:00]mode : null
[13:53:00][V][wifi_esp8266:535]: Event: Changed Mode old=STA new=OFF
[13:53:00]wifi evt: 8
[13:53:00][I][wifi:245]: WiFi Connecting to 'iot_2G'...
[13:53:00][V][wifi:247]: Connection Params:
[13:53:00][V][wifi:248]:   SSID: 'iot_2G'
[13:53:00][V][wifi:251]:   BSSID: 7A:45:58:B3:F7:6D
[13:53:00][V][wifi:271]:   Password: [redacted]
[13:53:00][V][wifi:276]:   Channel: 11
[13:53:00][V][wifi:283]:   Manual IP: Static IP=192.168.8.150 Gateway=192.168.8.1 Subnet=255.255.255.0 DNS1=0.0.0.0 DNS2=0.0.0.0
[13:53:00][V][wifi:287]:   Hidden: NO
[13:53:00][V][wifi_esp8266:058]: Enabling STA.
[13:53:00]mode : sta(e8:db:84:c4:79:5d)
[13:53:00]ip:192.168.8.150,mask:255.255.255.0,gw:192.168.8.1
[13:53:00]add if0
[13:53:00][V][wifi_esp8266:535]: Event: Changed Mode old=OFF new=STA
[13:53:00]wifi evt: 8
[13:53:01]scandone
[13:53:01]state: 0 -> 2 (b0)
[13:53:01]state: 2 -> 3 (0)
[13:53:01]state: 3 -> 5 (10)
[13:53:01]add 0
[13:53:01]aid 3
[13:53:01]cnt 
[13:53:02]
[13:53:02]connected with iot_2G, channel 11
[13:53:02]ip:192.168.8.150,mask:255.255.255.0,gw:192.168.8.1
[13:53:02][V][wifi_esp8266:469]: Event: Connected ssid='iot_2G' bssid=7A:45:58:B3:F7:6D channel=11
[13:53:02]wifi evt: 0
[13:53:03][V][wifi_esp8266:508]: Event: Got IP static_ip=192.168.8.150 gateway=192.168.8.1 netmask=255.255.255.0
[13:53:03]wifi evt: 3
[13:53:03][I][wifi:502]: WiFi Connected!
[13:53:03][C][wifi:350]:   Local MAC: E8:DB:84:C4:79:5D
[13:53:03][C][wifi:351]:   SSID: [redacted]
[13:53:03][C][wifi:352]:   IP Address: 192.168.8.150
[13:53:03][C][wifi:354]:   BSSID: [redacted]
[13:53:03][C][wifi:355]:   Hostname: 'office-temp-humid-motion'
[13:53:03][C][wifi:357]:   Signal strength: -50 dB ▂▄▆█
[13:53:03][V][wifi:359]:   Priority: -1.0
[13:53:03][C][wifi:361]:   Channel: 11
[13:53:03][C][wifi:362]:   Subnet: 255.255.255.0
[13:53:03][C][wifi:363]:   Gateway: 192.168.8.1
[13:53:03][C][wifi:364]:   DNS1: 0.0.0.0
[13:53:03][C][wifi:365]:   DNS2: 0.0.0.0
[13:53:03][D][wifi:511]: Disabling AP...
[13:53:03][C][ota:082]: Over-The-Air Updates:
[13:53:03][C][ota:083]:   Address: 192.168.8.150:8266
[13:53:03][C][ota:086]:   Using Password.
[13:53:03][C][api:025]: Setting up Home Assistant API server...
[13:53:03][I][app:062]: setup() finished successfully!
[13:53:03][I][app:102]: ESPHome version 2022.1.2 compiled on Jan 25 2022, 13:52:30
[13:53:03][C][wifi:488]: WiFi:
[13:53:03][C][wifi:350]:   Local MAC: E8:DB:84:C4:79:5D
[13:53:03][C][wifi:351]:   SSID: [redacted]
[13:53:03][C][wifi:352]:   IP Address: 192.168.8.150
[13:53:03][C][wifi:354]:   BSSID: [redacted]
[13:53:03][C][wifi:355]:   Hostname: 'office-temp-humid-motion'
[13:53:03][C][wifi:357]:   Signal strength: -51 dB ▂▄▆█
[13:53:03][V][wifi:359]:   Priority: -1.0
[13:53:03][C][wifi:361]:   Channel: 11
[13:53:03][C][wifi:362]:   Subnet: 255.255.255.0
[13:53:03][C][wifi:363]:   Gateway: 192.168.8.1
[13:53:03][C][wifi:364]:   DNS1: 0.0.0.0
[13:53:03][C][wifi:365]:   DNS2: 0.0.0.0
[13:53:03][C][logger:233]: Logger:
[13:53:03][C][logger:234]:   Level: VERBOSE
[13:53:03][C][logger:235]:   Log Baud Rate: 115200
[13:53:03][C][logger:236]:   Hardware UART: UART0
[13:53:03][C][dht:017]: DHT:
[13:53:03][C][dht:018]:   Pin: GPIO2
[13:53:03][C][dht:024]:   Model: DHT22 (or equivalent)
[13:53:03][C][dht:027]:   Update Interval: 60.0s
[13:53:03][C][dht:029]:   Temperature 'Office Temperature'
[13:53:03][C][dht:029]:     Device Class: 'temperature'
[13:53:03][C][dht:029]:     State Class: 'measurement'
[13:53:03][C][dht:029]:     Unit of Measurement: '°C'
[13:53:03][C][dht:029]:     Accuracy Decimals: 1
[13:53:03][C][dht:030]:   Humidity 'Office Humidity'
[13:53:03][C][dht:030]:     Device Class: 'humidity'
[13:53:03][C][dht:030]:     State Class: 'measurement'
[13:53:03][C][dht:030]:     Unit of Measurement: '%'
[13:53:03][C][dht:030]:     Accuracy Decimals: 0
[13:53:03][C][captive_portal:144]: Captive Portal:
[13:53:03][C][ota:082]: Over-The-Air Updates:
[13:53:03][C][ota:083]:   Address: 192.168.8.150:8266
[13:53:03][C][ota:086]:   Using Password.
[13:53:03][C][api:134]: API Server:
[13:53:03][C][api:135]:   Address: 192.168.8.150:6053
[13:53:03][C][api:139]:   Using noise encryption: NO
[13:53:03][C][mdns:084]: mDNS:
[13:53:03][C][mdns:085]:   Hostname: office-temp-humid-motion
[13:53:03][V][mdns:086]:   Services:
[13:53:03][V][mdns:088]:   - _esphomelib, _tcp, 6053
[13:53:03][V][mdns:090]:     TXT: version = 2022.1.2
[13:53:03][V][mdns:090]:     TXT: mac = e8db84c4795d
[13:53:03][V][mdns:090]:     TXT: platform = ESP8266
[13:53:03][V][mdns:090]:     TXT: board = nodemcuv2
[13:53:11]pm open,type:0 0
[13:53:37][W][dht:167]: Requesting data from DHT failed!
[13:53:37][W][dht:060]: Invalid readings! Please check your wiring (pull-up resistor, pin number).
[13:53:37][V][sensor:074]: 'Office Temperature': Received new state nan
[13:53:37][D][sensor:125]: 'Office Temperature': Sending state nan °C with 1 decimals of accuracy
[13:53:37][V][sensor:074]: 'Office Humidity': Received new state nan
[13:53:37][D][sensor:125]: 'Office Humidity': Sending state nan % with 0 decimals of accuracy
[13:54:37][W][dht:167]: Requesting data from DHT failed!
[13:54:37][W][dht:060]: Invalid readings! Please check your wiring (pull-up resistor, pin number).
[13:54:37][V][sensor:074]: 'Office Temperature': Received new state nan
[13:54:37][D][sensor:125]: 'Office Temperature': Sending state nan °C with 1 decimals of accuracy
[13:54:37][V][sensor:074]: 'Office Humidity': Received new state nan
[13:54:37][D][sensor:125]: 'Office Humidity': Sending state nan % with 0 decimals of accuracy

Thanks for full logs and what is physical distance between ESP and AP ? I suspect there are very near and these APs are quite powerful and you can’t expect radio to work properly if very near :frowning:

It was ~6ft from the AP when I did the install. I’ve since moved it across the house and plugged back in, so 30-40 ft with walls between line of sight, and still can’t connect.

Could the proximity at time of setup be a cause of the issue?

So I left the ESP plugged in overnight and when I came down today it was online. I guess proximity to the new AP was too close. Thanks @vincen for helping diagnose and for leading the way to my next rabbit hole lol

I may have spoken too soon as the ESP is now offline again. I’ve tried setting the 2.4G transmit power to Low, still not working. Though I think I can be pretty sure it’s a networking issue.

Few extra points that come in my mind:
→ power supply of that ESP is well dimensionned ?
→ what are all these so many Wifi ESP sees and with full power ??
→ and also serious oncerns why ESP sees two times same SSID on different channels ?? it’s extremely confusing and for sure not helping wifi to work properly ! (sorry didn’t notice earlier !

I’ve tried many, most are 5v 1500ma charging adapters; same as I’m using on the working one. I should also mention that I don’t currently have any sensors physically connected to the ESP at the moment.

I think this may be part of the auto-redact feature. They are a combination of my SSIDs and neighbours and not all are 100% when viewed in regular logs.

I’m not a networking pro, so I can’t really say. I thought it was because there were two channels available… I have two APs, so may it’s my second one?

Edit: Confirmed it’s the other AP. AP1 on channel 1, AP2 on channel 11 on 2.4G.

Interesting thing I noticed, the device shows as connected to the AP, but doesn’t show an IP address (see below). Looking at this now. I may try to deploy using non-static IP to see if DHCP picks it up.

Ok, I stumbled on the solution. Seems that using manual_ip: doesn’t work with my router for some reason (EdgeRouter X). Here’s what I did:

  1. Install without manual_ip: config
  2. Once DHCP has assigned an IP, add the manual_ip: block to the config using the IP that DHCP assigned. I also mapped the ESP’s MAC address to static on the DHCP server so the IP will never change.
  3. Save (don’t re-Install)
  4. I can now view the logs over wireless.

Obviously this is very hacky and, had I not already run an OTA update for my working ESP, I would assume this would break connection on next update. (maybe OTA doesn’t refresh full config?)

At the end of the day, this would have all been avoided if the ESPHome addon provided the option to NOT use mDNS to access our sensors without using the manual_ip: config. But, as per the following link, this appears to be by design. le sigh

1 Like

sound good, hope the cable between power supply and ESP is also adequate :wink:

Very weirdo configuration, I would strongly suggest to keep only one AP online (disconnect physically all the other ones) and see if ESP connects properly and what initial ESP Wifi scan discovers !

which is sign of a serious problem somewhere that you won’t solve properly by playing with network options of the ESP, sorry to say :frowning:

Whilst this topic may have been marked as solved, this problem still exists and the work around is still valid.

There appears to be some bug with ESP8266 devices when using static IP assignments.