🗣️ Voice-Controlled Appliances
Hey Google, turn on the lights. Emulate a smart home device using an ESP32.
Overview
By pretending to be a Belkin Wemo smart plug or using a cloud service like Sinric Pro, the ESP32 can connect directly to Amazon Alexa or Google Assistant.
What you'll learn: Third-party IoT cloud integrations, voice command parsing, and AC relay control.
Estimated time: 2-3 hours. Difficulty: ⭐⭐⭐ Intermediate.
Components Needed
| Component | Specification | Qty | Notes |
|---|---|---|---|
| ESP32 Development Board | WiFi | 1 | |
| Relay Module | 5V | 1 | |
| Appliance | e.g., Desk Lamp | 1 | USE CAUTION WITH AC VOLTAGE |
Step-by-Step Tutorial
1
Create IoT Account
Sign up for a service like Sinric Pro or use the FauxmoESP library.
2
Configure Tokens
Enter your Wi-Fi credentials and the API keys/Device IDs from your IoT platform into the sketch.
3
Wire Relay
Connect the relay to an ESP32 GPIO pin (e.g., GPIO 13).
4
Link Account
Open the Alexa or Google Home app and link your IoT account to discover the new device.
FauxmoESP emulates Philips Hue / Wemo devices locally (no cloud needed) but only works with Alexa. For Google Assistant, you must use a cloud broker like Sinric.
Code / Configuration
voice_lights.ino
INO
// Voice Controlled Lights (Sinric Pro conceptual)
#include <WiFi.h>
#include <SinricPro.h>
#include <SinricProSwitch.h>
#define WIFI_SSID "YOUR_SSID"
#define WIFI_PASS "YOUR_PASS"
#define APP_KEY "YOUR_APP_KEY"
#define APP_SECRET "YOUR_APP_SECRET"
#define SWITCH_ID "YOUR_DEVICE_ID"
#define RELAY_PIN 13
bool onPowerState(const String &deviceId, bool &state) {
Serial.printf("Device %s turned %s\r\n", deviceId.c_str(), state?"on":"off");
digitalWrite(RELAY_PIN, state ? HIGH : LOW);
return true;
}
void setup() {
Serial.begin(115200);
pinMode(RELAY_PIN, OUTPUT);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while(WiFi.status() != WL_CONNECTED) delay(500);
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];Reviews & Ratings
—0 reviews
Sign in to leave a review
Loading reviews...