Arduino Uno with WiFi – Network Scanner with I2C 20×4 Screen

This uses an Arduino Uno with Wifi and a 20×4 I2C LCD Screen. Plug the LCD into the SCL and SDA ports, NOT into A$ and A5.

Make sure to install the Liquid Crystal Library and the Liquid Crystal I2C library written by Frank de Brabander.

#include <SPI.h>
#include <WiFiNINA.h>
#include <Wire.h> 
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);

String networkName;

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


   lcd.begin(20,4); 
   lcd.setBacklightPin(3,POSITIVE);
   lcd.setBacklight(HIGH);
   lcd.setCursor(0,0);
   lcd.print("Network Scanner");
   lcd.setCursor(0,1);
   lcd.print("by"); 
   lcd.setCursor(0,2);
   lcd.print("Eli the Computer Guy");   
   lcd.setCursor(0,3);
   lcd.print("April 2020");
}

void loop() {
  Serial.println("Scanning available networks...");
  listNetworks();
  delay(10000);
}

void listNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  int numSsid = WiFi.scanNetworks();
  if (numSsid == -1) {
    Serial.println("Couldn't get a wifi connection");
    while (true);
  }

  // print the list of networks seen:
  Serial.print("number of available networks:");
  Serial.println(numSsid);

    lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Networks: ");
   lcd.print(numSsid);

   delay(2000);
   lcd.clear();

  // print the network number and name for each network found:
  for (int thisNet = 0; thisNet < numSsid; thisNet++) {
    Serial.print(thisNet);
    Serial.print(") ");
    Serial.print(WiFi.SSID(thisNet));
    Serial.print("\tSignal: ");
    Serial.print(WiFi.RSSI(thisNet));
    Serial.print(" dBm");

    lcd.setCursor(0, thisNet);
    networkName = WiFi.SSID(thisNet);
    networkName.remove(16);
    lcd.print(networkName);
    lcd.setCursor(17, thisNet);
    lcd.print(WiFi.RSSI(thisNet));
    
  }
}

Be the first to comment

Leave a Reply