// /*
// ESP32-S3 + ILI9341 TFT LCD Example
// https://wokwi.com/projects/343784047735997012
// */
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "WiFi.h"
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
String scaneando = "";
const uint32_t colors[] = {
ILI9341_GREEN,
ILI9341_CYAN,
ILI9341_MAGENTA,
ILI9341_YELLOW,
};
uint8_t colorIndex = 0;
void setup() {
Serial.begin(115200);
Serial.println("Welcome to Wokwi, ESP32-S3");
Wire.begin(10, 8);
tft.begin();
tft.setCursor(44, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println();
}
void displays(int textZ, int x = 26, int y = 164, String texto = "Carregando")
{
tft.setTextSize(textZ);
tft.setCursor(x, y);
tft.setTextColor(colors[colorIndex++ % 4]);
tft.println(texto);
delay(5000);
tft.fillScreen(ILI9341_BLACK);
}
void scan() {
displays(3, 26, 164, "Scanning...");
// WiFi.scanNetworks retornará o número de redes encontradas
int n = WiFi.scanNetworks();
displays(3, 26, 164, "Carregando!");
if (n == 0) {
displays(3, 26, 164, "No networks found.");
} else {
Serial.println();
Serial.print(n);
Serial.println(" networks found");
displays(2, 26, 164, "networks found");
for (int i = 0; i < n; ++i) {
// Imprime SSID e RSSI para cada rede encontrada
Serial.print(i + 1);
Serial.print(": ");
String ssid = WiFi.SSID(i);
String rssi = String(WiFi.RSSI(i));
Serial.print("SSID = ");
Serial.print(ssid);
Serial.print(", RSSI = ");
Serial.print(rssi);
Serial.println(" dBm");
//displays(1, 5 + i * 6, 164, "SSID = " + ssid + ", RSSI = " + rssi);
displays(1, 25, 18 + i, String(i + 1) + " - SSID = " + ssid + " RSSI = " + rssi);
delay(10);
}
}
Serial.println("");
// Espere um pouco antes de fazer a varredura novamente
delay(5000);
}
void loop() {
//displays(3, 25, 164, "Carregando");
scan();
delay(250);
}