ESP32 WiFi scanner iotXplain project

Ok, I know, really, another ESP32 WiFi Scanner.

Well lets just say, start to finish it’s simple, straight forward and of course, works.

This little project shows a few basic concepts, only has 4 wires, and construction cost is quite low.

Because of my Visual Disability, I printout pin diagrams and stick them to the breadboards, then use the wording to make it easier to identify inter wiring between components. This combined with magnification makes it a lot easier for those of us who have very little vision distance or color.  Simple but effective.

The parts needed….

www.aliexpress.com

1 Pcs New 400 Tie Points Solderless PCB Breadboard Mini Universal Test Protoboard DIY Bread Board for Bus Test Circuit Board
ESP32 ESP-32 ESP32S ESP-32S CP2102 Wireless WiFi Bluetooth Development Board Micro USB Dual Core Power Amplifier Filter Module
0.96 inch IIC Serial White OLED Display Module 128X64 I2C SSD1306 12864 LCD Screen Board GND VCC SCL SDA 0.96″ for Arduino Black
120pcs 40P 10cm male to male, female to male, and female to female dupont cable connector breadboard jumper wires

Below we see the Fritzing diagram for the build. Again all fairly simple.

The big things to note,

SCL pin from the OLED goes to GPIO 22 on the ESP32

SDA pin from the OLED goes to GPIO21 on the ESP32

VCC in this case is 3.3v

GND goes to GND

Now for the Code that does all the magic,

NOTE ………..

This assumes you have an Arduino IDE setup and working for ESP32 development boards.

// ***********************************************************
// ESP32 generic wifi scanner code
// by al mcdivitt iotXplain cr 2019
// iotxplain.com.au
//
//***********************************************************

#include "WiFi.h"
#include "Wire.h"
#include "SSD1306.h"

SSD1306 display (0x3c, 21, 22);
// SDA on 21 SCL on 22
void setup()
{
    Serial.begin(115200);
    
   
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);
    Serial.println("Setup done");

    display.init();
    display.flipScreenVertically ();
    display.clear();
    display.setTextAlignment (TEXT_ALIGN_LEFT);
    display.setFont(ArialMT_Plain_10);
}

void loop()
{
    Serial.println("scan start");
    display.setColor(BLACK);
    display.fillRect(0,0,127,10);
    display.setColor(WHITE);
    display.drawString(0, 0, "Scanning...     ");
    display.display();
    
    // number of networks
    int n = WiFi.scanNetworks();
    display.clear();
    display.drawString(0, 0, "Scan results:");
    display.display();    
    if (n == 0) {
      display.drawString(0,10,"No networks found");
    } else {
             for (int i = 0; i < n; ++i) {
                String data = String(WiFi.SSID(i));
             display.drawString( 0 , i*10+18  , data.substring(0,20));
             display.drawString( 105 , i*10+18  ,String(WiFi.RSSI(i)));
             delay(10);
        }
    }
     display.display();
    // Wait a bit 
    delay(5000);
}

When you successfully compile and upload the code to your ESP32 device, you should immediately be presented with local WiFi information displaying on the OLED screen.

If this is not the case… the fun begins.

If you are using a bread board like in my example image, check no pins are bent over, if they are, they may not be making contact and you will need to straighten them.

Check the jump wires, I know there are only 4 wires but are SDA / SCL 3.3 volts and GND pins all connected right?

Is your Arduino IDE Setup for ESP32? Have you tested on an example project to prove it is working with this current device?

Then check every line of the code, something is sure to be wrong or missing.

Personally for the most part I really enjoy debugging, fault finding, what ever you would like to call it. I won’t say it’s not stressful and sometimes frustrating, But it most certainly is a large part of what we do in this hobby business.

Oh, how easy it is to be calm, when you know the project works, certainly not always the case with unknown projects.

Above all… have fun!

Cheer’s

Al

the Blind Guy Tech

VigLink badge
______________________________________________________________________________________________________

ADS

Leave a Reply

Your email address will not be published. Required fields are marked *