Voice-Controlled Relay with ESP32 and ESP8266

Reporting from Shanghai, China
Apr 2, 2018

Rui Santos’s RNT blog responds to the voice-control trend and shows how ESP32 and ESP8266 can be used with Alexa, Amazon’s cloud-based voice service.

Voice command is currently trending high in the IoT industry, since it is estimated that 50% of all web searches in the next couple of years will be performed with a voice-command device (VCD). Contributing to this trend, Espressif Systems has just released two Audio Development Boards, ESP32-LyraTD-MSC and ESP32-LyraT. Both of them are based on the ESP32-WROVER module, which has a dual-core processor and 4.5 MB of operating memory, thus requiring the use of only few peripherals for a complete audio solution. Our audio-development boards can function over Wi-Fi and/or Bluetooth, while supporting major cloud-voice vendors, such as Amazon’s Alexa, Google’s Assistant, and Baidu’s DuerOS.

For educational purposes, however, the RNT blog has just released a tutorial  showing how to control ESP8266 or ESP32 with voice commands, using Alexa. As an example, two 12V lamps turn on/off  with voice commands given to either of the Espressif boards being used. Additionally, two wireless 433 MHz switches on a wall are used for physically controlling the lamps. 

With the voice-control method, Alexa can respond to spoken commands, such as:

  • Alexa, turn on|off lamp 1
  • Alexa, turn on|off lamp 2
  • Alexa, turn on|off lamps” [turns on/off both lamps.]

When giving the first command, the ESP8266 or ESP32 will trigger a relay to turn on lamp 1. A similar procedure is followed when the user wishes to turn off this lamp, or to turn on/off the second one, or even both of them.

Alexa ESP

To control ESP8266 or ESP32 with Amazon Echo, users need to install the FauxmoESP library. This library emulates a Belkin Wemo device, allowing to control ESP32 or ESP8266 using this protocol. Thus, after uploading the code, Amazon’s Echo or Echo Dot instantly recognizes the device without any extra skills or third-party services.

The physical-control method enables turning on and off the lamps with two 433 MHz wall switches. Each lamp responds to a different switch. Each switch, then, changes the respective lamp’s state to the opposite of its current state. For example, if the lamp is off, the wall switch must be pressed for the lamp to be turned on. To turn it off, users need to press the switch again.

433 switch ESP

The 433 MHz RF panel switch on the wall is a great way to remotely control devices. When pressing the switch, it sends a 433 MHz signal. Users need to decode that signal with a 433 MHz receiver. The switch can be easily attached to a wall with adhesive tap, without making any holes on the wall. Additionally, it is wireless, so there is no need for wiring and, subsequently, hiding any cables. This project uses two wall panel switches. Alternatively, a panel switch with two buttons could be used, while there is also another version with three switches, in case one wishes to use three lamps.

To find the full tutorial, with all its details, code and schematics, click here.

Share this article
Reuse this content