Amazon Echo ESP8266 control, with natural speech commands

Ok, thanks for that, although, I did get “TV volume up” to work as a WEMO/Alexa command, it sent TV down IR command though. Weird.

How do I get the Apps/skills for HUE ect… as I have tried and they all want a real device to work.

I have the emu code for the ESPs.

The HUE and LIFX apps are available free from Apple and Android app stores. Their Alexa skill for LIFX must be enabled in the Amazon Alexa app. I think the Hue skill is enabled by default.

For me, the emulation code for both platforms required some reworking to run on the ESP. I did manage to get both the Hue bridge emulator and the LIFX bulb emulator to respond to their iOS apps, but I couldn’t get Alexa to “discover” them. Please post if you’re successful. :slight_smile:

Ok, which emu code are you using on the 8266? I just tried probonopd/ESP8266HueEmulator, on a D1 that I have been using Blynk successfully on, with 9 pixels, defining the numbers in HUE code to 9px 3 bulbs 3px each, with no response, HUE Switcher app found it, but no light control.

Thank you for sharing this.I am very new to all this and have started playing around with Wemos D1 minis and have some Sonoff devices coming.
I am almost there with the Wemos/Alexa upgrade. The Wemos connects (automatically as remembers IP etc) to my network, Blynk still works and if I go to the webpage of the Wemos, I get “You should tell Alexa to discover devices” so I’m guessing it sees itself as Alexa compatible. This is where it falls apart. Neither Alexa app or FireTV discovery can find this device. They are both on the same network. Any help would be greatly appreciated. Many thanks, Julian

EDIT: I have just run FING on my phone and the device is showing as ‘SonOfWemo’ but Alexa still can’t discover it.

Alexa won’t discover the device unless you ask her to do so. Go into the Alexa app on your phone or tablet, click the “hamburger button” and select Smart Home > Devices > Discover. In a few seconds, she should find your device(s). At this point, you can go to Smart Home > Devices > Groups and give your device a more appropriate name, like “bedroom light” or “ceiling fan.”

I’ve found it handy to use a variety of Group names for my devices. For example, my HVAC is in a group called “heat,” and in another called “air.” That way, I’m not awkwardly asking for Alexa to turn on the heat in the middle of summer, even though it would have the same effect of running the HVAC. You can also control each device from multiple groups. My living room lamp is in a group called “Akari,” which is just the lamp, another group called “living room,” which includes a second lamp and the HVAC in that room, and third group called “everything,” which includes all of my smart home devices.

Hi and thanks for replying so quickly. I have tried that on numerous occasions and with ‘discover devices’ on the FireTV.
I have just sorted it though, I have just set up my sons Echo dot on my account and now Alexa has discovered ‘Sonof Wemo’. I thought it would work just using the Alexa app on Android but doesn’t appear so. Thanks again for a great tutorial. All the best, Julian

Hi Guys,

Is it possible to change the onboard tact switch to a toggle switch? I want to connect my wall mounted light switch to the tact switch so I can also toggle the lights on using the wall switch. Currently the switch is only momentary. I have tried changing this code but I cant get it to work!

// Handle hardware switch activation
void ButtonCheck(){
  // look for new button press
  boolean SwitchState = (digitalRead(TacSwitch));

  // toggle the switch if there's a new button press
  if (!SwitchState && SwitchReset == true){
    Serial.println("Hardware switch activated");
    if (LampState){
      lightOff();
    }
    else{
      lightOn();
    }

    // Flag that indicates the physical button hasn't been released
    SwitchReset = false;
    delay(50);            //debounce
  }
  else if (SwitchState){
    // reset flag the physical button release
    SwitchReset = true;
  }
}

If I understand you correctly, you want to remove the tac switch from the circuit, and connect the wall switch in its place. It will only be conducting LOW voltage, right? In that case, you could edit the ButtonCheck function as follows:

void ButtonCheck(){
  // check the position of the switch
  boolean SwitchState = (digitalRead(TacSwitch));

  // If the switch state has changed, toggle the light
  if ((SwitchState && SwitchReset == false) || (!SwitchState && SwitchReset == true)){
    if (LampState){
      lightOff();
    }
    else{
      lightOn();
    {
    SwitchReset = SwitchState;  //Tracks last switch state to see if it changes
    delay(50);            //debounce
  }
}

The direction you toggle the switch is ignored. The function is just looking for a change. If you change the switch state, the relay toggles to whichever position it’s not already in. If the light was on, it’s turned off, and visa-versa.

To keep things simple, I repurposed the SwitchReset variable name, but it would be more accurate to call it something like LastSwitchState.

At the beginning of my test, I could not see the new access point in the list on the wifi settings of the phone. It is appeared only after I introduced the command wifiManager.resetSettings(); …I hope this can help someone else.
@chrome1000 Starting from your example I have easily integrated the voice control in my table tennis robot project. Thank you!

Glad to hear it’s working for you Paolo.

I’m curious about wifiManager.resetSettings();. When is it called, and what is the problem that it’s resolving?

@chrome1000 I have found wifiManager.resetSettings(); in this example https://github.com/tzapu/WiFiManager/blob/master/examples/AutoConnect/AutoConnect.ino, there it is commented out. My NodeMcu was not discovered by Alexa, then I decided to restart from this basic example to setup the wifi connection. At the beginning I could not see the new access point on my phone, but after I uncommented that line everything worked (obviously adding also the code for wemo emulator). I think that helps if you want to reset the configuration and then enter again your settings in the captive portal.

It appears that the command clears the stored SSID and password. Doesn’t that mean you have to re-enter the credentials every time the power is cycled?

No, because I have commented out that reset command after the first run. After the “clean up” it works as you mentioned in your example. Don’t ask me why… It could be something due to the initial situation of my ESP8266, as in many other cases a restart or reset can help :wink:

Great work and thank you very much for sharing.
Your solution is already perfect as is. However, i have a question:
Since tzapu’s wifimanager meanwhile can fetch custom parameters, i dunno since when it can do that, would’nt it be nice to fetch the Blynk-token in the AP-mode at the time of first setup, instead of hardcoding it in the sourcecode?
Otherwise, seems like you have to edit your sourcecode for every new device.

However, pretty nice work already. I don’t intend to complain.
Im a noob also. So if this is a stupid question, don’t feel bothered.

Thank you…
Morpheouz

Thanks for the suggestion, @morpheouz

Yes, WiFiManager has had that capability for quite a while now, and I’ve seen it suggested on other projects.

I prefer to control several of my home’s IoT devices from a single Blynk dashboard, which means that the devices share one token. In such a case it might be more useful to allow input of each device’s virtual pin number, since that does need to be unique. However, to give maximum flexibility, I might put both options in the next iteration.

Thanks to @chrome1000 for posting such a wonderful project.

After a little bit of hickups I was able to setup the Wemos D1 mini with Blynk and my new Echo dot, what I found was that port D6 on the Wemos D1 mini was changing state when Alexa was asked to switch off or on the lights (virtual pin V1 set as per your program). Next I will try to emulate the Hue on the Wemos.

Yes, I could have been more clear about defining the pin numbers. Wemos D1 mini (and a few other dev boards) don’t use the same GPIO numbers as the generic ESP8266 boards. You need to match the relay and tac switch pin definitions to the numbering of your particular board. On a Wemos D1 mini, GPIO 0 and GPIO 12 are pins D3 and D6, respectively. which explains why Alexa changed the state of your D6.

I have the same problem (it works with Blynk but not Alexa). I’m using an Amazon Fire 7 with Alexa and an Android phone with the Alexa App installed and Alexa can’t find my sonofwemo.
I’ve even tried installing the Wemo App and it can’t find my devices. I’m getting a Dot for Christmas and hope that works.

The Fire tablet isn’t an Echo / Alexa device. It’s an Android tablet that’s been reskinned by Amazon. You need one of the Alexa products (Echo, Dot, Tap) to control Sonofwemo. The Dot you’re getting for Christmas will work fine with it.

Thanks chrome1000:

The Fire 7 came with Alexa pre-installed so I thought it might work.
Also, it was a real pain to install Blynk on the Fire 7 (couldn’t find Blynk on the Amazon App store) but once installed it works fine.
I bought a TP-link wifi switch for $5.00 when I ordered the Dot and had a hard time getting Alexa to find it (find new devices in the app always failed, had to use the speech command and that did finally work).
I can hardly wait till Christmas.
I have a question as well. I have been using Blynk with my garage door opener, and I was wondering if Alexa is able to handle a push button (momentary switch) as well as a on/off switch.