Amazon Echo ESP8266 control, with natural speech commands

Yes, in the newest version of the Alexa app, Amazon made some changes. As best I can surmise, Alexa is now attempting to sync device status with the official Wemo server, which of course doesn’t recognize the esp8266, and it causes this behavior.

However, since our devices can be controlled by so many other methods, there’s really no need to use the buttons in the Alexa app.

@chrome1000

However, since our devices can be controlled by so many other methods, there’s really no need to use the buttons in the Alexa app.

You are absolutely correct. Just wanted to rule out my MCU and make sure that I hadn’t gooned up my coding somewhere.

Thanks.

I have been following this thread with great interest and have just purchased an Amazon Echo so I would like to merge this code with my existing Blynk blind control and light control.I am about to try the code but have a question… How does the web configure handle a local Blynk server? I haven’t found anywhere that you point to the local server IP.

Any help gratefully accepted.

With the exception of reporting a switch status change back to Blynk, the Wemo emulation happens independently. Assuming that you maintain the local Blynk server settings that you’re using for your lights and blinds, you shouldn’t need any special configuration.

Thanks for the quick reply chrome1000. What I was wondering about is, I don’t see reference to the local IP in the code at the beginning of this thread. In particular Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,xxx), 8442) in setup() is missing so how is the connection made?

@modicon1 Check out the readme info at the beginning of the sketch… This OP’s sketch uses WiFiManager for provisioning, and thus only requires the Blynk.config(auth); command for the server connection.

http://docs.blynk.cc/#blynk-firmware-configuration-blynkconfig

Awesome… Thanks Gunner. A lack of understanding on my part of WiFiManager. Thanks for the insight Gunner and for your help as well chrome1000.

Will let you know the outcome in the next few days. Happy Holidays everyone:snowman_with_snow:

I recently picked up a Google Home Mini, and found that it doesn’t have the same direct integration of Wemo devices as the Amazon products. However, it does work very well with IFTTT. In fact, IFTTT’s Google Assistant trigger allows us to create whatever speech trigger we want. We’re no longer limited to “off” and “on!”

With the Google Home products, @dananmo can finally tell his device to “make me a dry martini.”

1 Like

Hahaha thatsis amazing
Am gunna tell my wife to have it as Christmas gift lol

First, thank you Chrome for your great work.
Your code worked perfectly on 2 devices (ESP-01 and D1-Mini) for almost a month. Now, i cannot find devices with Alexa for the life of me. Even worse, both saved devices in Alexa app are not there anymore. Same code, same hardware, nothing changed but Alexa is not discovering any wemo anymore.

The device is set up perfectly and all blynk related works perfect. What could be wrong? I never enabled any skill in alexa app before and still worked perfect as you described. What should i try? And why my devices dissapeared by themselves from Alexa app…?

All Alexa related things already tried (reset, reconfig same wifi; although useless because they were all in the same wifi network, etc)

P.S. i am on local server, but as i said, blynk is more than fine…

I had a similar experience after updating the Alexa app on my iPhone a few weeks ago. My solution was to re-discover my devices using my iPad that still had an earlier version of the app. It found my devices, which in turn populated them on the newer app.

Any Blynkers out there have another solution?

It worked with an older version that i’ve had on a tablet…rediscovering i mean.

HUGE IMPROVEMENTS since the last iteration!!!

I’ve replaced the WemoManager library that I was using with the Espalexa library, which solves several issues:

  1. It’s simpler to implement. One library. One callback.
  2. It resolves the issue that many were having with updated Echo devices not discovering correctly
  3. … and drumroll… It now allows LEVELS! You can specify any level from 0-100%.

For anyone who wants to dim a lamp, open the blinds halfway, or change the volume the stereo (@pavel @jon), it’s now possible. The Espalexa library takes advantage of Hue bulb emulation to expose a “brightness” parameter. That level, however you express it to Alexa, is converted to an unsigned integer 0-255 for us to use however we see fit.

Here’s the code that I used to test the functionality:

/* Wemo / Hue emulation for ESP8266 control with Alexa, Blynk and IFTTT.
 * 
 * https://github.com/tzapu/WiFiManager
 * https://github.com/Aircoookie/Espalexa
 * https://www.blynk.cc/
 * 
 * In order to control multiple devices with a single Blynk dashboard, each ESP8266
 * should be programmed with a unique virtual pin corresponding to a Blynk
 * dashboard widget (switch, slider, step). 
 * 
 * For IFTTT control, use the Maker Channel with the following settings:
 *    URL: http://blynk-cloud.com:8080/YOUR_TOKEN/V1       Substitute your own token and vitual pin 
 *    Method: PUT
 *    Content type: application/json
 *    Body: {"1"]                                          Use 0 for OFF, 1 for ON. For custom levels use 0-255.
 */

#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> 
#include <Espalexa.h>
#include <ArduinoOTA.h>
#include <BlynkSimpleEsp8266.h>

// Blynk token and virtual pin number
#define VPIN V10  //Use a unique virtual pin for each device using the same Blynk token / dashboard
char auth[] = "TOKEN"; //Get token from Blynk

const int OutputPin = D1;      //Relay switching pin. Relay is pin 12 on the SonOff

Espalexa espalexa;

void setup(){ 
  Serial.begin(115200);
  
  WiFiManager wifi; 
  wifi.autoConnect("MyDevice"); // Connect to wifi
 
  espalexa.addDevice("Switch1", UpdateSwitch1); //Parameters: (device name, callback function).
  espalexa.begin();

  pinMode(OutputPin, OUTPUT);
  digitalWrite(OutputPin, LOW); 

  Blynk.config(auth);
  
  ArduinoOTA.begin();
}
 
void loop()
{
   espalexa.loop();
   Blynk.run();
   ArduinoOTA.handle();
}

//------------ Callback functions. Level can be set from 0-255. -------------
void UpdateSwitch1(uint8_t level) {   // Espalexa callback
  SetNewLevel(&level);  
}

BLYNK_WRITE(VPIN){                    // Blynk & IFTTT callback
  uint8_t level = param.asInt();
  SetNewLevel(&level); 
}

void SetNewLevel(uint8_t * pLevel){
  Serial.print("New level= ");
  Serial.println(*pLevel);
  
  if (*pLevel) {
    digitalWrite(OutputPin, HIGH); // Use analog.Writes for PWM control
  }
  else  {
    digitalWrite(OutputPin, LOW); 
  }
}

Enjoy!

3 Likes

l have been Waiting for this for a long time! Thank you So much!

whoa! need to test it out ASAP!

Did you try running both WeMo emulator and Espalexa?

Yes, I attached a device with this code to my existing system, which is mostly Wemo emulators, and everything played nicely together.

However, since Espalexa seems to fix problems that folks had with Gen 2 Alexa losing or failing to find their devices, I’m inclined to update all my gadgets to the new code.

A post was split to a new topic: I would like to control the Nodemcu with natural voice commands

Can i use this code to link my esp8266 with my google home ? Because in GH i need a wemo account

Google Home doesn’t have the same native integration as Alexa, but you can connect through IFTTT. Just use IFTTT’s Google Assistant trigger and the Blynk webhook action (instructions in the header comments of the code).

The great thing about Google Home’s IFTTT trigger is that you can specify any phrase, provide alternate phrases, and even create a custom response.

1 Like

Hey,
The code works perfectly. But I have a case usually after power cut the wifi modem takes some time to be up. But the nodemcu immediately creates its own AP and stays there even after the wifi signal is back. in such cases I have connect to the hotspot and do a reset. Have you also faced such issue?

I had a look into the Documentation of WifiManager on Github.I found this:
https://github.com/tzapu/WiFiManager#configuration-portal-timeout

wifiManager.setConfigPortalTimeout(180);

So replacing this

with:

WiFiManager wifiManager;
//sets timeout until configuration portal gets turned off
//useful to make it all retry or go to sleep
//in seconds
wifiManager.setTimeout(180);

//fetches ssid and pass and tries to connect
//if it does not connect it starts an access point with the specified name
//here  "AutoConnectAP"
//and goes into a blocking loop awaiting configuration
if(!wifiManager.autoConnect("AutoConnectAP")) {
Serial.println("failed to connect and hit timeout");
delay(3000);
//reset and try again, or maybe put it to deep sleep
ESP.reset();
delay(5000);
}  

Hope this is helpful to people facing similar problems

1 Like