LED Control using Alexa and Google Home | Automation Ecosystem

"Effortlessly control your LED lights using voice commands through Alexa and Google Home in your smart home automation ecosystem. Transform your space with customizable lighting experiences. Learn how to set up seamless integration for a modern and convenient lifestyle."

Aug 7, 2023 - 21:55
LED Control using Alexa and Google Home | Automation Ecosystem
LED Control using Alexa and Google Home | Automation Ecosystem
Hello everyone, welcome and in this tutorial, I will show you how to integrate Alexa and Google Home to Control LEDs. Follow the below steps to help you get it done.
Hardware Requirements:
  • Breadboard
  • NodeMCU-Esp8266.
  • 3 x LEDs (Red, Green, Yellow).
  • USB micro-B cable.
  • Jumper wires.
  • PC/Laptop
Software Requirements:
  • Sinric Pro 
  • Alexa 
  • Google Home
 Connection/Circuit Diagram:

  • Connect Esp8266 to the breadboard as shown above.
  • Connect 3 LEDs, Green, Red and Yellow to the breadboard.
  • Connect the GND pin from Esp8266 to the GND rail of the breadboard.
  • Connect the pins D1(GPIO 5), D2(GPIO 4), and D3(GPIO 0) to Green, Yellow, and Red respectively.
  • Connect the negative terminals of the LEDs to the GND rail from the breadboard.
NOTE: Make sure there is a close and firm connection when connecting the negative terminals of the LEDs to the GND rail from the breadboard.
Sinric Pro Setup:
1.Open your browser and type sinric pro or else click on the link Sinric Pro - Connect Amazon Alexa, Google Home with esp8266, esp32, raspberry pi, RP2040
2.The below will be displayed on the screen,  click on sign up to create an account.
3. Fill in the details to register. 

4. After that then you can log in to your account. Click on Devices>Add device.
Give names for the devices, Green LED, Red LED and Yellow LED. Write anything of your choice in the description, leave everything that comes next as default, and continue clicking next until the device is created. Then you can check it in the dashboard. Repeating the same for Red and Yellow LEDs. The maximum number of devices you can create for a user using free service is three.

5. Next, click the Devices to show you the list of devices you created. 

6. The next thing, open Arduino IDE, click on the below options in the screenshot. File>Examples>Sinric Pro>Relay>Muti-relay_advance.

Copy the below code:

       #define DEBUG_ESP_PORT Serial
       #define NDEBUG

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <SinricPro.h>
#include <SinricProSwitch.h>

#define RELAYPIN_1 D1
#define RELAYPIN_2 D2
#define RELAYPIN_3 D3

 * Configuration *

struct RelayInfo {
  String deviceId;
  String name;
  int pin;

std::vector<RelayInfo> relays = {

 // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"
// Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"

#define BAUD_RATE  9600              // Change baudrate to your need

bool onPowerState(const String &deviceId, bool &state) {
  for (auto &relay : relays) {                                                            // for each relay configuration
    if (deviceId == relay.deviceId) {                                                       // check if deviceId matches
      Serial.printf("Device %s turned %s\r\n", relay.name.c_str(), state ? "on" : "off");     // print relay name and state to serial
      digitalWrite(relay.pin, state);                                                         // set state to digital pin / gpio
      return true;                                                                            // return with success true
  return false; // if no relay configuration was found, return false

void setupRelayPins() {
  for (auto &relay : relays) {    // for each relay configuration
    pinMode(relay.pin, OUTPUT);     // set pinMode to OUTPUT

void setupWiFi() {
  Serial.printf("\r\n[Wifi]: Connecting");

  while (WiFi.status() != WL_CONNECTED) {
  Serial.printf("connected!\r\n[WiFi]: IP-Address is %s\r\n", WiFi.localIP().toString().c_str());

void setupSinricPro() {
  for (auto &relay : relays) {                             // for each relay configuration
    SinricProSwitch &mySwitch = SinricPro[relay.deviceId];   // create a new device with deviceId from relay configuration
    mySwitch.onPowerState(onPowerState);                     // attach onPowerState callback to the new device

  SinricPro.onConnected([]() { Serial.printf("Connected to SinricPro\r\n"); });
  SinricPro.onDisconnected([]() { Serial.printf("Disconnected from SinricPro\r\n"); });

  SinricPro.begin(APP_KEY, APP_SECRET);

void setup() {

void loop() {
7. Delete the below code that shows when clicking on multi-relay and replace it with the above code.

8. Next go to Sinric Pro and copy each device token and replace them in the below section in the code on Arduino IDE respectively.
std::vector<RelayInfo> relays = {
After that type your WIFI SSD and Password.
 Next, go to credentials and copy APP KEY and APP SECRET.

Paste them in this section of your code respectively.

9. Go back to Arduino IDE and connect the USB from esp8266 to your PC then click>Tools>Board>Esp8266>NodeMCU 1.0(Esp-12E Module). In case you don't find the board install by clicking board manager, then type esp8266 in the search box.

If the connection between Esp8266 and Wi-Fi is successful, a connection is established with Sinric Pro and it will display 3 devices online on the dashboard as shown below.
10. Go to the Google Play store and install Amazon Alexa and Google Home. For the latest versions 
of Androids, it's already installed.
11. After that then open the Alexa app and link it with Sinric Pro. Click>More>Skills and Games.     
12. Click on the search icon, type Sinric Pro. And it will be shown as the first one. Simply click on it and link it with Alexa.

13. You can link Google Home with Sinric Pro. Open Google Home >Create a new home and give it a name for example My Smart Home Assistant. Add a Device>Works with Google, type Sinric Pro in the search bar and then link it with Google. You can either use Alexa or Google Assistant to command.
Finding: A unique feature of Google Assistant over Alexa, you can command all the LEDs to be turned on/off at once.