WIFI

WIFI Scan

Using the ESP32, you can effortlessly perform a Wi-Fi scan to identify nearby wireless networks. This scan provides essential information including the SSID (network name), the channel each network operates on, and, most importantly, the signal strength (RSSI) of each network.

By analyzing the Wi-Fi scan results, you can assess the performance of different antennas with your ESP32 IPEX board. This allows you to make an informed decision on the most suitable antenna for your specific application, ensuring optimal connectivity and performance.

RSSI

RSSI (Received Signal Strength Indicator) is a measure of the power level of a received signal. It is commonly used in wireless communications to gauge the strength of a radio signal received by a device (ESP32).

RSSI values are typically represented as negative numbers. For instance, 0 dBm represents the reference power level, and values like -30 dBm or -60 dBm represent power levels lower than this reference. The more negative the value, the weaker the signal. The closer the RSSI value is to zero, the stronger the signal. For example, -30 dBm is stronger than -60 dBm.

For example, - -30dBm: Indicates a very strong signal close to the device. - -60dBm: Represents a moderate signal strength, typically usable but not ideal. - -90dBm: Indicates a very weak signal, likely to result in poor connectivity or intermittent drops.

Code

 1/*
 2
 3The following ESP32 code performs a Wi-Fi network scan and outputs the SSID, channel, 
 4and signal strength (RSSI) of detected networks to the Serial Monitor. 
 5
 6Support the creation of high-quality ESP32 tutorials by purchasing 
 7from Lonely Binary at www.lonelybinary.com.
 8
 9ESP32 IPEX External Antenna Board
10https://lonelybinary.com/products/esp32-ipex
11
12ESP32-S3 IPEX External Antenna Board
13https://lonelybinary.com/products/esp32-s3-ipex
14
15*/
16
17#include <Arduino.h>
18#include "WiFi.h"
19
20void setup() {
21  Serial.begin(115200);
22
23  // Set WiFi to station mode and disconnect from an AP if it was previously connected.
24  WiFi.mode(WIFI_STA);
25  WiFi.disconnect();
26  delay(100);
27
28}
29
30void loop() {
31  Serial.println("Scan start");
32
33  // WiFi.scanNetworks will return the number of networks found.
34  int n = WiFi.scanNetworks();
35
36  Serial.println("Scan done");
37
38  if (n == 0) {
39    Serial.println("no networks found");
40  } else {
41    Serial.print(n);
42    Serial.println(" networks found");
43    Serial.println("Nr | SSID                             | RSSI | CH");
44    for (int i = 0; i < n; ++i) {
45      // Print SSID and RSSI for each network found
46      Serial.printf("%2d", i + 1);
47      Serial.print(" | ");
48      Serial.printf("%-32.32s", WiFi.SSID(i).c_str());
49      Serial.print(" | ");
50      Serial.printf("%4ld", WiFi.RSSI(i));
51      Serial.print(" | ");
52      Serial.printf("%2ld", WiFi.channel(i));
53      Serial.println();
54      delay(10);
55    }
56  }
57  Serial.println("");
58
59  // Delete the scan result to free memory for code below.
60  WiFi.scanDelete();
61
62  // Wait a bit before scanning again.
63  delay(5000);
64}
WIFI Scan Result