edison0215
Published © GPL3+

Mini WiFi Scanner using OLED

Modifying code example for ESP32 WiFi Scanner to display on OLED instead of Serial Monitor

BeginnerProtip1,411
Mini WiFi Scanner using OLED

Things used in this project

Story

Read more

Schematics

Actual circuitry diagram of WiFi scanner and OLED.

ESP32 OLED
3V3 > VCC
GND > GND
D21 > SDA
D22 > SCA

Code

WiFi scanner coding

Arduino
#include "WiFi.h"
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(-1);



void setup()
{
    // Set WiFi to station mode and disconnect from an AP if it was previously connected
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);

    // initialize with the I2C addr 0x3C
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  

    // Clear the buffer.
    display.clearDisplay();
     display.setTextSize(2);
            display.setTextColor(WHITE);
            
            display.setCursor(0,28);
            display.println(" WIFI SCAN");
            display.display();
            delay(2000);
    
}

void loop()
{
    // WiFi.scanNetworks will return the number of networks found
    //MatchState ms;
    int n = WiFi.scanNetworks();
    String ssid[n];
    String rssi[n];
    if (n == 0) {
        Serial.println("no networks found");
    } else {
        Serial.print(n);
        Serial.println(" networks found");
        for (int i = 0; i < n; ++i) {
            // Print SSID and RSSI for each network found
            display.clearDisplay();
            ssid[i] = WiFi.SSID(i);
            rssi[i] = WiFi.RSSI(i);
        }
    }

     for (int i = 0; i < n; ++i) {
            display.setTextSize(1);
            display.setTextColor(WHITE);
            
            display.setCursor(0,14*i);
            String ssid2 = ssid[i];
            ssid2.replace("unifi", "u"); //I customize so that it the display format is in single line
            display.println(ssid2+":"+ rssi[i]);
            display.display();
            delay(100);
            
        }
}

Credits

edison0215

edison0215

0 projects • 2 followers

Comments