Output Problem with Wi-Fi scan on Arduino IDE

Freaknyou
Posts: 2
Joined: Wed Dec 06, 2023 5:09 pm

Output Problem with Wi-Fi scan on Arduino IDE

Postby Freaknyou » Wed Dec 06, 2023 5:24 pm

I want to scan all avaible wi-fi with my ESP-WROOM-32, i can upload this code to the board without problem

Code: Select all

#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);
}
but this is the output that i get on the serial monitor
Attachments
Capture d’écran (38) copie.png
What can cause this?
Capture d’écran (38) copie.png (53.81 KiB) Viewed 3505 times

ESP_Sprite
Posts: 9729
Joined: Thu Nov 26, 2015 4:08 am

Re: Output Problem with Wi-Fi scan on Arduino IDE

Postby ESP_Sprite » Thu Dec 07, 2023 12:52 am

Your ESP32 is set to 115200 baud, but your terminal is set to 9600 baud. Change one of the two.

Freaknyou
Posts: 2
Joined: Wed Dec 06, 2023 5:09 pm

Re: Output Problem with Wi-Fi scan on Arduino IDE

Postby Freaknyou » Thu Dec 07, 2023 8:26 am

ESP_Sprite wrote:
Thu Dec 07, 2023 12:52 am
Your ESP32 is set to 115200 baud, but your terminal is set to 9600 baud. Change one of the two.
It works now thx

Who is online

Users browsing this forum: No registered users and 63 guests