WiFi not connecting Authentication failed

Been following esp home for a while and finally decided to give it a go over using Arduino IDE.
How hard can it be.

I am using the Hassio addon on a raspberry pi. Worked through the set up and writing my first program.(Just connecting to WiFi with ota and admin passwords.)

Using a nodemcu V1

Seems to compile and program ok but will not connect to WiFi just keeps cycling through connected, authenticating, disconnected authentication failed

Board works when programmed with Arduino IDE

Any ideas

It’d help more if we can see the logs and/or errors.
There might be more eyes to see your details and perhaps oversights.

Will post some logs later tonight when I get home.

Well don’t you know it.

Ran it again to got the logs. It started in a similar way and then just seemed to work.

Here are the logs anyway in case they tell you anything.

Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB0 with baud rate 115200
[19:52:17][I][logger:116]: Log initialized
[19:52:17][C][ota:364]: There have been 6 suspected unsuccessful boot attempts.
[19:52:17][I][app:028]: Running through setup()...
[19:52:17][C][wifi:029]: Setting up WiFi...
[19:52:17][D][wifi:272]: Starting scan...
[19:52:23][D][wifi:287]: Found networks:
[19:52:23][I][wifi:322]: - 'xxx' [redacted]▂▄▆█
[19:52:23][D][wifi:323]:     Channel: 11
[19:52:23][D][wifi:324]:     RSSI: -25 dB
[19:52:23][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[19:52:23][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[19:52:23][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[19:52:23][I][wifi:164]: WiFi Connecting to 'xxx'...
[19:52:24][W][wifi_esp8266:354]: Event: Disconnected ssid='xxx' bssid=AC:84:C6:21:25:68 reason='Authentication Failed'
[19:52:24][W][wifi:400]: Error while connecting to network.
[19:52:24][W][wifi:431]: Restarting WiFi adapter...
[19:52:24][I][wifi:164]: WiFi Connecting to 'xxx'...
[19:52:25][W][wifi_esp8266:354]: Event: Disconnected ssid='xxx' bssid=AC:84:C6:21:25:68 reason='Authentication Failed'
[19:52:25][W][wifi:400]: Error while connecting to network.
[19:52:25][W][wifi:431]: Restarting WiFi adapter...
[19:52:30][D][wifi:272]: Starting scan...
[19:52:36][D][wifi:287]: Found networks:
[19:52:36][I][wifi:322]: - 'xxx' [redacted]▂▄▆█
[19:52:36][D][wifi:323]:     Channel: 11
[19:52:36][D][wifi:324]:     RSSI: -23 dB
[19:52:36][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[19:52:36][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[19:52:36][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[19:52:36][I][wifi:164]: WiFi Connecting to 'xxx'...
[19:52:38][I][wifi:380]: WiFi connected!
[19:52:38][C][wifi:254]:   SSID: [redacted]
[19:52:38][C][wifi:255]:   IP Address: 192.168.1.136
[19:52:38][C][wifi:257]:   BSSID: [redacted]
[19:52:38][C][wifi:258]:   Hostname: 'test1'
[19:52:38][C][wifi:262]:   Signal strength: -29 dB ▂▄▆█
[19:52:38][C][wifi:263]:   Channel: 11
[19:52:38][C][wifi:264]:   Subnet: 255.255.255.0
[19:52:38][C][wifi:265]:   Gateway: 192.168.1.1
[19:52:38][C][wifi:266]:   DNS1: 192.168.1.1
[19:52:38][C][wifi:267]:   DNS2: 0.0.0.0
[19:52:38][C][ota:029]: Over-The-Air Updates:
[19:52:38][C][ota:030]:   Address: test1.local:8266
[19:52:38][C][ota:032]:   Using Password.
[19:52:38][W][ota:036]: Last Boot was an unhandled reset, will proceed to safe mode in 4 restarts
[19:52:38][C][api:030]: Setting up Home Assistant API server...
[19:52:38][I][app:060]: setup() finished successfully!
[19:52:38][I][app:096]: esphome version 1.13.6 compiled on Jul  8 2019, 19:50:54
[19:52:38][C][wifi:372]: WiFi:
[19:52:38][C][wifi:254]:   SSID: [redacted]
[19:52:38][C][wifi:255]:   IP Address: 192.168.1.136
[19:52:38][C][wifi:257]:   BSSID: [redacted]
[19:52:38][C][wifi:258]:   Hostname: 'test1'
[19:52:38][C][wifi:262]:   Signal strength: -29 dB ▂▄▆█
[19:52:38][C][wifi:263]:   Channel: 11
[19:52:38][C][wifi:264]:   Subnet: 255.255.255.0
[19:52:39][C][wifi:265]:   Gateway: 192.168.1.1
[19:52:39][C][wifi:266]:   DNS1: 192.168.1.1
[19:52:39][C][wifi:267]:   DNS2: 0.0.0.0
[19:52:39][C][logger:137]: Logger:
[19:52:39][C][logger:138]:   Level: DEBUG
[19:52:39][C][logger:139]:   Log Baud Rate: 115200
[19:52:39][C][logger:140]:   Hardware UART: UART0
[19:52:39][C][ota:029]: Over-The-Air Updates:
[19:52:39][C][ota:030]:   Address: test1.local:8266
[19:52:39][C][ota:032]:   Using Password.
[19:52:39][W][ota:036]: Last Boot was an unhandled reset, will proceed to safe mode in 4 restarts
[19:52:39][C][api:103]: API Server:
[19:52:39][C][api:104]:   Address: test1.local:6053
[19:54:17][I][ota:046]: Boot seems successful, resetting boot loop counter.

I have remover the actual wifi name and replaced with xxx

Tried a second nodemcu and we are back where we started

21:09:54][W][wifi:400]: Error while connecting to network.
[21:09:54][W][wifi:431]: Restarting WiFi adapter...
[21:10:00][D][wifi:272]: Starting scan...
[21:10:05][D][wifi:287]: Found networks:
[21:10:05][I][wifi:322]: - 'xxx' [redacted]▂▄▆█
[21:10:05][D][wifi:323]:     Channel: 11
[21:10:05][D][wifi:324]:     RSSI: -60 dB
[21:10:05][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[21:10:05][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[21:10:05][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[21:10:05][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[21:10:05][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[21:10:06][D][wifi:326]: - [redacted] [redacted]▂▄▆█
[21:10:06][I][wifi:164]: WiFi Connecting to 'xxx'...
[21:10:06][W][wifi_esp8266:354]: Event: Disconnected ssid='xxx' bssid=AC:84:C6:21:25:68 reason='Authentication Failed'
[21:10:06][W][wifi:400]: Error while connecting to network.
[21:10:06][W][wifi:431]: Restarting WiFi adapter...
[21:10:06][I][wifi:164]: WiFi Connecting to 'xxx'...
[21:10:06][W][wifi_esp8266:354]: Event: Disconnected ssid='xxx' bssid=AC:84:C6:21:25:68 reason='Authentication Failed'
[21:10:06][W][wifi:400]: Error while connecting to network.
[21:10:06][W][wifi:431]: Restarting WiFi adapter...
[21:10:12][D][wifi:272]: Starting scan...

It seems that is not able to connect. Perhaps password changed.

Looks like a password error indeed.

Definitely not a password error. Double checked but I have seen them connect.

I now have 2 nodemcus set up
test1:- the one programmed with the logs above that were sucsessful. Now being powered from a USB charger
and
test2:- I have seen this on online briefly. This is still connected to the USB port on the raspberry pi

Both behave the same and are sometimes connected but more often show as offline and cant be contacted.

Any more ideas.

What about power glitches?
Try to supply the devices from outside the USB. Just for a test. I suppose that the maximum that the RPi’s USB port is giving is the standard 250 mA. I saw other modules (like HC-06) having pick of 0.5 A.

Device connected to 2.1A charger still has the problem.

In the same setup but programmed using code from auduino IDE there seems to be no such problem.