Closed IOTMan7 closed 2 weeks ago
I am using this code and my Alexa/Alexa App can't find the ESP can, I'm getting an IP Address and when I look it up on the web it says Not Found (espalexa)
Can anyone help
boolean connectWifi();
void firstLightChanged(uint8_t brightness);
const char ssid = "BCUStudents"; const char password = "";
String Device_1_Name = "Yellow LED";
boolean wifiConnected = false;
Espalexa espalexa;
void setup() { Serial.begin(9600);
pinMode(RelayPin1, OUTPUT);
wifiConnected = connectWifi();
if (wifiConnected)
{ espalexa.addDevice(Device_1_Name, firstLightChanged);
espalexa.begin(); } else { while (1) { Serial.println("Can't Connect to WiFi. Please Try Again"); delay(2500); } } }
void loop() { espalexa.loop(); delay(1); }
void firstLightChanged(uint8_t brightness) { if (brightness == 255) { digitalWrite(RelayPin1, LOW); Serial.println("Device1 OFF"); } else { digitalWrite(RelayPin1, HIGH); Serial.println("Device1 ON"); } }
boolean connectWifi() { boolean state = true; int i = 0;
WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); Serial.println(""); Serial.println("Connecting to WiFi");
// Wait for connection Serial.print("Connecting..."); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); if (i > 20) { state = false; break; } i++; } Serial.println(""); if (state) { Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); } else { Serial.println("Connection failed."); } return state; }
Wrong repository ;) See https://github.com/Aircoookie/Espalexa
I am using this code and my Alexa/Alexa App can't find the ESP can, I'm getting an IP Address and when I look it up on the web it says Not Found (espalexa)
Can anyone help
ifdef ARDUINO_ARCH_ESP32
include
include
else
include
include
endif
include
define RelayPin1 5
boolean connectWifi();
void firstLightChanged(uint8_t brightness);
const char ssid = "BCUStudents"; const char password = "";
String Device_1_Name = "Yellow LED";
boolean wifiConnected = false;
Espalexa espalexa;
void setup() { Serial.begin(9600);
pinMode(RelayPin1, OUTPUT);
wifiConnected = connectWifi();
if (wifiConnected)
{ espalexa.addDevice(Device_1_Name, firstLightChanged);
espalexa.begin(); } else { while (1) { Serial.println("Can't Connect to WiFi. Please Try Again"); delay(2500); } } }
void loop() { espalexa.loop(); delay(1); }
void firstLightChanged(uint8_t brightness) { if (brightness == 255) { digitalWrite(RelayPin1, LOW); Serial.println("Device1 OFF"); } else { digitalWrite(RelayPin1, HIGH); Serial.println("Device1 ON"); } }
boolean connectWifi() { boolean state = true; int i = 0;
WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); Serial.println(""); Serial.println("Connecting to WiFi");
// Wait for connection Serial.print("Connecting..."); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); if (i > 20) { state = false; break; } i++; } Serial.println(""); if (state) { Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); } else { Serial.println("Connection failed."); } return state; }