Since I use ESP devices on a lot of my Home Assistant nodes, I hope that someone here can help me.
I am stumped. I have a few Wemos D1 Mini boards that were working on the local WiFi yesterday. Today none of them will connect. More puzzling is that I can flash Tasmota on them and they all connect to the WiFi, but none with the same sketch that was working yesterday. I flashed the same code to a NodeMCU, and got the same results.
Looking at the WiFi.status(), it starts with “6=WL_DISCONNECTED” for a few seconds, then “1=WL_NO_SSID_AVAIL”.
(In normal operations, it would be 6 for a few seconds then “3=WL_CONNECTED”.)
Which is strange because
Nothing here changed from yesterday, and
The SSID is the same one that my PC, my Raspberry Pi’s, and a dozen devices around the house use.
I tried compiling the sketch on another PC, and got the same results.
Yes, I logged on as admin and rebooted the router.
Now, it gets interesting… I turned on a hotspot from my phone, and I can connect every time.
Again. Nothing changed in my IDE or my sketch from yesterday.
I am really at a loss to figure out what is wrong. Any tips would be appreciated.
Here is my WiFi setup code that hasn’t changed.
void setup_wifi() {
//Connect to WiFi network so we can reach the MQTT broker and publish messages to topics.
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(wifi_ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(wifi_ssid, wifi_password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print(F("WiFi connected, "));
Serial.print(F("IP address: "));
Serial.println(WiFi.localIP());
}
The home assistant forum probably isn’t the best place to get support for your custom sketches not connecting to wifi. You could try here: https://www.esp8266.com/viewforum.php?f=25
Or just use esphome and drop the custom sketch altogether.
Thanks- after three days of pulling my hair out trying to understand what was happening, I posted the question here in desperation. If I couldn’t get aNodeMCU or Wemos to connect to my net, my Home Assistant project plans were toast. I finally figured out a workaround.
I have determined that if I use ESP8266WiFi library Version 2.5.0 or later, all I get from WiFi.status() is WL_NO_SSID_AVAIL.
By reverting to ESP8266WiFi library Version 2.4.2, I can get a connection with the same sketch.
I barely understand YAML, and you want me to learn something new?
Actually, I either never heard of esphome or I assumed it was an alternative to Home Assistant.
I can’t use Tasmota for this particular project because I need the sleep mode of the esp on a Wemos.
However, I have Dr. Zzs video about esphome on my queue.
I have a bit of programming background- but pointers in C++ still confound me. I have some planned projects that Tasmota wouldn’t work with, so I will look into esphome. Don’t be surprised if I ask you for assistance.
Thanks for the links. I did install esphome to my Home Assistant, opened the UI and created a simple test, compiled it and downloaded the file test.bin. I used ‘esphomeflasher’ and flashed the binary to a Wemos D1 Mini. No errors so far. Then the Wemos restarted and attempted to connect to the local AP. Like my sketches using ESP8266WiFi library Version 2.5.0 or later, it won’t connect.
Watching the compile messages, I did see that esphome is including ESP8266WiFi- I expect the latest version. Which is the root of my problem.
Esphome looks like a good addition for my home IOT devices that Tasmota won’t work, but until I can get my sketches to work using the most recent version of ESP8266WiFi, it looks like I can’t use esphome, either.
Here is my console log:
Using 'COM33' as serial port.
Connecting....
Detecting chip type... ESP8266
Connecting....
Chip Info:
- Chip Family: ESP8266
- Chip Model: ESP8266EX
- Chip ID: 007F9099
- MAC Address: 80:7D:3A:7F:90:99
Uploading stub...
Running stub...
Stub running...
- Flash Size: 4MB
- Flash Mode: dout
- Flash Frequency: 40MHz
Erasing flash (this may take a while)...
Chip erase completed successfully in 5.4s
Compressed 326224 bytes to 227320...
Wrote 326224 bytes (227320 compressed) at 0x00000000 in 20.0 seconds (effective 130.4 kbit/s)...
Hash of data verified.
Leaving...
Hard Resetting...
Done! Flashing is complete!
Showing logs:
[22:36:04]{$
[22:36:04][C][ota:484]: There have been 2 suspected unsuccessful boot attempts.
[22:36:04][I][application:055]: Running through setup()...
[22:36:04][C][wifi:027]: Setting up WiFi...
[22:36:04][D][wifi:271]: Starting scan...
[22:36:10][D][wifi:286]: Found networks:
[22:36:10][I][wifi:321]: - 'Kaywinnet' (18:1B:EB:7B:0D:E2) ▂▄▆█
[22:36:10][D][wifi:322]: Channel: 1
[22:36:10][D][wifi:323]: RSSI: -68 dB
[22:36:10][D][wifi:325]: - 'DIRECT-WMRIVER-2msVV' (74:DA:38:8F:B2:7F) ▂▄▆█
[22:36:10][D][wifi:325]: - 'ESP_1AC4E4' (86:F3:EB:1A:C4:E4) ▂▄▆█
[22:36:10][D][wifi:325]: - '' (00:22:6C:87:E8:38) ▂▄▆█
[22:36:10][D][wifi:325]: - 'Cloutier' (00:7F:28:C1:53:CC) ▂▄▆█
[22:36:10][D][wifi:325]: - 'NETGEAR79' (9C:3D:CF:76:E3:68) ▂▄▆█
[22:36:10][I][wifi:167]: WiFi Connecting to 'Kaywinnet'...
[22:36:16][W][wifi:399]: Error while connecting to network.
[22:36:16][W][wifi:429]: Restarting WiFi adapter...
[22:36:16][I][wifi:167]: WiFi Connecting to 'Kaywinnet'...
[22:36:22][W][wifi:399]: Error while connecting to network.
[22:36:22][W][wifi:429]: Restarting WiFi adapter...
[22:36:27][D][wifi:271]: Starting scan...
This just keeps repeating:
[22:36:10][I][wifi:167]: WiFi Connecting to 'Kaywinnet'...
[22:36:16][W][wifi:399]: Error while connecting to network.
[22:36:16][W][wifi:429]: Restarting WiFi adapter...
[22:36:16][I][wifi:167]: WiFi Connecting to 'Kaywinnet'...
[22:36:22][W][wifi:399]: Error while connecting to network.
[22:36:22][W][wifi:429]: Restarting WiFi adapter...
If you have any other ideas, I am willing to try them.
I suspected that also, but I got a new upgraded router from my ISP (Verizon), and the results are exactly the same. Reverting to ESP8266WiFi library Version 2.4.2, I can get a connection every time.
I tried that, but the only options for the upload from esphome are OTA and /dev/tty. Esphome won’t find test.local for OTA because it’s a new Wemos device and esphome has not been flashed to it yet. And, of course, the PC doesn’t have a /dev folder. That’s why I used esphomeflasher.
I’ll try running the esphome UI on a browser on a Raspberry Pi (which does have /dev/tty devices).