Amazon Echo ESP8266 control, with natural speech commands

I have been using this code for a while and it is working great. Thanks for sharing… I am facing a small issue. It would be great if you can fix it.

I usually face this issue when there is powercut at my place and when Electricity is ON after the powercut, My Wifi Router and my esp8266-01 switches ON at the same time. My Router takes about a minute to boot but esp8266-01 with this code does not wait for a minute to connect to Wifi… It goes directly in Access Point Mode. Is there any way to delay the process to connect to Wifi Router on ESP8266-01.

Also it would be great if a local web server is embedded in the script with a single button to control GPIO with static IP. This would also help control devices on powercut.

Correction. If am looking for local web server to control GPIO with static IP. This would help when internet is not working.

delay() is very, very bad with Blynk projects but as long as you use it before you start Blynk then it’s fine. Hopefully that’s enough of a clue but if not try delay(65000L) as the first line of setup().

@chrome1000 I have been following this thread for some time now and have created numerous projects utilizing this code; so thanks a million.

I am successfully able to control my devices with the Blynk App, voice commands from Amazon Echo, and a physical momentary switch.

The one thing that is not working is utilizing the button in the Devices section of the Smart Home section of the Amazon Alexa app. When I push a particular button to turn on a device it turns on as expected. However, if I push the button again to turn off the device, it turns off but a couple of seconds later it turns back on. The only way to prevent it from turning back on again is to quickly back out of the button before it has a chance to turn off. It then stays on as one would expect.

I am using the exact same code with no modifications. Any experience with this action? I did not notice any comments concerning this issue.

I should mention that I am using a WeMos D1 R2 mini.

Again great work and thanks for sharing.

Sean

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.