#include #include #include TFT_eSPI tft; void setup() { Serial.begin(115200); while(!Serial); tft.begin(); tft.setRotation(3); tft.fillScreen(TFT_BLACK); tft.setTextColor(TFT_WHITE); tft.setTextSize(2); tft.setCursor(20, 120); tft.println("Buscando Wrover..."); BLEDevice::init(""); } void loop() { BLEScan* pBLEScan = BLEDevice::getScan(); pBLEScan->setActiveScan(true); // Escaneo rápido de 1 segundo BLEScanResults foundDevices = pBLEScan->start(1, false); for (int i = 0; i < foundDevices.getCount(); i++) { BLEAdvertisedDevice device = foundDevices.getDevice(i); String nombre = device.getName().c_str(); // Si el nombre empieza por "W:" if (nombre.startsWith("W:")) { // Extraemos el número (lo que hay después de "W:") String valorStr = nombre.substring(2); int valorInt = valorStr.toInt(); // Pintamos en pantalla tft.fillScreen(TFT_DARKGREEN); tft.setTextColor(TFT_WHITE); tft.setTextSize(3); tft.setCursor(50, 60); tft.print("WROVER LINK OK"); tft.setTextSize(8); tft.setCursor(110, 130); tft.println(valorInt); Serial.println("¡Dato Cazado!: " + valorStr); } } pBLEScan->clearResults(); }