Arduino Projects Online

Complete Details about the Arduino

WiFi Scanner using PCD8544 and NodeMCU

While searching in my Pandora’s box of electronics, I came across the beautiful PCD8544, or the more familiar name, the Nokia 5110 LCD.

WiFi Scanner using PCD8544 and NodeMCU

WiFi Scanner using PCD8544 and NodeMCU

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

Also Check: Arduino Datalogger with Memory Card

The Code

#include "ESP8266WiFi.h"
#include <Arduino.h>
#include <SPI.h>
////github.com/adafruit/Adafruit-GFX-Library
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
////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

Updated: 29th July 2017 — 9:37 am
Arduino Projects Online © 2017 Frontier Theme