Use an ESP32 to get the best performance with your WiFi router.
For the best performance with your WiFi router, you should choose a wireless channel less used by any of your neighbors. Many routers use the same channel by default–e.g., 6–and unless you know to test for and change the Wi-Fi channel when you first install your router, you’re probably using the same channel as someone else nearby. In other words, decreased performance.
Here the script for the ESP32 to scan your neighborhood WiFi access points.
#include "WiFi.h" void setup(){ Serial.begin(57600); WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); } void loop(){ Serial.println("Start scan"); int n = WiFi.scanNetworks(); if (n == 0) { Serial.println("no networks found"); } else { Serial.print(n); Serial.println(" networks found"); for (int i = 0; i < n; ++i) { Serial.print(i + 1); Serial.print(": "); Serial.print(WiFi.SSID(i)); Serial.print(" ("); Serial.print(WiFi.RSSI(i)); Serial.print(") "); Serial.print(" ["); Serial.print(WiFi.channel(i)); Serial.print("] "); String encryptionTypeDescription = translateEncryptionType(WiFi.encryptionType(i)); Serial.println(encryptionTypeDescription); delay(10); } } Serial.println("Scan done"); Serial.println(""); delay(10000); } String translateEncryptionType(wifi_auth_mode_t encryptionType) { switch (encryptionType) { case (0): return "Open"; case (1): return "WEP"; case (2): return "WPA_PSK"; case (3): return "WPA2_PSK"; case (4): return "WPA_WPA2_PSK"; case (5): return "WPA2_ENTERPRISE"; default: return "UNKOWN"; } }
Here an example output from my neighborhood:
scan start
15 networks found
1: robnet2 (-54) [13] WPA2_PSK
2: woodfamily2 (-85) [2] WPA2_PSK
3: VGV7519DFC699 (-85) [6] WPA_WPA2_PSK
4: woodfamilyGuest (-86) [2] WPA2_PSK
5: FRITZ!Box 7581 MO (-87) [6] WPA2_PSK
6: Ziggo beneden (-89) [1] WPA2_PSK
7: Infinity (-89) [6] WPA_WPA2_PSK
8: Ziggo (-91) [1] WPA2_ENTERPRISE
9: Ziggo (-91) [11] WPA2_ENTERPRISE
10: Ziggo (-92) [1] WPA2_ENTERPRISE
11: Infinity (-92) [11] WPA2_PSK
12: FBI surveillance van (-93) [6] WPA_WPA2_PSK
13: Ziggo39330 (-94) [1] WPA2_PSK
14: Eightball's network (-94) [6] WPA2_PSK
15: DIRECT-8E-HP ENVY 4520 series (-96) [6] WPA2_PSK
scan done
Change the Wi-Fi Channel on Your Router
Once you know the wireless channel that’s least congested near you, head to your router’s administration page by typing in its IP address in the browser address bar. Depending on your router, this will likely be something like 192.168.2.1, 192.168.1.1, or 10.0.0.1 (check your router manual or the bottom of your router for details).
Head to your router’s wireless settings to change the Wi-Fi channel and hit apply for it to take effect.
See also my other page using the ESP8266 / Wemos D1 Mini as WiFi scanner
Hi, I tried your code hoping to scan all MAC addresses from surrounding WiFi access points.
I always get the error :
Using library WiFi at version 1.0 in folder: C:\Users\test\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\WiFi
exit status 1
enumeration value ‘WIFI_AUTH_MAX’ not handled in switch [-Werror=switch]
Please help to fix this error.
Thanks.
Wim
just add this to the end of the switch statement (after line 52):
default:
return “UNKOWN”;
Thank you for this, I need to be able to list the available routers for a clock I’m building, otherwise it will have to rely on an RTC, which seems to drift faster than I want. This is exactly what i need to start showing the networks so the user can choose one and give the password, which will then be coded and go into the NVRAM.
Works fine on DOIT ESP32 Devkit V1 with Arduino IDE ver 1.8.12
sinds core 2.0 esp32 should also support wpa3. Any idea how to change the code for this?