Alexa Smart Home Automation system using NodeMCU ESP8266 & Relay Module | IoT Projects
HTML-код
- Опубликовано: 8 фев 2025
- In this IoT project, I have made the Alexa Smart Home Automation system using NodeMCU ESP8266 & Relay Module. You can control lights, fans, and other home appliances with the voice command. I have used only the Amazon Alexa app to connect the Echo Dot smart speaker with the NodeMCU.
JLCPCB Prototype for $2(Any Color): jlcpcb.com
Download PCB Garber file for this NodeMCU project
drive.google.c...
Required Components for this Alexa smart home project
1. NodeMCU or ESP32 board amzn.to/3fJA4EG
2. Relay Module amzn.to/2BQ5Y3o
3. Alexa Echo Dot amzn.to/2PkTOTe
Required Components for Relay Module:
1. Relays 5v (SPDT)
2. BC547 Transistors
3. LED 5mm
4. 220-ohm Resistors
5. Connectors
Download Code for this Alexa Home Automation projects
drive.google.c...
During the video, I have shared the circuit diagram for this Alexa control home automation and also explained the code for this IoT project. This is a very simple home automation project, so you can easily make this smart home device with NodeMCU and Relay module. I have also shown how to set up the Amazon Alexa app for this smart house project. You can control up to 10 home appliances with Alexa.
There is a limitation, the NodeMCU, and the echo dot smart speaker should be connected with the same wifi network.
If you face any issue please let me know in the comment section.
------------------------------------------------------
Thanks For Watching...
✅ SUBSCRIBE ✅LIKE ✅SHARE ✅ COMMENTS
Find out more such projects: easyelectronic...
Find us on Facebook: / techstudycell
-------------------------------------------------------
Other smart home IoT projects:
Latest ESP32 projects playlist:
• ESP32 Projects
How to make Smart Home using Arduino Bluetooth IR & Sensors
• How to make Smart Home...
Home Automation using Google Assistant, Blynk, IFTTT, NodeMCU
• Home Automation using ...
IoT based Home Automation with sensors and NodeMCU control Relay | Real-Time Feedback
• IoT based Home Automat...
#Alexa
#SmartHome
#TechStudyCell
Thank you very much, with a little code adjustment and additional wring I have mine set up with an 8-way relay and it works perfect.
I have already made an video on Alexa 8 Relays. Please refer this video ruclips.net/video/b5yr-H6jJAc/видео.html
Simple but useful home automation project👍👍👍
Thanks
Thanks a lot mate. i have used several tutorials . not worked but yours . i thanks sooo much. i have subscribed at once.
Great 👍
Thank you for the video bro I do exactly and it work superbly when ever my nodemcu is reboot or power cut relay state is turn to normal can you do it to remember the previous relay state something like that to turn which ever device is turned on or not
A big big shout out to Tech StudyCell. Saw a lot of other videos but this is the one that worked.
Thanks
Great Brother. Really you are a great teacher.
it is working good but I have some issues
when ever power cuts and comes back all device turns on
can u tell me the code to turn them default off after every restart.
Can it control with mobile alexa
Thanks for explanation and the code it worked for me. Initially, the devices are not discovered after restarting and trying it again it got detected. :-) :-)
Is it working for you brother? I am going to use this code for my project
This is AWESOME, THANK YOU, saved, liked & subscribed
Thanks. You may also like our other home Automation project with Alexa. Please visit our channel.
@@TechStudyCell Already have, I am loving your channel, you really have helped me decipher this ‘black art’ programming is easy. But knowing nothing, makes learning about IoT very hard as I do not even know what to research.
Fantastic, thank you. The NodeMCU is such a great device. Next port of call will be the Nano T-Call for long range projects.
Unless you have a better suggestion? 🤔🤔🤞
Nice project.
Thanks
thanks bro it worked for me
Great 👍
beautifully explained...... thank you study cell for making this video... hope 2 see many in future.. :)
Thanks for your feedback...
Sir ssid new bnate hai ya hospot hota hai
Extremely helpful video
We can control the lights with the alexa app also right??
Can we check with google home and google assistant?
Always usefull. Thanks!
Nice project, attractive way of explaining thank you, but I have a question, all the Alexa smart home videos with esp8266 focus on direct contact with relay, can you make a video that you change that to UART message to be received by another system (aurduino or microcontroller) that can control larger number of relays and maybe other systems also?
is this same think processible using google assistant
can you describe the rest of the components you saw in the project. For example, what value are the diodes and what are the resistors that are next to the connection block. The resistors that are between the LEDs do not look like 220 because their code starts with black. Can you provide more information or a wiring diagram for this device? Regards. Adam.
While searching aleaxa finds only one device can u tell me how to solve this issue
Thank you
Welcome
after uploading your code esp is not connected with my wifi i have cheaked ssid password which i put correct but stile it is not connected with my wifi
Sir.. can i connect 8 or 16 channel relay ... It can possible to control.... I want to control ten motors using relay by voice commands
Successfully executed your processes. But one drawback is , when power cut happened, during the time of come back of power, all the bulbs are stared running even you don't want them to run. Could you please suggest any solution!???
how many relay control and add device from alexa? issue only 10 device discovred
Hii . I made thi project in 2021 and it was working perfectly but in 2024 when m trying to pairing device with alexa, alexa is not showing device or pairing. Will you please guide me ?
Can we connect multiple ESP32 devices to the same account as shown in the video?
supply to relay is from nodemcu???? if yes explain how because it output is 3.3V...
Hello this is amazing thank you very much
But I have a question
If I need the lamp turn on just for 1 second thin turn of automatically what i can do
((I need a button not switch))
I have made this home automation system I am not able to find out the devices in alexa can you please help me for my issue
Great job ♥♥♥
Should I buy Alexa Echo Dot to do this project or does it work without it (just alexa App) ??
Thanks. Please refer this video ruclips.net/video/Sx9akwBwK4g/видео.html
You don't need echo dot.
Inbuit option for retaining the same state as before power failure should be used. My humble request to you to help me for this.
YOUR CORD all upload done but onther step alexa not working. what is the problem.
i m gettin no device found on alexa app. what to do. even i unplugged the alexa and plugged it again.
Is it contains 2 stages
i am having trouble connecting my lights to relay board please help
Many thanks for sharing the code. How can you change the device type to something other than Lights
Any mains powered device with work, if connected to the relay in the same way.
@@tonysicily2687 hi yes, I realise that. I was referring to the device type in the Alexa app. They are all device type "Lights". What if I want it to be type "Plug", "Switch", "TV" or "Fan" for example?
@@paulpkae ah ok, thanks for clarifying, hopefully some one can help you. The best of luck 👍👍
I also have the same question
Is it able to control from another network or internet (not same wifi network) through alexa?
Obviously nodeMcu will be connected to a fixed alexa device or a mobile which have alexa.
Can we control the devices manually by the wall switches along with this?
Great job. How would you add a sensor/digital read to tell the status of an input?
i have the same question
Great video, can you tell me if I actually need a echo device to discover the nodemcu. Right now I have a fire tv cube and using the Alexa app on my iPhone and it doesn’t seem to be able to discover it
Thanks. Yes, you need an Alexa device like echo dot.
@@TechStudyCell thanks for getting back to me so quick
Hello greetings from Mexico.
Is it necessary to connect the components (the led or spotlight)?
Or is it enough to load it to the nodemcu without connecting the components?
Since I load the code, but without component, I look for the devices but my echo dot 3gn has not found them
Did u solve the problem of finding devices. Please let me know. ahmadnomi52@gmail.com
Will this code works without Alexa Smart Speaker... Actually I want the alternative of Blynk
Alexa not detecting node mcu8266, no compilation error
Brilliant! I tried to add another 5 output relays but I couldn't - wonder if you can help
I copied everything that include the setting and pasted and changed the values but couldnt
as soon as l add after the Serial.begin(115200); it compiles but will not run
Help would be great
Thanks in advance
Erik Hoffman
Please refer the following video ruclips.net/video/OJ4CzWyRQr4/видео.html
I have added more features and shown each steps in details. Thank you.
Hey buddy can we directly connect google home mini instead of Alexa to Aurdino library as you shown???I dont wanna use blynk app or ifftt etc..
your code is working fine. But I have one issue which is when power fails it will not retain last On state, It reset to Off.Kindly update this.
Hi Tech StudyCell, how to change the wake word like turn on light to open light...
Nodemcu program not sure
USB not connected error please solution
sir can we add manual buttons to it?
Hiw you get this ok feedbacks from alexa
Sir.. Alexa coading made by you is very good. How can we make manual switch coading in that. Pls send me video. I want Esp8266 code board
I will try to cover that in upcoming videos. Thanks.
Is it possible to do with Mobile hotspot
i want to interface a small led without relay do i need to change the code for that?
NO
I using your code for my project but cannot find the device in alexa app......i am just using the app on my phone i dont have smart speaker, but my phone and mcu board is connected with the same wifi.
Please help
Do you need echo device or you can just use alexa app also to connect? Since i dont have echo but trying your code using app it says not device found!! (in serial debug window it shows connected to my wifi). Your reply is appreciated!
All relays turn on at boot, is there any way to solve this?
Great video man! thanks a lot!
You are welcome
ESP 8266 not reponding to Alexa when use local wifi router, its only work on mobile hotspot
is there any limit of number of devices with ESPALexa.h library?
Bro can you please share a code that works with alexa and Google assistant as well. I use both devices and since ifttt is no longer free my old code doesn't work anymore.
Is there a way to turn off the bulbs trought arduino?
Can't keep the power on and off without resetting?,😇
Hi Iam not able to see in alexa app any lights or discoverable in the app, NodMCU & my mobile & Alexa echo Show its in the same network
Just restart the echo dot, then try again. Please refer this video ruclips.net/video/OJ4CzWyRQr4/видео.html
I need your help please help me
My alexa is not able to find the devices but before it was able to find and again o got the same issue please help me
I made it but Alexa aap not add this module I tried many times but it app show no device find .
bro solve my problem please
Sad thing is that this reset when a power outage occurs, anyone has solved this?
A few solutions that I can think are:
*use a power bank to power device, and connect that power bank to a usb charger to always have energy.
*Use a battery module thingie to power it, same as power bank but gives more options when designing
*I believe these devices have onboard persistent storage, but I think it has short life so making some code that has this in mid is important, something like “every hour write the last state of device”, that or storing this last state on a separate server or storage device
For integrating with Alexa, is it necessary to do coding in the firmware itself?
no echo dot , no sinric pro //// only esp and android with alexa app installed any possibilities ?????
Not possible till now
Bhai tmam lights reverse operate kar rahi turn on bolny par band ho rahi ha or turn off bolny par chal rahi ha ...ye code ma problem ha ya connections ma kindly tell ma
Hi can you explain why only 10 devices can be connected with Alexa using this method and how to overcome this limitation.
how can i continues this project without ur custom pcb ?
Is it necessary to have an Alexa device or just use my phone to search for it? I don't have Alexa, but I tried the Alexa app to find it, but I couldn't find the device set according to the code.
For this project you must have an Alexa device.
If you don't have any Alexa device then please refer to the following video
ruclips.net/video/Sx9akwBwK4g/видео.html
Good Afternoon, I really hope someone sees this comment and can help. I am doing this project for a Senior Project for my graduation requirement. The code is working fine for me but when I connect the lights to Amazon Alexa it only discovers one 1 device. When I delete the device it found it finds the next one. Can someone help.
Everything I did as per your Video.but Alexa not detecting any lights. Please help me
I will try and let you know...
Sure
Can we possible with alexa app only without speaker sir?
Yes. You have to use Sinric. No Echo dot required.
Please refer this video ruclips.net/video/Sx9akwBwK4g/видео.html
bhai plz make a project of all in one, like 4 lights & fan with speed slow n fast with push button also
Hi, I tried this and it worked well. but can you give some information on electricity consumptions as Im planning to use it in my home for 24x7
Power consumption is very low. Less than 1 watt
Hello.
I want to do a smart home project that responds to voice commands using Amazon Alexa.
The idea is that I have to give up relays and I have to use control circuits for force.
Can you help me?
You didn't give the all components name
hey bro. why i can't use esp 8266 Controlsle for this fan
Without Alexa dot
Can we use this with alexa app
If you don't have echo dot, please refer to the following video ruclips.net/video/gpB4600keWA/видео.html
Hi i have setup all the connection and uplaod the code on the NodeMCU the last part when i faced problem when connect alexa app in the app it shows me no device found yet i dont know what is the problem please advice
This is common problem. Please check NodeMCU and echo dot conneted with same WiFi.
If you face same issue please try 2-3 times.
@@TechStudyCell hi sir it connect but when u give command to alexa to open both bedroom light it shows on the amazon alexa app on but no the lamp it doesnt trigger the relay to open light any advice in this project i only used two channel relay n two lamp i would like to buy ur PCB send me ur number so that we can talk about the PCB
If both conneted, then you should see the device name in Alexa App. Other wise restart Alexa and add the device as shown in video
Can I use an 8 channel board with same set up for controlling 8 bulbs. What would be the changes needed
Yes. Please refer this video ruclips.net/video/b5yr-H6jJAc/видео.html
Does this work also with Echo Flex?
Yes
Bro.2 channel kaam nhi kar rhe hain please help..i followed all steps carefully..
Can you include Wifi manager in this code
I m faceing some problem with alexa and node mcu, alexa is not getting connected can someone help me?
Sir ek Q hei h...hme relay ko on krna h bt ek specific time tk on rkhna h ..jese 5 sec tk or fir apne aap off honi chaiye...supose i command that alexa turn on relay 1 and its on bt for 5 sec ..and i want it automatic off after 5 sec..
add delay in that executed file
for eg. in code
to make these changes in
first device
void firstLightChanged(uint8_t brightness)
{
//Control the device
if (brightness == 255)
{
digitalWrite(RelayPin1, HIGH);
Serial.println("Device1 ON");
delay(5000);
digitalWrite(RelayPin1, LOW);
}
else
{
digitalWrite(RelayPin1, LOW);
Serial.println("Device1 OFF");
}
}
@@MaheshBahutePPTSIndia sir can you merge two program plss for ESP32 board ...
1. fingerprint door lock by android fon with app ..
code// #include
WiFiClient client;
WiFiServer server(80);
#define wifiLed 2 //D2
const char* ssid = "wifi name"; //WIFI SSID
const char* password = "password"; //WIFI PASSWORD
String data ="";
int Relay4 = 26; //D26
void setup()
{
pinMode(Relay4, OUTPUT);
digitalWrite(Relay4,HIGH);
Serial.begin(115200);
connectwifiFing();
server.begin();
}
void loop()
{
client = server.available();
if (!client) return;
data = checkClient ();
Serial.print(data);
if (data == "RELAY4SUCCESS")
{
digitalWrite(Relay4,LOW);
delay(100);
digitalWrite(Relay4,HIGH);
}
}
void connectwifiFing()
{
Serial.println("Connecting to WIFI");
WiFi.begin(ssid, password);
pinMode(wifiLed, OUTPUT);
Serial.print("WiFi Connected ");
digitalWrite(wifiLed, HIGH);
while ((!(WiFi.status() == WL_CONNECTED)))
{
delay(300);
Serial.print("..");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("NodeMCU Local IP is : ");
Serial.print((WiFi.localIP()));
}
/********************************** RECEIVE DATA FROM the APP ******************************************/
String checkClient (void)
{
while(!client.available()) delay(1);
String request = client.readStringUntil('
');
request.remove(0, 5);
request.remove(request.length()-9,9);
return request;
}
@@MaheshBahutePPTSIndia and 2nd program is relay on off by alexa ...
code//
#include
#include
Espalexa espalexa;
#define RelayPin1 23 //D23
#define SwitchPin1 13 //D13
#define wifiLed 2 //D2
int toggleState_1 = 0;
boolean connectWifi();
void firstLightChanged(uint8_t brightness);
// WiFi Credentials
const char* ssid = "wifi name";
const char* password = "passwrd";
// device names
String Device_1_Name = "Study Lamp";
boolean wifiConnected = false;
//our callback functions
void firstLightChanged(uint8_t brightness)
{
//Control the device
if (brightness == 255)
{
digitalWrite(RelayPin1, LOW);
Serial.println("Device1 ON");
toggleState_1 = 1;
}
else
{
digitalWrite(RelayPin1, HIGH);
Serial.println("Device1 OFF");
toggleState_1 = 0;
}
}
void relayOnOff(int relay){
EspalexaDevice* d = espalexa.getDevice(relay-1); //the index is zero-based
switch(relay){
case 1:
if(toggleState_1 == 1){
d->setPercent(100); //set value "brightness" in percent
digitalWrite(RelayPin1, LOW); // turn on relay 1
toggleState_1 = 0;
Serial.println("Device1 ON");
}
else{
d->setPercent(0); //set value "brightness" in percent
digitalWrite(RelayPin1, HIGH); // turn off relay 1
toggleState_1 = 1;
Serial.println("Device1 OFF");
}
break;
default : break; }
delay(300);}
// connect to wifi - returns true if successful or false if not
boolean connectWifi()
{
boolean state = true;
int i = 0;
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("Connecting to WiFi");
// Wait for connection
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
if (i > 20) {
state = false; break;
}
i++;
}
Serial.println("");
if (state) {
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
else {
Serial.println("Connection failed.");
}
return state;
}
void addDevices(){
// Define your devices here.
espalexa.addDevice(Device_1_Name, firstLightChanged); //simplest definition, default state off
espalexa.begin();
}
void setup()
{
Serial.begin(115200);
pinMode(RelayPin1, OUTPUT);
pinMode(wifiLed, OUTPUT);
digitalWrite(wifiLed, HIGH);
pinMode(SwitchPin1, INPUT_PULLUP);
//During Starting all Relays should TURN OFF
digitalWrite(RelayPin1, HIGH);
// Initialise wifi connection
wifiConnected = connectWifi();
if (wifiConnected)
{
addDevices();
}
else
{
Serial.println("Cannot connect to WiFi. So in Manual Mode");
delay(1000);
}
}
void loop()
{
if (WiFi.status() != WL_CONNECTED)
{
//Serial.print("WiFi Not Connected ");
digitalWrite(wifiLed, LOW); //Turn off WiFi LED
//Manual Switch Control
if (digitalRead(SwitchPin1) == LOW){
relayOnOff(1);
}
}
else
{
//Serial.print("WiFi Connected ");
digitalWrite(wifiLed, HIGH);
//Manual Switch Control
if (digitalRead(SwitchPin1) == LOW){
relayOnOff(1);
}
//WiFi Control
if (wifiConnected){
espalexa.loop();
delay(1);
}
else {
wifiConnected = connectWifi();
// Initialise wifi connection
if(wifiConnected){
addDevices();
}
}
}
}
@@MaheshBahutePPTSIndia and rember its for ESP32 board DEV kit vi
Good job. I'm having issue with the code, showing this error message "leaving.... Hard resetting via RTS". HOW do I resolve this issue? Thanks for your quick response.
Is it working for you brother? I am going to use this code for my project
@@ranadheervakkalagadda9925 yes. Perfect.
Nice
Thanks
is the use of echo dot mandatory?
For this project, yes. Otherwise you can check my video on Arduino IoT Cloud and Sinric Pro.
Can you share the code please I liked your project
You can download the code from description
hi dear can we connect blynk to alexa
The Alexa App has all the features that Blynk have. Why you need both.
Excellent explantion 👍
Thanks
please check the google drive link of the code. It's not working. I have mailed you for some queries related to the assembled PCB of some of your projects. I want to buy all those PCBs. But first of all please make the drive link available to us. I beg of your help
I have checked. The link is working. But still if you face problem please refer the following link. Thank you.
www.hackster.io/techstudycell/alexa-home-automation-system-using-nodemcu-relay-module-234617#code
You can also refer this video: ruclips.net/video/OJ4CzWyRQr4/видео.html
the alexa app is not findin any devices, the wifi is connected on serial monitor, both on the same wifi , still not showing on the app
The NodeMCU, echo dot, and Amazon Alexa App should be connected with same WiFi.