adonno / tagreader

Simple to build/use NFC tag reader, specially created for Home Assistant
https://adonno.com
GNU General Public License v3.0
1.13k stars 175 forks source link

Tag Reader not detected in Home Assistant: lwIP error -16 on interface st #258

Closed michaelstepner closed 2 months ago

michaelstepner commented 2 months ago

I resolved this issue with help from @adonno on Discord, but I want to document it here so that the solution is searchable.

Problem

[W][wifi_esp8266:212]: wifi_apply_hostname_(tagreader-19397a): lwIP error -16 on interface st (index 0)
[W][wifi_esp8266:482]: Event: Disconnected ssid='BELL063' bssid=[redacted] reason='Association Leave'
[W][wifi:588]: Error while connecting to network.
[W][wifi:624]: Restarting WiFi adapter...

Solution

I made two configuration changes, and I'm not sure which one was the key:

  1. I hardcoded the wifi configuration in the YAML configuration and disabled the captive_portal.
  2. I specified a Static IP, as advised by the ESPHome docs

The tag reader now connects without issue to my router (which remains on a mixed 5Ghz / 2.4Ghz configuration).

This post helped me debug the error I was encountering: https://community.home-assistant.io/t/cant-get-d1-mini-to-connect-to-wifi/249987?u=mstepner

Context

Initial problem

I received my tag reader today and have been trying to set it up, without success. The tag reader won't connect successfully to the wifi. I've tried reflashing it at: https://adonno.github.io/tagreader/

It flashes successfully, and I can connect to the tagreader AP to configure the wifi settings. But after doing so, it repeatedly fails to connect to the wifi with the following error:

[I][wifi:274]: WiFi Connecting to 'BELL063'...
[W][wifi:582]: Timeout while connecting to WiFi.
[I][wifi:274]: WiFi Connecting to 'BELL063'...
[W][wifi_esp8266:212]: wifi_apply_hostname_(tagreader-19397a): lwIP error -16 on interface st (index 0)
[W][wifi_esp8266:482]: Event: Disconnected ssid='BELL063' bssid=[redacted] reason='Association Leave'
[W][wifi:588]: Error while connecting to network.
[W][wifi:624]: Restarting WiFi adapter...

I also tried setting it up using the latest version of ESPHome (2024.3.x) by plugging it directly into my HA RPi and flashing it from the Home Assistant add-on, using the tagreader.yaml config. It flashed successfully there too, but also failed to connect to the wifi with the same error.

I also can't configure the wifi using same interface used to flash it on https://adonno.github.io/tagreader/ , I just receive an error message in red text saying "Unable to connect".

For what it’s worth, I was able to briefly connect to the wifi when I first set it up out of the box. I could see the tag reader appear on my router’s DHCP table and I got a notification in home assistant that a new device was detected. But it disconnected almost immediately and would not reconnect to home assistant. (I’ve since flashed it multiple times and didn’t even get it detected in HA)

Second status update

  1. In my router settings, I can see the tagreader is connected via 2.4ghz:

IMG_0693 (1)

  1. If I manually try to add the device in HA using "Add Integration" > ESPHome > enter IP address, I get an error:

image

  1. HA doesn't give me a notification that a new device was discovered. (It did when I first configured the tagreader, but not since I tried reflashing it.)

  2. Using the serial interface to see the logs, I still see the same "lwIP error -16" in the logs.

[I][wifi:274]: WiFi Connecting to 'BELL063'...
[W][wifi_esp8266:212]: wifi_apply_hostname_(tagreader-19397a): lwIP error -16 on interface st (index 0)
[W][wifi:588]: Error while connecting to network.
[I][wifi:274]: WiFi Connecting to 'BELL063'...
[W][wifi_esp8266:212]: wifi_apply_hostname_(tagreader-19397a): lwIP error -16 on interface st (index 0)
[W][wifi:582]: Timeout while connecting to WiFi.
  1. Despite the fact that my router shows the tagreader as connected, the tagreader launches the fallback AP.
[I][wifi:274]: WiFi Connecting to 'BELL063'...
[W][wifi_esp8266:212]: wifi_apply_hostname_(tagreader-19397a): lwIP error -16 on interface st (index 0)
[I][wifi:153]: Starting fallback AP!
[C][wifi:227]: Setting up AP...
[C][wifi:229]:   AP SSID: 'tagreader'
[C][wifi:230]:   AP Password: ''
[C][wifi:239]:   IP Address: 192.168.4.1
[W][wifi:582]: Timeout while connecting to WiFi.
[I][wifi:274]: WiFi Connecting to 'BELL063'...
[W][wifi_esp8266:212]: wifi_apply_hostname_(tagreader-19397a): lwIP error -16 on interface st (index 0)
[W][wifi_esp8266:482]: Event: Disconnected ssid='BELL063' bssid=[redacted] reason='Association Leave'
[W][wifi:588]: Error while connecting to network.