Alexa not discovering ESP8266

Thread Starter

s200bym

Joined Aug 9, 2017
82
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.

C-like:
#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");

}
 
Last edited:

djsfantasi

Joined Apr 11, 2010
9,156
Don’t you expect that beyond discovering your device on the network, that Alexa expects it to respond to a proprietary protocol

That is, your device must have device driver software to allow it to talk to Alexa in her language. Is the ESP8266 software configured properly to respond to Alexa’s device probe?
 

Thread Starter

s200bym

Joined Aug 9, 2017
82
I completely changed the code I found a fauxmo library that worked. Now it works properly with Alexa.

C-like:
#include <RCSwitch.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"

#define SERIAL_BAUDRATE 115200

#define WIFI_SSID "MY SSID"
#define WIFI_PASS "MY PASSWORD"

#define Christmas_Lights  "Christmas Lights"

const int GreenLED = 5; //Connected to pin D1.
const int RedLED = 4;   //Connected to pin D2.


fauxmoESP fauxmo;

RCSwitch mySwitch = RCSwitch();


// Wi-Fi Connection
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(500);
  }
  Serial.println();

  // Connected!
  Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
}

void setup() {

  pinMode (GreenLED, OUTPUT);
  pinMode (RedLED, OUTPUT);

  // 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.

  // Init serial port and clean garbage
  Serial.begin(SERIAL_BAUDRATE);
  Serial.println();

  // Wi-Fi connection
  wifiSetup();

  fauxmo.createServer(true);
 
  fauxmo.setPort(80); //

  fauxmo.enable(true);
 
  fauxmo.addDevice(Christmas_Lights);

  fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
  

   Serial.printf("[MAIN] Device #%d (%s) state: %s value: %d\n", device_id, device_name, state ? "ON" : "OFF", value);
    if ( (strcmp(device_name, Christmas_Lights) == 0) ) {
    
      if (state) {
        Serial.println("Christmas Lights switched ON ...");
        digitalWrite(GreenLED, HIGH);
        digitalWrite(RedLED, LOW);
        mySwitch.send("000001000101010100110011");
      } else {
        Serial.println("Christmas Lights switched OFF ...");
        digitalWrite(RedLED, HIGH);
        digitalWrite(GreenLED, LOW);
        mySwitch.send("000001000101010100111100");
      }

    }


  });

}

void loop() {
  // fauxmoESP uses an async TCP server but a sync UDP server
  // Therefore, we have to manually poll for UDP packets
  fauxmo.handle();

 
}
 

ErnieM

Joined Apr 24, 2011
8,377
I use the Sinric site to connect to my stuff thru Alexa. It can do some nice things, like it runs an 4 channel RGB 4 channel White controller, and I can even add groups of channels with it.

I just use his free version. (Full disclosure: I did ship him a few bucks to pay for a beer as he requests.)
 

Johnye

Joined Apr 17, 2021
1
I completely changed the code I found a fauxmo library that worked. Now it works properly with Alexa.

C-like:
#include <RCSwitch.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"

#define SERIAL_BAUDRATE 115200

#define WIFI_SSID "MY SSID"
#define WIFI_PASS "MY PASSWORD"

#define Christmas_Lights  "Christmas Lights"

const int GreenLED = 5; //Connected to pin D1.
const int RedLED = 4;   //Connected to pin D2.


fauxmoESP fauxmo;

RCSwitch mySwitch = RCSwitch();


// Wi-Fi Connection
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(500);
  }
  Serial.println();

  // Connected!
  Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
}

void setup() {

  pinMode (GreenLED, OUTPUT);
  pinMode (RedLED, OUTPUT);

  // 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.

  // Init serial port and clean garbage
  Serial.begin(SERIAL_BAUDRATE);
  Serial.println();

  // Wi-Fi connection
  wifiSetup();

  fauxmo.createServer(true);

  fauxmo.setPort(80); //

  fauxmo.enable(true);

  fauxmo.addDevice(Christmas_Lights);

  fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
 

   Serial.printf("[MAIN] Device #%d (%s) state: %s value: %d\n", device_id, device_name, state ? "ON" : "OFF", value);
    if ( (strcmp(device_name, Christmas_Lights) == 0) ) {
   
      if (state) {
        Serial.println("Christmas Lights switched ON ...");
        digitalWrite(GreenLED, HIGH);
        digitalWrite(RedLED, LOW);
        mySwitch.send("000001000101010100110011");
      } else {
        Serial.println("Christmas Lights switched OFF ...");
        digitalWrite(RedLED, HIGH);
        digitalWrite(GreenLED, LOW);
        mySwitch.send("000001000101010100111100");
      }

    }


  });

}

void loop() {
  // fauxmoESP uses an async TCP server but a sync UDP server
  // Therefore, we have to manually poll for UDP packets
  fauxmo.handle();


}
Hello, I'm having the same problem. Alexa does not detect my esp8266. Can you tell me which version of the fauxmo library you used to solve the problem?
 
Top