ESPHome - 8266 device does not connect to WiFi

Hi everybody,

ESPHome sounds great to me, but I got stuck at the very beginning.

I’m using a D1 mini V3 board, which is Arduino compatible and working fine with it’s integrated WiFi.
Uploading the ESP-framework code worked perfect. There are no errors during compile process.

But on start, the message is displayed “mDNS … failed” and two other messages, which show, that the board does not connect to WiFi. Using a fixed manual set IP does not change the result.

I checked the weak points, as: Signal strenght, password/ ssid of WiFi, correct board type etc. All the standard traps.

The same boards works fine with Wifi using an Arduino sketch, I wrote for temperature measurement.

Is there anything I can do, to fix it? Maybe there are settings incorrect or the ESPHome does not work with all “8266 generic boards”.

Please share your thoughts with me. Any hint is welcome, I’m a HA rookie :slight_smile:

Kind regards
Michael

Please share your yaml and your log with us.

When answering, please read this, particularly point 11 How to help us help you - or How to ask a good question

PS, welcome aboard :slight_smile:

It has happened to me that a bug in the code/yaml made the board not connect.
It was not picked up by the compiler but it just didn’t connect.

Try and remove everything that is not essential and compile a new binary and upload it with cable to the ESP.

Thank you, my fried, for this turbo-quick reply. Let me share my home-assistant.log with you. My tries with ESPHome happened yesterday, March-23:

2021-05-23 13:29:39 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Timeout occurred while connecting to IPP server.
2021-05-23 16:56:57 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration esphome/: No module named ‘homeassistant.components.esphome/’
2021-05-23 16:58:18 ERROR (MainThread) [homeassistant.components.hue.light] Timeout fetching light data
2021-05-23 16:59:12 ERROR (MainThread) [homeassistant.components.hue.light] Timeout fetching light data
2021-05-23 16:59:12 ERROR (MainThread) [homeassistant.components.hue.sensor_base] Timeout fetching sensor data
2021-05-23 17:17:08 ERROR (MainThread) [homeassistant.components.hue.light] Timeout fetching group data
2021-05-23 17:17:08 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py”, line 673, in ping
await self._send_frame(message, WSMsgType.PING)
File “/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py”, line 650, in _send_frame
self._write(header + message)
File “/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py”, line 660, in _write
raise ConnectionResetError(“Cannot write to closing transport”)
ConnectionResetError: Cannot write to closing transport
2021-05-23 17:17:25 ERROR (MainThread) [homeassistant.components.hue.light] Timeout fetching light data
2021-05-23 17:17:25 ERROR (MainThread) [homeassistant.components.hue.sensor_base] Timeout fetching sensor data
2021-05-23 19:31:43 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py”, line 422, in _handle_request
resp = await self._request_handler(request)
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py”, line 499, in _handle
resp = await handler(request)
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py”, line 119, in impl
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/security_filter.py”, line 56, in security_filter_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/request_context.py”, line 18, in request_context_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/ban.py”, line 74, in ban_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/auth.py”, line 135, in auth_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/view.py”, line 131, in handle
result = await result
File “/usr/src/homeassistant/homeassistant/components/hassio/ingress.py”, line 57, in _handle
return await self._handle_request(request, token, path)
File “/usr/src/homeassistant/homeassistant/components/hassio/ingress.py”, line 152, in _handle_request
await response.prepare(request)
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py”, line 378, in prepare
return await self._start(request)
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py”, line 386, in _start
await self._write_headers()
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py”, line 458, in _write_headers
await writer.write_headers(status_line, self._headers)
File “/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py”, line 119, in write_headers
self._write(buf)
File “/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py”, line 67, in _write
raise ConnectionResetError(“Cannot write to closing transport”)
ConnectionResetError: Cannot write to closing transport
2021-05-23 19:40:33 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Timeout occurred while connecting to IPP server.
2021-05-23 21:05:13 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Timeout occurred while connecting to IPP server.
2021-05-23 21:48:39 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Timeout occurred while connecting to IPP server.
2021-05-24 08:46:03 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Timeout occurred while connecting to IPP server.
2021-05-24 11:54:11 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Timeout occurred while connecting to IPP server.
2021-05-24 12:35:35 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Timeout occurred while connecting to IPP server.
2021-05-24 14:28:23 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Timeout occurred while connecting to IPP server.
2021-05-24 15:39:39 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Timeout occurred while connecting to IPP server.
2021-05-25 02:11:21 WARNING (MainThread) [homeassistant.components.websocket_api.http.connection] [1763688536] Disconnected: Did not receive auth message within 10 seconds
2021-05-25 02:11:25 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [1778996824] Received invalid command
2021-05-25 02:11:26 ERROR (MainThread) [homeassistant.components.mobile_app.webhook] Received invalid webhook payload: value must be at least 0 for dictionary value @ data[‘battery’]. Got -100

This is the screen, I get after compilation and start:
========================= [SUCCESS] Took 11.06 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of switch-globus.local
ERROR Error resolving IP address of switch-globus.local. Is it connected to WiFi?
ERROR (If this error persists, please set a static IP address: WiFi Component — ESPHome)
ERROR Error resolving IP address: Error resolving address with mDNS: Did not respond. Maybe the device is offline., [Errno -5] No address associated with hostname

The first time you compiled, was it connected with a cable ?

You didn’t share your yaml. Nor did you share your esphome logs so far as I can see.

Hi Francis, YES, it was all the time connected with an USB-cable.

I appreaciate you help very much :slight_smile: Hope, I picked the correct logs. Please find here

switch-globus.yaml
ESP log

I tried the version with manual IP again.

------ switch-globus.yaml -----

esphome:
name: switch-globus
platform: ESP8266
board: esp01_1m

wifi:
ssid: Werkstatt
password: 29dfmk11

manual_ip:
# Set this to the IP of the ESP
static_ip: 192.168.0.199
# Set this to the IP address of the router. Often ends with .1
gateway: 192.168.0.1
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0

#captive_portal:

Enable logging

logger:

Enable Home Assistant API

api:
password: “29dfmk11”

ota:
password: “29dfmk11”

-------------------------------------ESP log -----------------------------------------------------------------------

Compiling & Uploading: switch-globus.yaml
INFO Reading configuration /config/esphome/switch-globus.yaml…
INFO Generating C++ source…
INFO Compiling app…
INFO Running: platformio run -d /config/esphome/switch-globus
Processing switch-globus (board: esp01_1m; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
PACKAGES:

  • framework-arduinoespressif8266 3.20704.0 (2.7.4)
  • tool-esptool 1.413.0 (4.13)
  • tool-esptoolpy 1.20800.0 (2.8.0)
  • toolchain-xtensa 2.40802.200502 (4.8.2)
    Library Manager: Installing Update
    Library Manager: Already installed, built-in library
    Dependency Graph

|-- ESPAsyncTCP-esphome> 1.2.3
| |-- ESP8266WiFi> 1.0
|-- ESP8266WiFi> 1.0
|-- ESP8266mDNS> 1.2
| |-- ESP8266WiFi> 1.0
Retrieving maximum program size /data/switch-globus/.pioenvs/switch-globus/firmware.elf
Checking size /data/switch-globus/.pioenvs/switch-globus/firmware.elf
RAM: [===== ] 45.3% (used 37148 bytes from 81920 bytes)
Flash: [=== ] 34.0% (used 348648 bytes from 1023984 bytes)

========================= [SUCCESS] Took 9.76 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.0.199
ERROR Connecting to 192.168.0.199:8266 failed: [Errno 113] No route to host

I deleted the “<” in some lines, because it’s supressing 5 lines of display (“ 1.2.3” f.e.)

Please? did you read this?

The first time you have to manually upload by USB. Only then it will connect to WiFi, and be able to OTA.

Thanks for all that effort, you put into my problem - very kind, thank you!

I bought 4 HUE-compatible wallplugs for just 26,50 € to solve my problem.
4 boards + relay etc. etc. would cost double of that and had to be soldered and you need a box for it etc. etc. etc.

Let me come back to the ESP later

Thanks for that. It was clear to me, that the first upload etc. has to be done by USB, because there is no initial connection to WiFi when starting to flash the board for the first time.