Mini WiFi Scanner using OLED

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

 

Mini WiFi Scanner using OLED

Things used in this project

 

Hardware components

HARDWARE LIST
1 DFRobot FireBeetle ESP32 IOT Microcontroller (Supports Wi-Fi & Bluetooth)
1 Graphic OLED, 128 x 64
4 Jumper wires (generic)
1 Arduino UNO

Software apps and online services

 

Arduino IDE

 

Story

 

The codes generated from this project is by modifying code of others (The reference link is attached below). It comes to my mind when I learn about how to use esp32. From the blog, the WiFi scanner data is displayed via Serial monitor. I am thinking "Hmm.. can I just try to display it on OLED, to make it cuter and cooler?" With some times of learning, eventually I have made it >w<

 

From the website I referred, it is using a 38 pins of ESP32 to realize the project. Instead, I am using a 30 pins of ESP32, so the GPIOs may be different. What I learnt from this project is that, you may refer to the datasheet to understand each pin functionality.

You may also try working with arduino Uno instead of esp32 by browsing through the net!

Schematics

 

Actual circuitry diagram of WiFi scanner and OLED.

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

 

Code

 

WiFi scanner coding

Arduino

CODE
#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);
            
        }
}

The article was first published in hackster, December 16, 2022

cr: https://www.hackster.io/edison0215/mini-wifi-scanner-using-oled-42a7a7

author: edison0215

License
All Rights
Reserved
licensBg
0