Alexa doesn't find devices, with esp32, please help.
ReptilMagico opened this issue · 3 comments
_This is my code, everything is just fine. But when i tell alexa to search for devices, she literally can't find nothing, i've tried the debug method too, but i don't understand the problem. Please, @Aircoookie , you're an amazing programmer i know you can help me with this problem, let me know if there is any solution.
Everything boots just fine, my code is basically for turning on basic lights, with 8 relays.
My Alexa is a 2nd generation DOT._
#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include <Espalexa.h>
//variables
int relay1 = 4;
int relay2 =15;
int relay3 = 2;
int relay4 = 5;
int relay5 = 13;
int relay6 = 14;
int relay7 = 12;
int relay8 = 27;
// prototypes
boolean connectWifi();
//callback functions
void port1(uint8_t brightness);
void port2(uint8_t brightness);
void port3(uint8_t brightness);
void port4(uint8_t brightness);
void port5(uint8_t brightness);
void port6(uint8_t brightness);
void port7(uint8_t brightness);
void port8(uint8_t brightness);
// Change this!!
const char* ssid = "NETLIFE-60";
const char* password = "25212612";
boolean wifiConnected = false;
Espalexa espalexa;
EspalexaDevice* device3; //this is optional
void setup()
{
Serial.begin(115200);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(relay5, OUTPUT);
pinMode(relay6, OUTPUT);
pinMode(relay7, OUTPUT);
pinMode(relay8, OUTPUT);
// Initialise wifi connection
wifiConnected = connectWifi();
if(wifiConnected){
// Define your devices here.
espalexa.addDevice("one", port1);
espalexa.addDevice("two", port2);
espalexa.addDevice("three", port3);
espalexa.addDevice("four", port4);
espalexa.addDevice("five", port5);
espalexa.addDevice("six", port6);
espalexa.addDevice("seven", port7);
espalexa.addDevice("eight", port8);
espalexa.begin();
} else
{
while (1) {
Serial.println("Cannot connect to WiFi. Please check data and reset the ESP.");
delay(2500);
}
}
}
void loop()
{
espalexa.loop();
delay(1);
}
//our callback functions
void port1(uint8_t brightness)
{
Serial.print("RELAY1 - ");
if (brightness)
{
digitalWrite(relay1, HIGH);
Serial.println("ON");
}
else
{
digitalWrite(relay1, LOW);
Serial.println("OFF");
}
}
void port2(uint8_t brightness)
{
Serial.print("RELAY2 - ");
if (brightness)
{
digitalWrite(relay2, HIGH);
Serial.println("ON");
}
else
{
digitalWrite(relay2, LOW);
Serial.println("OFF");
}
}
void port3(uint8_t brightness)
{
Serial.print("RELAY3 - ");
if (brightness)
{
digitalWrite(relay3, HIGH);
Serial.println("ON");
}
else
{
digitalWrite(relay3, LOW);
Serial.println("OFF");
}
}
void port4(uint8_t brightness)
{
Serial.print("RELAY4 - ");
if (brightness)
{
digitalWrite(relay4, HIGH);
Serial.println("ON");
}
else
{
digitalWrite(relay4, LOW);
Serial.println("OFF");
}
}
void port5(uint8_t brightness)
{
Serial.print("RELAY5 - ");
if (brightness)
{
digitalWrite(relay5, HIGH);
Serial.println("ON");
}
else
{
digitalWrite(relay5, LOW);
Serial.println("OFF");
}
}
void port6(uint8_t brightness)
{
Serial.print("RELAY6 - ");
if (brightness)
{
digitalWrite(relay6, HIGH);
Serial.println("ON");
}
else
{
digitalWrite(relay6, LOW);
Serial.println("OFF");
}
}
void port7(uint8_t brightness)
{
Serial.print("RELAY7 - ");
if (brightness)
{
digitalWrite(relay7, HIGH);
Serial.println("ON");
}
else
{
digitalWrite(relay7, LOW);
Serial.println("OFF");
}
}
void port8(uint8_t brightness)
{
Serial.print("RELAY8 - ");
if (brightness)
{
digitalWrite(relay8, HIGH);
Serial.println("ON");
}
else
{
digitalWrite(relay8, LOW);
Serial.println("OFF");
}
}
// connect to wifi – returns true if successful or false if not
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;
}
Assuming the same issue as me #142
Please include #define ESPALEXA_DEBUG and your serial monitor output! Hopefully, @Aircoookie Responds to us.
I solved it! Well i believe it was just luck but i restarted my alexa dot and the arduino ide, then upload it again and it worked!
I solved it! Well i believe it was just luck but i restarted my alexa dot and the arduino ide, then upload it again and it worked!
Same with me!!! Thank you. Dumb of me to not think of that haha.