Smart Home Using Amazon Alexa

Introduction: Smart Home Using Amazon Alexa

The Basic idea behind this project is to control an electronic appliance using Amazon Alexa or through its app from anywhere in the world. We will be using a Node MCU V1.0 for this. All the code will be on my Github Page. If at any point you don't understand a step feel free to comment down below and I shall respond to it at the earliest. All Credits for the servers as well as the code goes to kakopappa( I have modified the code to control 4 Relays for the purpose of this tutorial. Well, Lets get started!

Note: This tutorial assumes that you have some knowledge about Arduino IDE and Node MCU.


  1. Node MCU V1.0
  2. 4 Relays(Relay Bank)
  3. Jumper wires
  4. Breadboard
  5. An External Power Source

Step 1: Create an Account on

The first thing that you have to do is go to and create an account(Its Free). Sinric allows you to control your micro-controller over the internet. You will then get an API key which will be unique to your account. You will use this key later in your code. The next thing we have to do is add a device. This is done by Clicking on the "Add" button. Create a name for your device which you will then use to call via Alexa. In device type choose "Switch" and then click Save. This will create a device id for your device which is also going to be used in the code. In the Alexa app enable the Sinric skill for your Amazon echo so that it can discover the newly created devices.

Step 2: Wiring the Circuit

Wire the circuit as Follows or follow the fritizing diagram attached:

Relay----> ESP

VCC ------->Vin





JD-VCC-->Positive of external Power Supply

GND------->GND of external Power Supply

Since the NodeMCU cannot power the relay bank alone an external power supply is needed to power it.

The relays are connected in between the appliances by breaking the live wire and inserting them in the each relay like in a switch.

Step 3: Uploading the Code to the NodeMcu

The Code is uploaded here:

The libraries you will be needing are ArduinoJson(install version 5.13.2) and Arduino websockets(get it from:

Dont forget to configre the Board to Node MCU v1.0.

Based on the number of relays you need you can modify the code to add more. The changes required would be to define a new pin and add another else if loop with the new device id. You can even change the pins as per your liking by reffering to this pin chart at

This tells you which GPIO is what in on the Arduino. Basically if you want to change your relay pin from D4 to D3 the change in the code will be as follows:

Previous Code:

#define MYPIN2 2 //D4

New Code:

#define MYPIN2 0 //D3


Anything after // is a comment on the same line and is not considered by the compiler.

Step 4: Configuring the Amazon Echo

To Control the devices using Amazon Echo you need to first set them up. You can do this by saying "Alexa,Discover Devices". It will take 20 seconds and it should discover your switches. You can now say "Alexa, Turn on device name" to turn on your device and vice versa. You can control it from the Alexa app as well by going to the Devices Section of the app.

Step 5: The End

I hope you did not face any problem while following this Instructable. If you have any queries please drop them below in the comments section.

If you want to support me in any way here is my Paypal ID :

Be the First to Share


    • Mason Jar Speed Challenge

      Mason Jar Speed Challenge
    • Bikes Challenge

      Bikes Challenge
    • Remix Contest

      Remix Contest



    1 year ago

    Thank you for sharing! : )