Introduction: Trigger Amazon Alexa With an ESP8266

That's right as the titles says. Actually anything that can visit a URL such as a Raspberry PI, ES8266, ESP32 even a web browser or code running on a web server like PHP, JS ..... and the list will go on forever.

Just as long as it can visit a URL.

I needed a way to trigger an Alexa routine remotely via an ESP8266 which is connected to a Solar PIR motion sensor that runs off an 18650 battery.

At the time I could only find one skill that would allow me to do that but you only get one "Virtual Button" for free. The rest you have to pay for. And I don't want to have to worry about subscription and credit cards and things to extend the functionality of my Amazon echo.

Then i found LittleNodes.com which is a basic IOT platform that allow me to do just that. When signing in and navigating to the Virtual button panel you will get 10 Virtual buttons which is enough for what I want to do.

Supplies

ESP8266

Amazon Echo

Optional: Wall mounted solar powered motion sensor & LED

Littlenodes.com account linked to Alexa via the LittleNodes Virtual Button Skill which can be found in the Alexa Skill store.

Step 1: Create a LittleNodes.com Account

First things first!.

Follow the below instructions it wont take long.

1. Visit www.littlenodes.com and sign up for an account.

2. After signing in, navigate to the Virtual button panel via the "Alexa Virtual Buttons" menu.

3.When visiting the button page for the first time it will create 9 disabled and 1 active virtual button. You can click "Edit Buttons"if you wish to enable the other 9. But for now we will only use one.

4. In the Alexa app, find the skill called "LittleNodes Virtual Buttons" and add it. Once you added it go into the skill and allow the skill to link to LittleNodes.com. You will be taken to a LittleNodes login screen. Login with your credientials and allow the linking request.

5. Create a routine by adding the LittleNodes.com virtual device to the section "When This Happens" and then also add an action"Alexa Says" choose custom and type a message. Example: "There is movement near the garage"

Important: For the next step you will need the web url with embedded API key to virtually "Press" the button.

As shown in the picture of this step you can find the URL for each button on the button card from the button panel page. Click the "Show API" URL to reveal the link.

In the meanwhile copy the above mentioned link. But before you continue to the next step. Press the "Trigger" button on the LittleNodes Button Panel to test if Alexa will trigger. You should hear alexa speak out the sentance you types in the routine.

Step 2: Program the ESP8266 With a Sample Sketch.

For starters program your ESP8266 with the example sketch which you can also find on LittleNodes.com under the documentation menu.

See below link

https://littlenodes.com/docs.php?page=esp8266.php

After you get everything to work you can change the sketch to do other stuff if you like.

Change the access point and password to your AP SSID username and password.

const char* ssid = "Accesspoint_SSIS"; const char* password = "Accesspoint_Password"; <br>

Aswell as the link which is used to trigger the routine you created in the previous step.

const char* host = "https://www.littlenodes.com/api/alexa/triggeralexa.php?email=EMAIL@emailaddress.com&apikey=API_KEY_HERE";

And you are done Upload the sketch!

After uploading , sometimes its necessary to press the reset button on the ESP if you are using a NodeMCU variation or just power it down and power it up again.

The sketch will start up, establish a connection visit the link and then go into deep sleep whilst the LED lights up for a few more minutes. Deep sleep is not necessary but it helps to save some battery power.

Step 3: Connect the ESP8266 to Your Solar Lamp.

I connected the ESP8266 in parallel with the LED lamp. Positive to the ESP8266 3V pin and negative to the GND pin.


In my case the solar lamp drives the LED with 3V and not 3.7 or 4.2v directly from the 18650 battery. Its a good Idea to measure the voltage and use something to tone down the voltage with a regulator or buck boost.. The ESP8266 is quite sensitive to incorrect voltages.

After connecting it with the lamp close it all up and off you go! You now have a solar powered motion sensor that works with Alexa.