WiFi Scanner using PCD8544 and NodeMCU





You can download our e-book ‘Learn Arduino from Scratch’ from this link
While searching in my Pandora’s box of electronics, I came across the beautiful PCD8544, or the more familiar name, the Nokia 5110 LCD.

pcd8544
PCD8544

This amazing piece of hardware is fully programmable using Arduino or ESP8266/NodeMCU. Thanks to Adafruit and bbx10 for their libraries which make our lives easier. The display has a resolution of 84×48 pixels. Each pixel can only be on or off, so there you have it, a monochrome display.

In this tutorial we are going to scan for WiFi networks, display their SSID, MAC Address (BSSID), the encryption type and the signal strength (RSSI);

The Parts

  • NodeMCU or ESP8266 with certain pins exposed.
  • PCD8544 Nokia 5110 LCD
  • 8 jumper wires
  • 5 resistors at 1k Ohm or so (these may not be needed since the ESP8266 pin voltage level is 3.3v, but better be safe)
  • 1 220 Ohm resistor for LED (this is important)

I am using 2 small breadboard but obviously you can use a big one or even solder everything on a veroboard.

The Wiring

 

  • LCD Pin —————> NodeMCU
  • RST ——————–> D2 (resistor in series)
  • CE  ———————> D1 (resistor in series)
  • DC ———————> D6 (resistor in series)
  • DIN ——————–> D7 (resistor in series)
  • CLK  ——————-> D5 (resistor in series)
  • VCC ——————–> 3.3v
  • Light ——————> iether 3.3v or GND depends on the board. (220 Ohm resistor)
  • GND ——————-> GND

Please make sure you connect VCC to 3.3v. The LCD is NOT 5V tolerant



The Code

#include "ESP8266WiFi.h"
#include <Arduino.h>
#include <SPI.h>
//https://github.com/adafruit/Adafruit-GFX-Library
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
//https://github.com/bbx10/Adafruit-PCD8544-Nokia-5110-LCD-library/tree/esp8266

Adafruit_PCD8544 display = Adafruit_PCD8544(14, 13, 12, 5, 4);

void setup() {
Serial.begin(115200);

// Set esp8266 to station mode and disconnect from any AP previously connected to
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);

Serial.println("WiFi Scanner using Adafruit PCD8544 and GFX libraries");

display.begin();
display.setContrast(40);
//adjust for your display (if you see a black screen try lowering the value, if all white try increasing it. Max 127)

display.clearDisplay();
delay(2000);

display.clearDisplay();
display.setTextSize(0);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println("Runtime");
display.setCursor(0,10);
display.println("Projects");

display.setCursor(0,20);
display.println("WiFi Scanner");

display.display();
delay(2000);
Serial.println("Setup done");
}

void loop() {
Serial.println("Scan started");

display.clearDisplay();
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println("Scan started");
display.display();

int networksFound = WiFi.scanNetworks();
Serial.println("Scan Complete");
display.setCursor(0,10);
display.println("Scan Complete");
display.display();
delay(2000);

if (networksFound == 0){
Serial.println("No Networks Found");
display.clearDisplay();
display.setCursor(0,0);
display.println("No Networks");
display.setCursor(0,10);
display.println("Found");
display.display();
}
else
{
Serial.print("Displaying ");
Serial.print(networksFound);
Serial.println(" networks");

display.print("Displaying ");
display.print(networksFound);
display.println(" networks");
display.display();
delay(2000);
display.clearDisplay();
display.setCursor(0,0);
display.print("Displaying ");
display.println(networksFound);
display.setCursor(0,10);
display.println("Networks");
display.display();

for (int i = 0; i < networksFound; ++i)
{
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" [");
Serial.print(WiFi.BSSIDstr(i));
Serial.print(" ]");
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println(getEncryptionType(WiFi.encryptionType(i)));

display.clearDisplay();
display.setCursor(0,0);
display.print("Network: ");
display.println(i);
display.setCursor(0,8);
display.print("SSID: ");
display.println(WiFi.SSID(i));

display.print("MAC: ");
display.println(WiFi.BSSIDstr(i));

display.print("RSSI: ");
display.println(WiFi.RSSI(i));

display.print("ENC: ");
display.println(getEncryptionType(WiFi.encryptionType(i)));
display.display();

delay(5000);
}
}

}

char* getEncryptionType(int enc) {
switch(enc){
case ENC_TYPE_NONE: return "Open";
case ENC_TYPE_WEP:
return "WEP";
case ENC_TYPE_TKIP:
return "WPA";
case ENC_TYPE_CCMP:
return "WPA2";
case ENC_TYPE_AUTO:
return "WPA/WPA2";
}
}

Conclusion

In this tutorial we are only using a very small portion of functions provided by the libraries. Primarily:

  • display.print() which print text to the screen
  • display.clearDisplay() which clears the screen
  • display.setCursor() which sets the cursor to a position on the display
  • and most importantly… display.display

Will be posting more on this LCD soon

Tags:

  1. Almost spent wiring wrong to LCD Module for last 1 hour. Reached to your blog and now I can see display properly.

  2. Which of the best WiFi modules can be used on the Arduino? For example, a wiFi module capable of capturing a distance of 150 m? Do you have any suggestions? Thank you.

  3. My display is only working for few minutes before going blank. I need to rest it for a while to get it work. I’m not getting the issue. I have connected without using any resistors. When I connects power it shows up and flower symbol (So my connections must be correct). Sometimes it even shows the scan results and suddenly it stops displaying. Can anyone help me?

  4. Thanks for sharing this project. It works nice but I have a simular issue as Vamsi says on 20th January 2019 at 08:04, only my display restart almost every 5-10 seconds. I have NodeMCU v1 (V0.9) and see every time just before the display resets the blue led blinking once.

Leave a Reply

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