Hi, I am relatively new with regards to ESP8266 and how it work. I am trying to make a light switch on and off using Amazon echo dot. I am having trouble finding the device from amazon echo dot. Please help.
here is the code:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"
#define WIFI_SSID "----------"
#define WIFI_PASS "--------------"
#define SERIAL_BAUDRATE 115200
fauxmoESP fauxmo;
//--------------------------------------------------------
//Wifi
//--------------------------------------------------------
void wifiSetup()
{
// Set Wifi module to STA mode
WiFi.mode(WIFI_STA);
// Connect
Serial.printf("[WIFI] Connecting to %s ", WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);
// Wait
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(100);
}
Serial.println();
// Connected
Serial.printf("[WIFI] STATION Mode, SSID %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
}
void callback(uint8_t device_id, const char * device_name, bool state)
{
Serial.print("Device "); Serial.print(device_name);
Serial.print(" state: ");
if(state)
{
Serial.println("ON");
digitalWrite(D2,HIGH);
}else {
Serial.println("OFF");
digitalWrite(D2,LOW);
}
}
void setup()
{
// Init serial port and clean garbage
Serial.begin(SERIAL_BAUDRATE);
Serial.println("FauxMo demo sketch");
Serial.println("After connection, ask Alexa to 'turn on' or 'off'");
pinMode(D2,OUTPUT);
// Wifi
wifiSetup();
// Fauxmo
fauxmo.addDevice("Fish Tank");
fauxmo.onMessage(callback);
}
void loop()
{
fauxmo.handle();
}
This is the message that I am getting on my serial monitor:
SDK:2.2.1(cfd48f3)/Core:2.4.1/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1)
FauxMo demo sketch
After connection, ask Alexa to 'turn on' or 'off'
[WIFI] Connecting to ------------- scandone
..scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 6
cnt
connected with ------------, channel 1
dhcp client start...
..........ip:123.456.7.890,mask:123.456.789.0,gw:123.456.7.890
[WIFI] STATION Mode, SSID ---------, IP address: 123.456.7.890
pm open,type:2 0