2

Maybe this is a dumb question, but is there a way to test for wrong Wifi password?

I know you can do WL_CONNECT to check if the password works, but is there a command for checking if the password is wrong? Not just by waiting.

dda
1,5951 gold badge12 silver badges17 bronze badges
asked Oct 15, 2019 at 18:54
6
  • my esp is trying to connect to the WiFi Commented Oct 15, 2019 at 19:20
  • i guess that makes my esp client Commented Oct 15, 2019 at 19:21
  • github.com/esp8266/Arduino/blob/… Commented Oct 16, 2019 at 5:05
  • there's no way to tell if a password is right or wrong other than by trying to use it. Commented Oct 16, 2019 at 16:13
  • @dandavis but the WiFi class does not return the info even though it's available. It simply returns an error. Commented Oct 16, 2019 at 17:54

2 Answers 2

3

The information is available on SDK level. If you include #include "user_interface.h", you can use function wifi_station_get_connect_status(). It returns one of:

STATION_GOT_IP
STATION_NO_AP_FOUND
STATION_CONNECT_FAIL
STATION_WRONG_PASSWORD
STATION_IDLE

The WiFi.status() function uses function wifi_station_get_connect_status(), but returns WL_CONNECT_FAILED for STATION_WRONG_PASSWORD.

answered Oct 16, 2019 at 18:13
0

one can check for wrong password using the following code snippet

 if (WiFi.status() == WL_CONNECTED)
 {
 Serial.println("Connected successfully");
 }
 else if (WiFi.status() == WL_NO_SSID_AVAIL) 
 {
 Serial.println("Wifi network is not avaliable");
 }
 else
 {
 Serial.println("Password is not correct");
 }

more information can be found on GitHub here: https://github.com/aeonSolutions/aeonlabs-ESP32-C-Base-Firmware-Libraries

Juraj
18.3k4 gold badges31 silver badges49 bronze badges
answered Jan 3, 2024 at 19:06
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.