In this tutorial, you’ll learn how to find the ESP32 WiFi signal strength of a specific network. And we’ll discuss how to get the RSSI (Received Signal Strength Indicator) value and use it to judge the WiFi signal strength.
Before proceeding with this tutorial, you should have installed the ESP32 Arduino Core in your Arduino IDE to be able to compile and build projects for ESP32 in Arduino IDE. Follow the tutorial below to get started if you haven’t done that already.
If you’re just starting with ESP32, it’s highly recommended to begin with the following tutorial to kickstart your journey with ESP32 microcontrollers. Then, go to the second link which directs you to the main page for ESP32 Tutorials Series, where you’ll find all ESP32 tutorials ordered and categorized in a logical way that guarantees you systematic progress in learning ESP32 programming and IoT.
Table of Contents
ESP32 WiFi Signal Strength
For checking the WiFi signal strength of a specific network with ESP32, we’ll be using the WiFi.h library which is built-in already in Arduino core. We just need to include the library.
There is a provided example for ESP32 WiFi network scanning that can also be used to get the WiFi signal strength for each of the nearby WiFi networks. Open File > Examples > WiFi > WiFiScan sketch.
Here is the full code listing of this example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
/* * ESP32 WiFi Scanner Example. Examples > WiFi > WiFiScan * Full Tutorial @ https://deepbluembedded.com/esp32-wifi-library-examples-tutorial-arduino/ */ #include "WiFi.h" void setup() { Serial.begin(115200); // Set WiFi to station mode and disconnect from an AP if it was previously connected. WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); Serial.println("Setup done"); } void loop() { Serial.println("Scan start"); // WiFi.scanNetworks will return the number of networks found. int n = WiFi.scanNetworks(); Serial.println("Scan done"); if (n == 0) { Serial.println("no networks found"); } else { Serial.print(n); Serial.println(" networks found"); Serial.println("Nr | SSID | RSSI | CH | Encryption"); for (int i = 0; i < n; ++i) { // Print SSID and RSSI for each network found Serial.printf("%2d",i + 1); Serial.print(" | "); Serial.printf("%-32.32s", WiFi.SSID(i).c_str()); Serial.print(" | "); Serial.printf("%4d", WiFi.RSSI(i)); Serial.print(" | "); Serial.printf("%2d", WiFi.channel(i)); Serial.print(" | "); switch (WiFi.encryptionType(i)) { case WIFI_AUTH_OPEN: Serial.print("open"); break; case WIFI_AUTH_WEP: Serial.print("WEP"); break; case WIFI_AUTH_WPA_PSK: Serial.print("WPA"); break; case WIFI_AUTH_WPA2_PSK: Serial.print("WPA2"); break; case WIFI_AUTH_WPA_WPA2_PSK: Serial.print("WPA+WPA2"); break; case WIFI_AUTH_WPA2_ENTERPRISE: Serial.print("WPA2-EAP"); break; case WIFI_AUTH_WPA3_PSK: Serial.print("WPA3"); break; case WIFI_AUTH_WPA2_WPA3_PSK: Serial.print("WPA2+WPA3"); break; case WIFI_AUTH_WAPI_PSK: Serial.print("WAPI"); break; default: Serial.print("unknown"); } Serial.println(); delay(10); } } Serial.println(""); // Delete the scan result to free memory for code below. WiFi.scanDelete(); // Wait a bit before scanning again. delay(5000); } |
This example is particularly useful when you try to connect to a nearby network but keeps failing. This WiFi scanner example will show you the signal strength of each WiFi network within the ESP32 range. The RSSI (Received Signal Strength Indicator) is what you’re looking for if you’d like to know the signal strength of each nearby network.
The function WiFi.scanNetworks() is used to handle the core logic of WiFi scanning and it returns the total number of networks found.
1 |
int n = WiFi.scanNetworks(); |
At this point, you’ll have the number of found networks nearby and you can access any of the following parameters of each network.
- SSID
- RSSI
- Channel
- EncryptionType
To get & print the SSID of any found network in the list, call the following function WiFi.SSID(i) and pass to it the index of the found network.
1 |
Serial.print(WiFi.SSID(i)); |
To get and print the RSSI (Received Signal Strength Indicator), use the WiFi.RSSI(i) function as shown below.
1 |
Serial.print(WiFi.RSSI(i)); |
Which gives you an estimated signal strength value for any surrounding network you’ve found while scanning.
And this is the result of running the ESP32 WiFi Scanner sketch on my board.
And I can definitely confirm that my home router WiFi has the strongest signal as it’s in the next room, followed by my other router on another floor which has a bit weaker signal as we can expect. So we can conclude this topic and move to the next which is trying to connect to an existing WiFi network with ESP32.
ESP32 RSSI WiFi (Signal Strength Indicator)
The RSSI (Received Signal Strength Indicator) can be checked by the ESP32 to determine the WiFi connection strength between the ESP32 and the specific WiFi network you’re trying to connect to (e.g. home router or any access point). This can be useful in case you’re having some issues with the WiFi connection or keeps disconnecting sporadically.
You can then check the RSSI for the network you’re working with and judge if the WiFi signal power needs adjusting or if you simply need to place the ESP32 board a little closer to the access point.
Generally speaking, the lower the RSSI value, the weaker the signal is, and vice versa. The range for RSSI value is from 0 down to -120 dBm. Having a 0 dBm is hard to achieve and it means you’ve got an amazingly strong connection. And low values from -90 down to -120 dBm are unusable at all.
ESP32 WiFi Signal Strength RSSI Rating
RSSI is an estimated measure of the WiFi signal strength for a specific network (router or access point). The return value has the following form and unit (-x dBm). Which means a lower absolute value indicates a more powerful connection. Here’s how to judge the RSSI value and decide on the signal strength rating:
RSSI Value Range | WiFi Signal Strength | |
RSSI > -30 dBm | Amazing | |
RSSI < – 55 dBm | Very good signal | |
RSSI < – 67 dBm | Fairly Good | |
RSSI < – 70 dBm | Okay | |
RSSI < – 80 dBm | Not good | |
RSSI < – 90 dBm | Extremely weak signal (unusable) |
Parts List
Here is the full components list for all parts that you’d need in order to perform the practical LABs mentioned here in this article and for the whole ESP32 series of tutorials found here on DeepBlueMbedded. Please, note that those are affiliate links and we’ll receive a small commission on your purchase at no additional cost to you, and it’d definitely support our work.
Concluding Remarks
To conclude this tutorial, we’ll highlight the fact that the ESP32 WiFi signal strength is affected by the distance between your ESP32 board and the access point you’re trying to connect to. If there is any obstacle between the ESP32 and the AP this will also reduce the WiFi signal strength, especially if the obstacle contains a conductor material that will attenuate the RF signals and contribute to a smaller RSSI value at the end.
If you’re just starting to learn about ESP32 WiFi, it’s highly recommended that you follow the tutorial below and keep it bookmarked in your browser. It is crafted specifically to help beginners with ESP32 WiFi to know everything about this huge topic and draw a clear roadmap for what to learn in a systematic way.
You can easily get overwhelmed when starting with ESP32 WiFi by the number of topics and libraries out there (e.g HTTP, TCP/IP, UDP, WebServers, AsyncWebServers, WebSocket, MQTT, ESP-NOW, etc…). There are too many libraries, modes, topologies, and protocols that make just getting started an even harder task than it should be. And the most reasonable question is where should I get started? The guide below is the perfect answer!
This is the ultimate guide for ESP32 WiFi, if you’re just starting with ESP32 WiFi, you should definitely check it out. It’ll provide you with a clear roadmap for what to learn and in which order to fully understand everything about ESP32 WiFi.