esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
16.07k stars 13.33k forks source link

ESP8266 Can't connect to WIFI network and can't work as access point #8520

Open mohamedsemz opened 2 years ago

mohamedsemz commented 2 years ago

Problem Description

I used the WiFiAccessPoint example and I couldn't find the network using both laptop and mobile phone.

I tried to run the WiFiScan example to check if the hardware is working or not. The ESP couldn't find my wifi, phone hotspot. But it only finds mobile hotspot created from laptop. I checked the router and confirmed that the router is working on 2.4 GHz not 5 GHz.

I tried the HelloServer example with my wifi network name (which is couldn't be found in the Scan example) and the status is WL_DISCONNECTED for sometime and then WL_NO_SSID_AVAIL.

I tried the HelloServer example with hotspot created from the laptop (which is found in the Scan example) and the status is WL_DISCONNECTED for sometime and then WL_CONNECT_FAILED.

What is the issue and how to fix it ? Or how o debug this kind of issues ?

Note: I'm using Core version 3.0.2, Nodemcu with ESP8266 and Arduino IDE. I also tested 3.0.0, 2.7.2, 2.4.2 and all of them not working too.

mohamedsemz commented 2 years ago

I enabled the debugging and when running the AP example I get 20:10:38.091 -> Configuring access point...fpm close 3 20:10:38.091 -> mode : softAP(32:83:98:a5:34:f3) 20:10:38.091 -> add if1 20:10:38.091 -> dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1) 20:10:38.091 -> bcn 100 20:10:38.982 -> bcn 0 20:10:38.982 -> del if1 20:10:38.982 -> usl 20:10:38.982 -> add if1 20:10:38.982 -> dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1) 20:10:38.982 -> bcn 100 20:10:38.982 -> Awifi evt: 8 20:10:38.982 -> P IP address: 192.168.4.1 20:10:38.982 -> HTTP server started

and in HelloServer 20:19:07.653 -> scandone 20:19:08.544 -> state: 0 -> 2 (b0) 20:19:08.544 -> state: 2 -> 3 (0) 20:19:08.544 -> state: 3 -> 5 (10) 20:19:08.544 -> add 0 20:19:08.544 -> aid 1 20:19:08.544 -> cnt 20:19:18.541 -> pm open,type:2 0 20:19:18.541 -> state: 5 -> 0 (2) 20:19:18.541 -> rm 0 20:19:18.541 -> pm close 7 20:19:18.541 -> reconnect 20:19:18.541 -> wifi evt: 1 20:19:18.587 -> STA disconnect: 204 20:19:18.667 -> scandone 20:19:18.667 -> state: 0 -> 2 (b0) 20:19:18.667 -> state: 2 -> 3 (0) 20:19:18.716 -> state: 3 -> 5 (10) 20:19:18.716 -> add 0 20:19:18.716 -> aid 1 20:19:18.716 -> cnt 20:19:28.683 -> pm open,type:2 0 20:19:28.683 -> state: 5 -> 0 (2) 20:19:28.683 -> rm 0 20:19:28.683 -> pm close 7 20:19:28.683 -> reconnect 20:19:28.683 -> wifi evt: 1 20:19:28.683 -> STA disconnect: 204 20:19:28.824 -> scandone 20:19:28.824 -> state: 0 -> 2 (b0) 20:19:28.824 -> state: 2 -> 3 (0) 20:19:28.824 -> state: 3 -> 5 (10) 20:19:28.824 -> add 0 20:19:28.824 -> aid 1 20:19:28.824 -> cnt 20:19:38.860 -> pm open,type:2 0 20:19:38.860 -> state: 5 -> 0 (2) 20:19:38.860 -> rm 0 20:19:38.860 -> pm close 7 20:19:38.860 -> reconnect 20:19:38.860 -> wifi evt: 1 20:19:38.860 -> STA disconnect: 204 20:19:38.953 -> scandone 20:19:38.953 -> state: 0 -> 2 (b0) 20:19:39.938 -> state: 2 -> 0 (2) 20:19:39.938 -> reconnect 20:19:39.938 -> wifi evt: 1 20:19:39.984 -> STA disconnect: 2 20:19:40.078 -> scandone 20:19:40.078 -> state: 0 -> 2 (b0) 20:19:40.078 -> state: 2 -> 3 (0) 20:19:40.078 -> state: 3 -> 5 (10) 20:19:40.078 -> add 0 20:19:40.078 -> aid 1 20:19:40.078 -> cnt

lorerave85 commented 2 years ago

I have a very similar problem:

the same code that I use regularly for other esp8266 (and that work) has stopped working and now going to debug it no longer sees any wifi network.

i installed arduino IDE 1.8.19 on my new mac with M1 processor, and it doesn't seem to work anymore.

core version 3.0.2 which has been standing still for almost a year.

d-a-v commented 2 years ago

Did you try the option "erase flash > all flash content" ?

mohamedsemz commented 2 years ago

I still have the same issue and didn't fix it yet.

Did you try the option "erase flash > all flash content" ?

I tried it back then and had the same issue.

lorerave85 commented 2 years ago

I tested all core versions from 2.4 up to 3.0.2. every time I erased everything. today I try with an external power supply, maybe the USBC-USB-ESP8266 adapter can't power it

mohamedsemz commented 2 years ago

I tested all core versions from 2.4 up to 3.0.2. every time I erased everything. today I try with an external power supply, maybe the USBC-USB-ESP8266 adapter can't power it

It's good idea. I didn't try external power supply. Let us know the result.

lorerave85 commented 2 years ago

no change, same error: no SSID found

voblaunsane commented 2 years ago

same problem, running this basic code does not set a SSID nor does it set a password. what's going on? erasing all contents; usually powering from PC usb, but also tried 2A wall chargers with same results..

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

void handleRoot() {
  server.send(200, "text/html", "<h1>You are connected</h1>");
}

void setup() {
  delay(1000);
  Serial.setDebugOutput(true);
  Serial.begin(115200);

  WiFi.softAP("ESPap", "thereisnospoon");

  server.on("/", handleRoot);
  server.begin();

  WiFi.printDiag(Serial);
}

void loop() {
  server.handleClient();
}
SDK:2.2.2-dev(38a443e)/Core:3.0.2=30002000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:6105635
fpm close 3 
mode : softAP(26:a1:60:3a:b7:98)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
bcn 0
del if1
usl
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
Mwifi evt: 8
ode: AP
PHY mode: N
Channel: 1
AP id: 0
Status: 255
Auto connect: 1
SSID (0): 
Passphrase (0): 
BSSID set: 0

config: https://i.postimg.cc/GhcP23ZJ/Untitled.jpg

lorerave85 commented 2 years ago

I made an even simpler test with the example of the CORE 3.0.2 library - ESP8266WiFi.h WifiScan.ino

result: wemos d1 mini (on the right): everything ok wemos d1 mini v3 (on the left): cannot find any networks

WhatsApp Image 2022-07-04 at 12 50 43

I begin to think that it is version 3 of the wemos that has something wrong, there must be some incompatibility. All wemos old versions work

voblaunsane commented 2 years ago

I've got this one:

IMG_20220704_155749

It came with the manual where it says to choose "Generic ESP8266 Module" board option. It used to work very well a few years back, but I couldn't make it work yesterday... Thanks to pictures @lorerave85 posted, I noticed "D1 mini" written on the corner of my board, so I picked "LOLIN(WEMOS) D1 mini (clone)" and this solved my problem. The code is working now. Thank you!

It turns out RTFM, but don't fcuking trust it. lol