0-ESP32 Alexa ESP32 ESP8266 Project Tech

Alexa (Echo) with ESP32 and ESP8266

Alexa (Echo) with ESP32 and ESP8266

On this undertaking, you’re going to discover ways to management the ESP8266 or the ESP32 with voice instructions utilizing Alexa (Amazon Echo Dot). For instance, we’ll management two 12V lamps related to a relay module. We’ll additionally add two 433 MHz RF wall panel switches to bodily management the lamps. 

Observe: this tutorial is suitable with all Echo Dot generations and with the newest fauxmoESP library (three.1.zero). It really works with ESP32 and ESP8266.

Watch the Undertaking Video Demonstration

We advocate the next tutorials as a reference:

Challenge Overview

This challenge works each with ESP8266 and ESP32. We offer directions for each improvement boards. Earlier than getting straight to the venture, learn this part to see what you’ll obtain by the top of this challenge.

Management Lamps utilizing Alexa

By the top of this undertaking you’ll have the ability to management two lamps (lamp 1 and lamp 2) with voices instructions utilizing Alexa. The determine under exhibits a high-level overview on how the undertaking works to regulate lamp 1 – it really works equally for lamp 2.

Alexa will reply to the next instructions:

  • “Alexa, activate lamp 1”
  • “Alexa, flip off lamp 1”
  • “Alexa, activate lamp 2”
  • “Alexa, activate lamp 2”
  • “Alexa, activate lamps” activates each lamps
  • “Alexa, flip off lamps” turns off each lamps

Whenever you say one thing like “Alexa, activate lamp 1”, the ESP8266 or ESP32 will set off a relay to activate lamp 1. Whenever you say one thing like “Alexa, flip off lamp 1”, the ESP8266 or ESP32 will ship a sign to the relay to show off the lamp. This works equally for lamp 2.

Management Lamps utilizing 433 MHz Wall Switches

On this challenge, we’ll additionally add two 433 MHz wall switches to bodily management the lamps. You’ll have a change for every lamp. The change modifications the lamp’s state to the other of its present state. For instance, if the lamp is off, press the wall change to show it on. To show it off, you simply have to press the change once more. Check out the determine under that illustrates the way it works.

Elements Required

Right here’s an entire listing of the elements required for this undertaking (click on the hyperlinks under to seek out the most effective worth at Maker Advisor):

You should use the previous hyperlinks or go on to MakerAdvisor.com/instruments to seek out all of the elements in your tasks at the perfect worth!

Learn how to Purchase An Amazon Echo

You need to use the hyperlinks under to purchase an Amazon Echo. There are a number of fashions obtainable – all of them are suitable with this venture.

Shopping for an Amazon Echo by means of Amazon shouldn’t be attainable for all nations. We offer hyperlinks for Amazon in UK, USA, and Germany. If the Amazon Echo doesn’t ship to your nation via Amazon, you will get one from eBay (obtainable worldwide).

Echo Dot (2nd Era)

Echo (2nd Era)

Echo Present

433 MHz RF Wall Panel Change

The 433 MHz RF wall panel change is a good way to remotely management units. It may be simply hooked up to a wall with adhesive faucet, with out the necessity to make holes on the partitions. Moreover, it’s wi-fi, so that you don’t want to fret about wiring after which hiding cables.

On this challenge we’re utilizing two wall panel switches. As an alternative, you should use a panel change with two buttons – there are additionally one other model with three switches.

This wall panel change has a push button in its circuit, as proven within the determine under, that when pressed emits a 433 MHz sign. You should use that sign to regulate no matter you need. This wall panel change makes use of a 27A 12V sort battery (not included within the package deal). So, you might need to purchase one, once you get your wall panel change.

Decode the Wall Panel Change 433 MHz RF Alerts

Once you press the 433 MHz wall panel change, it sends a 433 MHz sign. It’s worthwhile to decode that sign utilizing a 433 MHz receiver. To discover ways to decode the 433 MHz sign learn the next publish: Decode and Ship 433 MHz RF Alerts with Arduino – learn the “Decoder Sketch” half. The sketch works with Arduino, ESP32, and ESP8266.

Pay attention to the decimal (24Bit) code for every of your switches, since you’ll want them later.

In my case:

  • change 1: 6819768
  • change 2: 9463928

You must get totally different values. You’ll then use these alerts in your ESP8266 or ESP32 sketch. If you press the change, it sends a 433 MHz sign. This sign is detected by the receiver that’s related to the ESP. This manner, the ESP is aware of the change was pressed and it inverts the lamp’s present state.

The FauxmoESP

To regulate your ESP8266 or ESP32 with Amazon Echo, it’s essential set up the FauxmoESP library. This library emulates a Belkin Wemo system, permitting you to regulate your ESP32 or ESP8266 utilizing this protocol. This manner, the Echo or Echo Dot immediately acknowledges the gadget, after importing the code, with none additional expertise or third get together providers. You’ll be able to learn extra about FauxmoESP right here.

Putting in the FauxmoESP Library

  1. Click on right here to obtain the FauxmoESP library. It is best to have a .zip folder in your Downloads
  2. Unzip the .zip folder and you must get xoseperez-fauxmoesp-50cbcf3087fd folder
  3. Rename your folder from xoseperez-fauxmoesp-50cbcf3087fd to xoseperez_fauxmoesp
  4. Transfer the xoseperez_fauxmoesp folder to your Arduino IDE set up libraries folder
  5. Lastly, re-open your Arduino IDE

Alexa – Echo Dot with ESP8266

Comply with these subsequent directions in the event you’re utilizing an ESP8266.

Putting in the ESP8266 Board in Arduino IDE

To be able to add code to your ESP8266 utilizing Arduino IDE, you need to set up an add-on for the Arduino IDE that permits you to program the ESP8266 utilizing the Arduino IDE and its programming language. When you haven’t put in the ESP8266 add-on for the Arduino IDE, comply with the subsequent tutorial:

Putting in the ESPAsyncTCP Library

You additionally want to put in the ESPAsyncTCP Library library. Comply with the subsequent directions to put in it:

  1. Click on right here to obtain the ESPAsyncTCP library. You need to have a .zip folder in your Downloads
  2. Unzip the .zip folder and it is best to get ESPAsyncTCP-master folder
  3. Rename your folder from ESPAsyncTCP-master to ESPAsyncTCP
  4. Transfer the ESPAsyncTCP folder to your Arduino IDE set up libraries folder
  5. Lastly, re-open your Arduino IDE

Schematic

When you’re utilizing an ESP8266 board, assemble your circuit by following the subsequent schematic diagram – you’ll be able to click on the picture to zoom.

In case you’re having hassle following the circuit diagram, you should use the next desk as a reference:

ESP8266 Hook up with
GPIO 5 433 MHz receiver knowledge pin
GPIO four Relay IN1 pin
GPIO 14 Relay IN2 pin

 

IMPORTANT NOTE: earlier than making use of energy, ensure you set your step-down buck converter output voltage to 5V! In any other case, you might injury your ESP.

Alexa – Echo Dot with ESP32

Comply with these subsequent directions in case you’re utilizing an ESP32.

Putting in the ESP32 Board in Arduino IDE

So as to add code to your ESP32 utilizing Arduino IDE, you must set up an add-on for the Arduino IDE that lets you program the ESP32 utilizing the Arduino IDE and its programming language. When you haven’t put in the ESP32 add-on for the Arduino IDE, comply with the subsequent tutorial:

Putting in the AsyncTCP Library

You additionally want to put in the AsyncTCP Library. Comply with the subsequent directions to put in it:

  1. Click on right here to obtain the AsyncTCP library. You must have a .zip folder in your Downloads
  2. Unzip the .zip folder and you must get AsyncTCP-master folder
  3. Rename your folder from AsyncTCP-master to AsyncTCP
  4. Transfer the AsyncTCP folder to your Arduino IDE set up libraries folder
  5. Lastly, re-open your Arduino IDE

Schematic

In case you’re utilizing an ESP32 board, assemble your circuit by following the subsequent schematic diagram – you possibly can click on the picture to zoom.

 

For those who’re having hassle following the circuit diagram, you should use the next desk as a reference:

ESP32 Hook up with
GPIO 13 433 MHz receiver knowledge pin
GPIO 14 Relay IN1 pin
GPIO 12 Relay IN2 pin

 

IMPORTANT NOTE: earlier than making use of energy, be sure to set your step-down buck converter output voltage to 5V! In any other case, you could injury your ESP.

Code

Copy the next code to your Arduino IDE, however don’t add it but! You should make some modifications to make it be just right for you.

Choosing the suitable board

This code works each with ESP32 and ESP8266. To make it work on your board, you must choose the board you’re utilizing in Instruments > Board. Choose your ESP8266 or ESP32 mannequin.

Add your community credentials

You should modify the next strains to incorporate your community credentials.

#outline WIFI_SSID “REPLACE_WITH_YOUR_SSID”
#outline WIFI_PASS “REPLACE_WITH_YOUR_PASSWORD”

Add your 433 MHz sign codes

You additionally want to incorporate the alerts you’ve decoded beforehand on your wall panel switches.

Substitute the worth highlighted in purple with the worth you’ve gotten for the change that controls lamp 1:

if (mySwitch.getReceivedValue()==6819768)
  digitalWrite(RELAY_PIN_1, !digitalRead(RELAY_PIN_1));

And the worth for lamp 2 within the following:

if (mySwitch.getReceivedValue()==9463928)
  digitalWrite(RELAY_PIN_2, !digitalRead(RELAY_PIN_2));

Importing the code

After making all the required modifications, you possibly can add code to your ESP. Ensure you have the proper COM port chosen, in Instruments > Port. For demonstration functions, you possibly can open your Serial Monitor at a baud fee of 115200, when you put together your Echo Dot.

Alexa, Uncover Units

With the circuit prepared, and the code uploaded to your ESP8266 or ESP32, you might want to ask alexa to find units.

Say: “Alexa, uncover units”. It ought to reply as proven within the determine under.

Alternatively, you may also uncover units utilizing the Amazon Alexa app, by following the steps proven within the determine under.

Then, ask Alexa to activate/off the lamps. You’ll additionally get details about the lamps state on the Serial Monitor.

After ensuring all the things is working correctly, you’ll be able to flip your circuit right into a everlasting answer.

Demonstration

For demonstration functions, we’ve constructed our circuit in a prototyping stripboard, and hooked up every thing in a picket board, as proven within the determine under:

Now you possibly can ask Alexa to regulate your lamps with the next voice instructions:

  • “Alexa, activate lamp 1”
  • “Alexa, flip off lamp 1”
  • “Alexa, activate lamp 2”
  • “Alexa, activate lamp 2”

You can even management each lamps on the similar time by creating a gaggle within the Amazon Alexa app. We referred to as it “lamps”.

Now, you possibly can management each lamps on the similar time, utilizing the next voice instructions.

  • “Alexa, activate lamps”
  • “Alexa, flip off lamps”

It’s also possible to bodily management your lamps utilizing the 433 MHz wall panel switches.

Wrapping Up

On this challenge we’ve proven methods to management your ESP8266 and your ESP32 with voice instructions utilizing Amazon Echo. For instance, we’ve managed two 12V lamps utilizing a relay. As an alternative of 12V lamps, you possibly can management some other electronics home equipment. We’ve additionally proven you how one can remotely management your lamps utilizing a 433 MHz wall panel change.

We hope you’ve discovered this challenge helpful. Should you appreciated this publish, you might also like:

Thanks for studying.

Beneficial Assets