I’m using a D1Mini with two reed switches, a DHT11 and a relay for garage door monitoring and control. When I program the board directly through the Rpi4, all goes well and it connects to wifi and begins logging temp/humidity info as programmed.
As soon as I cycle the power on the board, it will not connect to wifi (even when using the same cable to power from Rpi4).
Here snippets of the logs:
Upon programming:
> [08:33:35][C][captive_portal:088]: Captive Portal:
> [08:33:35][C][mdns:115]: mDNS:
> [08:33:35][C][mdns:116]: Hostname: garage-controltemphum
> [08:33:35][C][ota:097]: Over-The-Air Updates:
> [08:33:35][C][ota:098]: Address: garage-controltemphum.local:8266
> [08:33:35][C][ota:101]: Using Password.
> [08:33:35][C][api:139]: API Server:
> [08:33:35][C][api:140]: Address: garage-controltemphum.local:6053
> [08:33:35][C][api:142]: Using noise encryption: YES
> [08:33:36][D][api:102]: Accepted 192.168.0.130
> [08:33:37][W][component:214]: Component api took a long time for an operation (0.29 s).
> [08:33:37][W][component:215]: Components should block for at most 20-30ms.
> [08:33:39][D][api.connection:1121]: Home Assistant 2023.12.4 (192.168.0.130): Connected successfully
> [08:33:43][D][dht:048]: Got Temperature=20.6°C Humidity=56.4%
> [08:33:43][D][sensor:093]: 'Temp': Sending state 20.60000 °C with 1 decimals of accuracy
> [08:33:43][D][sensor:093]: 'Humidity': Sending state 56.40000 % with 0 decimals of accuracy
> [08:33:53][D][dht:048]: Got Temperature=20.4°C Humidity=56.4%
> [08:33:53][D][sensor:093]: 'Temp': Sending state 20.40000 °C with 1 decimals of accuracy
> [08:33:53][D][sensor:093]: 'Humidity': Sending state 56.40000 % with 0 decimals of accuracy
After power cycling:
INFO ESPHome 2023.12.5
INFO Reading configuration /config/esphome/garage-controltemphum.yaml…
INFO Starting log output from garage-controltemphum.local using esphome API
WARNING Can’t connect to ESPHome API for garage-controltemphum.local: Error resolving IP address: [Errno -5] No address associated with hostname (APIConnectionError)
INFO Trying to connect to garage-controltemphum.local in the background
That is almost certainly an mDNS error. Every once in awhile my network gets in a state where one of my devices can’t do mDNS resolution, and ESPHome depends on that. On my Mac, often a reboot solves it.
Can you see the ESPHome device in HA? That might help you narrow down if it’s an issue with the device, your computer, or the network generally.
Tried rebooting Mac, router, and HA. The device shows as online on the ESPHome page but unavailable in States and Lovelace.
If you like, I can send the entire log of its activity when I program it (excluding the compiles). I don’t know if that would provide information for you.
[12:52:09][I][wifi:300]: WiFi Connecting to 'Brule'...
[12:52:09][W][wifi_esp8266:214]: wifi_apply_hostname_(garage-controltemphum): lwIP error -16 on interface st (index 0)
[12:52:09][W][wifi:618]: Error while connecting to network.
[12:52:09][I][wifi:300]: WiFi Connecting to 'Brule'...
[12:52:09][W][wifi_esp8266:214]: wifi_apply_hostname_(garage-controltemphum): lwIP error -16 on interface st (index 0)
As soon as I disconnect the DHT11 from the board everything works. I’ve tried two different GPIO pins (2, 14). Both bring the same results. I’m stumped.
The DHT data reads when logging through serial connection.
Does your router have an interface to be able to see if it is connected? Also you might try adding 'use_address: 192.168.x.x ’ to your wifi component and see if it connects.
That was it. I had to expand the number of available addresses on my DHCP server in my router. Strangely, even though I had 100 addresses available with 52 devices, I would lose a couple routinely. I don’t know if they try to renew their leases all at once but increasing the number solved it.