#include <WiFi.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
// define some the TFT pins
const int TFT_CS = 23;
const int TFT_DC = 21;
// Initialize display
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
// setting up the TFT display
tft.begin(); // tft display
tft.fillScreen(ILI9341_BLACK); // set the background color of the screen to black
tft.setTextColor(ILI9341_WHITE); // set the font color to white
tft.setTextSize(3);
tft.setCursor(0,0);
tft.println("Connected");
// set wifi to station mode
WiFi.mode(WIFI_STA);
// disconnect from an AP if it was previously connected
WiFi.disconnect();
delay(100);
}
void loop() {
Serial.println("Scanning for networks...");
// returning nbr of networks found
int n = WiFi.scanNetworks();
if(n==0)
//Serial.println("No networks found");
tft.println("No networks found");
else{
tft.print("Nbr of networks found = ");
tft.println(n);
// printing available networks on the serial monitor
tft.println("Nr | SSID | RSSI | CH | Encryption");
for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
tft.printf("%2d",i + 1);
tft.print(" | ");
tft.printf("%-32.32s", WiFi.SSID(i).c_str());
tft.print(" | ");
tft.printf("%4d", WiFi.RSSI(i));
tft.print(" | ");
tft.printf("%2d", WiFi.channel(i));
tft.print(" | ");
}
}
}