I have a problem detecting device created with this code:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"
#define WIFI_SSID "HUAWEI-B315-A5A7"
#define WIFI_PASS "MYA6BY5N9FJ"
#define LED_PIN D7
#define DEVICE_NAME "Lilypad led"
fauxmoESP fauxmo;
void wifiSetup() {
Serial.println("[WIFI] Connecting...");
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(300);
}
Serial.println();
Serial.println("[WIFI] Connected!");
Serial.print("[WIFI] IP Address: ");
Serial.println(WiFi.localIP());
}
void setup() {
Serial.begin(115200);
Serial.println("\n--- DEVICE STARTING ---");
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
Serial.println("[GPIO] LED pin initialized.");
wifiSetup();
Serial.println("[ALEXA] Initializing fauxmo...");
fauxmo.createServer(true);
Serial.println("[ALEXA] Server created.");
fauxmo.setPort(80);
Serial.println("[ALEXA] Port set to 80.");
fauxmo.enable(true);
Serial.println("[ALEXA] fauxmo enabled.");
fauxmo.addDevice(DEVICE_NAME);
Serial.print("[ALEXA] Device added: ");
Serial.println(DEVICE_NAME);
fauxmo.onSetState([](unsigned char device_id, const char * name, bool state, unsigned char value) {
Serial.print("[ALEXA] Command received for device: ");
Serial.println(name);
Serial.print(" State: ");
Serial.println(state ? "ON" : "OFF");
if (strcmp(name, DEVICE_NAME) == 0) {
digitalWrite(LED_PIN, state ? LOW : HIGH);
Serial.println("[GPIO] LED state changed.");
}
});
}
void loop() {
fauxmo.handle();
}
I have mesh devices at home, which I was told might be a problem, but now I have connected the Wemos D1 to an old router. My phone with the Alexa app is also connected to this router, and yet when I look for the device, I cannot find it. I checked the router configuration, but I don’t see any device isolation or multicast options that I can change. I’ve seen people on YouTube set it up and it was working, so I’m wondering what I am doing wrong