Hi,
I am having trouble connecting Alexa to my ESP8266. The ESP8266 is connected to my wifi and I can ping it with no problems. when I try to discover the ESP on Alexa it cant discover it. Is anyone else having this problem? It's an Alexa 3rd Gen. When I ask Alexa to search for new devices the blue LED on the ESP flashes for a split second.
Thanks,
Mike.
#include <RCSwitch.h>
#include <ESP8266WiFi.h>
#include "WemoSwitch.h"
#include "WemoManager.h"
#include "CallbackFunction.h"
// Assign the LED pins.
// LED's show debugging for program state.
const int GreenLED = 5; //Connected to pin D1.
const int RedLED = 4; //Connected to pin D2.
// prototypes.
boolean connectWifi();
// On/Off callbacks.
void ChristmasLightsOn();
void ChristmasLightOff();
// WiFi Network credentials.
char ssid[] = "MY SSID"; // Network SSID.
char password[] = "MY PASSWORD"; // Network Password.
WemoManager wemoManager;
WemoSwitch *ChristmasLights = NULL;
RCSwitch mySwitch = RCSwitch();
void setup() {
// Setup pins as outputs.
pinMode (GreenLED, OUTPUT);
pinMode (RedLED, OUTPUT);
// Setup Baud rate.
Serial.begin(115200);
// Set WiFi to station mode and disconnect from an access point if it was previously connected.
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
// Attempt to connect to Wifi network.
Serial.print("Connecting Wifi: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
IPAddress ip = WiFi.localIP();
Serial.println(ip);
wemoManager.begin();
// Format: Alexa invocation name, local port no, ON callback, OFF callback.
ChristmasLights = new WemoSwitch("Christmas Lights", 80, ChristmasLightsOn, ChristmasLightsOff);
wemoManager.addDevice(*ChristmasLights);
delay(10);
//Setup 433mhz Transmitter.
mySwitch.enableTransmit(16); // Transmitter DATA Pin is connected to Pin D0.
mySwitch.setProtocol(1); // Set protocol.
mySwitch.setPulseLength(165); // Set pulse length.
mySwitch.setRepeatTransmit(15); // Set number of transmission repetitions.
}
void loop() {
wemoManager.serverLoop();
}
void ChristmasLightsOn() {
Serial.println("Christmas Lights switched ON ...");
digitalWrite(GreenLED, HIGH);
digitalWrite(RedLED, LOW);
mySwitch.send("000001000101010100110011");
}
void ChristmasLightsOff() {
Serial.println("Christmas Lights switched OFF ...");
digitalWrite(RedLED, HIGH);
digitalWrite(GreenLED, LOW);
mySwitch.send("000001000101010100111100");
}