#include #include // https://github.com/tzapu/WiFiManager #include // Create an instance of Espalexa Espalexa espalexa; // Pin definitions for the lights const int lightPin1 = LED_BUILTIN; // State variables for the lights bool lightState1 = false; // Callback functions for Alexa commands void light1Changed(uint8_t brightness) { lightState1 = brightness > 0; digitalWrite(lightPin1, lightState1 ? HIGH : LOW); Serial.println("Light 1 State: " + String(lightState1)); } void setup() { // Start the serial communication Serial.begin(115200); delay(1000); // Set up the pins as outputs pinMode(lightPin1, OUTPUT); // Create an instance of WiFiManager WiFiManager wifiManager; // Uncomment the following line to reset saved WiFi credentials // wifiManager.resetSettings(); // Automatically connect to WiFi // If it fails, it will start an access point with the specified name // and wait for you to connect and configure the credentials if (!wifiManager.autoConnect("AutoConnectAP")) { Serial.println("Failed to connect and hit timeout"); // Reset and try again, or go to deep sleep ESP.reset(); delay(1000); } // If you get here, you have connected to the WiFi Serial.println("Connected to WiFi!"); // Add devices to Espalexa espalexa.addDevice("Licht", light1Changed); // Start Espalexa espalexa.begin(); } void loop() { // Handle Alexa requests espalexa.loop(); }