How To: DIY Home Automation with NodeMCU And Amazon Alexa
HTML-код
- Опубликовано: 15 июл 2024
- *****************NOTE******** The code contained in this video no longer works after an update to the Amazon Alexa API. ****************************
Welcome back to another installment of The Workbench. In this video how to automate lights and outlets using a NodeMCU, 4-Channel Relay Board, and a 20x4 I2C Character LCD in conjunction with Amazon Alexa.
The written tutorial that accompanies this video can be found here: bit.ly/2lNosbr
Link to the GitHub page for this project - bit.ly/2lRDwAJ
Buy The NodeMCU V1.0 on Amazon.com: amzn.to/2lS4ic5
If you like this video, please consider becoming out patron on Patreon. - bit.ly/1FWfVqT
Additionally you can follow us on:
Facebook - on. 1dwf8AE|
Instagram - @MakerofThingz
Twitter - bit.ly/1F9wjhc
The Web - www.themakersworkbench.com
Element14 - bit.ly/2dKow9d
Pick up everything you need to build this project at Amazon.com by using the links below. This helps support our channel!
Amazon Echo Dot - amzn.to/2h55l6Q
NodeMCU V1.0 - amzn.to/2lS4ic5
4-Channel Relay Board - amzn.to/2kL6C4w
20x4 I2C Character LCD - amzn.to/2kL1zBg
Bread Board - amzn.to/2l9bqBI
Jumper Wires - amzn.to/2kqZ62M Наука
Charles, thank you so much for the code and the tutorial. This works flawlessly! You are awesome!
wow finally a video that is clear enough that i could attempt it myself.
+Andrew Small Thanks!
This was well done. Great job. I think I could actually do this.
You should try it! Other than the echo, the parts cost less than $40
great video sir..Please make a video on fan control using alexa..
Great job
Maxwell Moojw thanks!
This is a great tutorial and I thank you for it!!
can you create a tutorial with how to connect NodeMCU to the google home platform?
Sorry for the late upload everyone. I ran into several technical issues while filming and editing this video. From camera focusing and audio issues to Premiere Pro telling me that my GPU (a Nvidia GTX 970) was not compatible, to days searching for a fix, it is finally out. Again, I apologize for the late posting, but at least its out there now. Hope everyone finds it helpful in some way.
I am using a 8 Channel Relay but when I turn on the relay with 3v3 output and ground it just turn on the light on the relay but the relay dont turn off or on any solution to this ?
Hello Sandipan, Yes, the 3.3v is not enough to energize the 5V coil that is inside the relays you are using. You need to power them separately with a 5V 500mAh source.
I tried it power it from a 5v of arduino but then also it dont work but when I changed the relay pin from node to arduino and uploaded a relay test code it worked.
Can you send me info on the relay board? Manufacturer, photo, etc?
Yes how can I contact you ?
Best starting music,
Cool video... Say if we had 2 boards say NodeMCU1 and NodeMCU2 how would you control those...
This is great, I should try this using my several sonoff switches (I'm not sure its compatible or not). But you should try using google home instead of amazon alexa :D
GREAT video! How did you get Amazon Dot to read the text?
Hello, Nice project but I would like to know how Alexa echo is connecting to this device if remote access is needed. Or some other API or MQTT is needed?
Amazing intro! What are your thoughts on how to integrate a temperature and humidity sensor like the HDC2010 to make it turn a swamp cooler on or off? I have been trying to look into it because I do not have a central AC so cannot use the Alexa thermostat.
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
Great video. I wish you could do a project on an Echo switching those cheap 433 MHz remote power sockets. This would be a great alternative to those expensive Smart Plugs, sold TP-Link and others. There are a couple of videos, where those get switched by a NodeMCU, but none that includes an Echo...
That is on my list, and I have the hardware to do it, I just need a few days to put it all together, but I have to get my next home networking video out before then. Thanks for following along, and thanks for the kind words!
Cool intro
You could use a RF-Outlet so u dont have to have a relay and mess around with mains-voltage. Iam planning to do so. I had something like that but with no voicecontrol. It was just an icon on my smartphone that i clicked on. Worked well but wasnt that cool without voicecontrol.
Hey, do you have the wallpaper of your desk? so cool!
Hi interesting pic I see you have callbackfunction.h where do you put the additional files. I have larded a sketch before
Great video... :) could you please tell me how to connect these through Openhab2 server..?
if the internet loss , it keep look your apliances ?
I used your set up and everything works great! However, I can't seem to get Alexa to respond to anything but ON/OFF commands, even by changing the call backs. I'd like to use this setup to automate my mini-blinds, but it sounds a little awkward to say "Alexa, turn off/on the blinds". It works, but it would be better if "open/close" was an option. I have a genuine WEMO switch and it will turn OFF/ON in response to a verbal command of OPEN/CLOSE, OPEN/SHUT, etc. Is there a way to get the emulation to follow these commands?
Can you make step by step tutorial for using Alexa/Google dot controlled nodemcu to control relay that can put in computer on/off switch that can make computer shut down or turn on ? should be simple but i am totally new to this field.
Is it possible to set the relays to pulse? So on the on command it switches on for 1 second and then switches off again?
Nvrmnd. I figured it out. Just made the extra tabs and pasted the files there. Not done yet, but seems like it might work.
@TheMakersWorkbench My alexa is not discovering my NOdeMCU, i can see in the WIFI that nodemcu successfully logs in? Can you let me know what could I be missing out on?
Trying to make this project work. I am having an issue with uploading the sketch. The code compiles ok, but when I upload I am getting and error with the unit not flasing, tried a different board with same problem. Now I am noticing that the light on the relay board for IN2 is on. Not sure if that indicates some sort of error on the relay board. I tried to disconnect the wire for that relay and sketch loads but that does not seem to work. Any suggestions on the light for IN2?
Did not work for me a newbie at it though. The LiquidCrystal_I2C.h gave an error that it could not be found. I put it in the directory of the program but did not work. Seems like it going to take a bit to get your code going. Thanks for all you did.
Hi sir node mcu ki alexa ke liye programming kar ke denge kya
Can you please tell us how to turn on off a 3 phase mains with Alexa?
does it also work for google home mini?
I have been able to compile but not able to upload see below What ESP2866 do you use please?
WARNING: library LiquidCrystal_I2C-1.1.2 claims to run on (avr) architecture(s) and may be incompatible with your current board which runs on (esp8266) architecture(s)
I used Node MCU and "reverb for alexa" app, I dont have echo device.however, it didn't worked with this app. it is exactly same as echo. Please help me with this
hi, thanks for the video. i wonder if this is will works with the v3 NodeMCU ??
+Julio Cuadros yes it should work fine.
How many node mcu can we attach with a single alexa
?
rather then using the hardcoded SSID and password is there way we can configure it and saved it ?
How did you get all devices to turn off? I can't find it in the scripts
alexa doesnt work. do i need any configuration in echo dot. pls help
Is there any update with new code?
I dont know why sometimes Alexa doesnt recognice the NodeMCU.. Sometimes work well but sometimes doesnt work.. Now, nothing work, Can Wemos change something in their servers or way to connect that make the NodeMCU cant connect to wiFi network thoroug intenet?
do we require internet connection , how can i buid it without internet connection
What is Alexa programmed? Or have to program, I'll buy Alexa, I am in India, Alexa can be run in India
Is it work with alexa app mobile?
Hi, im getting an error where the WiFiUDP is missing, where do I get WiFiUDP.h from?
Great video - and appears less difficult to try compared to other articles I have read. Couple questions for you... do you know if it is possible to ask Alexa to read a value, and return it... such as if a door is open, motion detected (variable set), etc?
+Ken Jaynes Thanks for the compliment. At the moment I do not think it's possible to have Alexa read strings back.
I am wondering if via home-assistant would work - home-assistant.io/components/binary_sensor.rpi_gpio/ via Raspberry Pi though, not Arduino or ESP8266
+Ken Jaynes I'm not yet sure.
+Ken Jaynes It's possible. I know the esp8266 is quite popular with the home assistant people
can we use any other device like iphone or any other one to control them
Im not sure if Apple has the Siri API open to the extent it needs to be for this to work on their platform.
Is the node mcu suitable for 24x7 application of home automation systems? or would it burn away?
+nishit patel it's stable for 24/7 usr
lcd.init(); error ...
Brilliant job on the application, have done a few switching projects using this board and they work fine, but I really liked the idea of using the L.C.D screen (geek factor and all that..) I have downloaded the ZIP file but I am unsure with what to do with the 5 other files that are needed - where do I put them and how do I include them - plus where do I get WiFiUDP.h from? - also i am getting an error saying "error compiling for board NodeMCU 1.0 (ESP - 12E Module) - I am assuming this is related to missing files? - any help or advice would be welcome !
Well after a fair bit of head scratching I finally got the main part of the project working and its talking to my echo dot nicely and switching the relays... however, the LCD screen just sits their glowing blue and showing two rows of white squares (as I understand it, its in reset mode?) it does nothing when rebooting the NodeMcu and I have spent most of the day looking if I went wrong anywhere with connection etc, the LCD is the exact same one in the tut here, so am at a bit of a loss, and as their seems to be no activity here I fear this will have to go on the back burner for a while and i'll look for an alternative. Not all lost though at least I think I learnt something :)
how did you manage to get the WiFiUdp.h file working? Having the same problem now
Hi Ray, My Nodemcu is connecting to Wifi fine but echo is not discovering it at all. Can you please tell me what did you exactly do to get this working? I know it would be a thing of past for you but still, will look forward to hearing from you.
how can you off all light at same time?
Hello sir thank u for ur video and for u sharing ur knowledge with us
I have one q
Am using the wemos d1 mini and it worked great
My q is
I built automated bar tender and am trying to use this to trigger drink for me
But it's lil awkward to say turn on Vodka
Is it possible to change it to Alexa MAKE ME vodka?
I tried to change in the code didn't have luck
Thanks for ur help sir
Dan
U have to say turn on
I love your project and built it but a couple of months ago it stopped working
after trying everything including uploading to a new NodeMCU I rang Amazon, they told me that they do not support this anymore
Help me if you can
Thanks
Erik Hoffman
Hello, Can the echo be used from a remote network to control nodeMCU that is connected to the home wifi ?
+Justin Jose I am not sure if this is possible and I believe that Amazon has security measures in place to prevent this exact thing. I could be wrong though as I have not spent any time researching it.
Could you Please Elaborate on Discovering and adding a device to Alexa please. My Alexa is not able to detect this ESP8266 device. I am finding it difficult. please help.
Well thank you very much. I have 10 devices that are running with my echo. one of them is my garage door. There is one problem and that is that I cant figure out how to get the echo to respond to "Open,Close" commands. I can say "Garage door on" and "Garage door off" works fine. If you could help me that would be great.
+Travis Micolichek this is something I am trying to figure out as well for a new video. When I have it worked out I will share the details.
I have figured it out. I hooked an nodemcu and a relay to my garage door push button. I used a
digitalWrite(relayFour, HIGH);
delay (500);
digitalWrite(relayFour, LOW);
delay (500);
digitalWrite(relayFour, HIGH);
You don't need to change the code for open/close commands. You can use open/close command instead of on/off but alexa is picky about what you name your device. I tried "Alexa, open garage" and it works fine. If you say "Alexa, garage open" it dont work. You can also say activate and deactivate to control devices.
Time 1:15 I did see a switch right below the LCD display, what is that for. A light turned on by Alexa, can i turn it off using the manual wall switch ?
It appears to be the A/C supply so yes you can... how it affects the low voltage controls if you power it back on is unknown.
Why i get this error message Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"
NODEMCU_ALEXA_wemos\NODEMCU_ALEXA_wemos.ino:31:31: fatal error: LiquidCrystal_I2C.h: No such file or directory
#include
^
compilation terminated.
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
how can I customize my command instead of saying light one and light two can I make it in the way that make sense to my project
+Nick Nguyen if you watch the code and read the written article linked at the bottom of the video in the description, you will see where the change needs to be made
This may be a weird question but I am trying to wrap my head around the circuit in a house environment. I am planning on using a few of these relays around the house to make some of the wall outlets smart. When these get hooked up, is the circuit parallel or series?
I am trying to make sure everything in my house stays to code and nothing will draw more than it should without tripping the breaker.
If you want to stick to code, you will want to buy something like Sonoff switches and work them into a separate utility box in your mechanical / electrical closet. Using open relays like this inside of a wall is very dangerous, and unless they are UL approved, and in a fire safe box, it will not be up to code.
I was planning on putting them in the attic (with the rest of my wiring) and inside proper electrical junction boxes. I was mostly concerned with load on the circuit breaker and if these would keep the same amount of load as the original outlets that are in parallel.
Edit: As a note, i am planning on having an electrician verify my work.
Benjamin H these particular relays are only capable of 10a of current each and I would not put more that 8.5 amps on each one. Typical wall outlet circuits are on a 15a circuit breaker which is able to handle 15a across that who circuit.
Right, most likely none of my lamps will draw more than 8.5 amps heh but i definitely see your point. Maybe the Sonoffs can pull more or a higher amperage multi-relay might be safer.
My main question though is still the circuit type. A typical wall circuit has the outlets in parallel. My concern is that if one of the relays goes out that all of them will stop functioning.
You should use this system to automate your blinds
Why did you change the relay from the LinkNode R4 to the Sainsmart relay? I made the other project using the LinkNode R4 and have had trouble with the relay going on and off?
I'm not really sure what you are asking. I made this video to show people how to use the Node MCU to do the same thing that I did with the LinkNode R4.
My question was, were you having a problem with the LInkNode R4 and was that why you changed to the Sainsmart relay? I wanted to know since I had built the first version using the LInkNode R4 relay and got everything working great with the Echo. However after the outlet stayed on a little while the power would cycle (on then off then back on again). This happened all the time the outlet was on. I changed to another LinkNode R4 only with the same result. I have contacted the seller and am awaiting a reply. I just was curious if you had a similar experience and changed relays. Thanks
I have the Linknode running the poweroutlet to my PC right now, and it has been solid for 15+ hours a day of use for the last two weeks with no issues. I am not sure what could be causing it to reset like that.
How do you get all devices to turn on and off? I did not see it on your code. How do you add push button to it?
Would be a nice addition... cant find it listed in the code anywhere.
Just for information it doesn’t need any extra code to get this to happen... you just create groups in the Alexa app.. works very well.
Looks like This is giving me an error - LiquisCrystal_I2C, why????
install the library
I keep getting this error "Error compiling for board NodeMCU 1.0 (ESP-12E Module)" Can someone help?
I've been getting the same error, have u u found a solution??
how did you get her to read all that can you make a tut onit?
+Jay Mee "Alexa Simon says "Hello Everyone"
Does this need Internet to work ? Or just the WiFi Connectivity (I mean what if i disconnect the CAT6 cable from the Router but keep it Running, so will it work without connecting to the Internet ?)
Yes it needs an active internet connection.
@@Themakersworkbench Alright! Thanks Mate!
can i connect more than one NodeMcu to alexa echo dot
I have same query?
can you send me the code..
how do you build smart home device groups in Alexa?
That is done within the Amazon Alexa app on your phone or tablet, or on the webapp found on Amazon.com
Ok thank you
中国能用吗?中国有好用的开源的智能音箱吗?
How did you let Alexa recite the intro?
John Chen you use the phrase "simon says"
My Alexa is not detecting the relays....what Shud I do
can i use two of these at the same time
+Guillermo Lopez yes you just have to discover the second device.
thank you for letting me know
G8
exit status 1
Error compiling for board NodeMCU 0.9 (ESP-12 Module).
Same here... did you find a fix?
No
same here too, have u guys found a solution?
my echo dot cant find any smarthome devices
im never change what u've done
only ssid and password
please help
same for me.
If you have one of the new V2 Echo Dots, at least some of the WeMo emulators for ESP8266 stopped working because Amazon changed the discovery protocol.
I just got mine, so I haven't found out what the fix is yet. I only found out about the problem when I was looking for examples.
I had the same problem. My wireless network name is Thor, but I was typing thor in the code. it's case sensitive. maybe this will.help
what low voltage device is at each light/receptacle
Dean D'Aiuto I'm unsure of what you are asking.
you have a low voltage wire running to each light/receptacle. what is that connected to to communicate with the arduino?
No, those are not low voltage. The black wires are the Hot wires from the 120V mains, there is a Neutral wire and Ground wire traveling to each from the main junction box as well, you just can not see them. The Hot wires (Black) travel from each gang box to one side of their respective relays, and then the other side of each relay is connected to the mains 120V hot wire in the main junction box.
The only low voltage on this project is the 5V that travels into the NodeMCU from the USB adapter, and then the 5V that powers the coils in each relay. Please, if you do not understand how mains voltage wiring works, do not attempt to build this project. It can and will kill you.
Ok I see thank you for taking the time to answer my question.
You're welcome! Thanks for watching the video and taking the time to comment!
But only for my Knowing. It couldn't be wireless, could it?
As far as networking goes it is wireless. It will never be able to be truly wireless as you have to switch the mains power somehow.
It appears to be a well made video. However when I tried it on (after changing the SSID and PW) and choice of LCD header file, I get the following errors.
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
I cannot understand where on earth that came from. The code compiles alright and yet this. Please help.
That's because Amazon killed the API that allowed this to work.
@@Themakersworkbench Thank you for a prompt reply. Do you have an updated video to handle this problem then?
@@nearmitech not yet but I do have the newest generation Echo Dot and will be making a new video in a few weeks.
Ok, so that didn't work. I guess I still need to get them in the library?
Hello I made the project run. But when I add to the code, the nodeMcu constantly resets itself.I would like to ask you to write code for 8 way relay.
CAN I GET CODE FOR DOING THE SAME PROJECT WITH 4 LED'S?
Sure can, give me a couple of weeks and I will have a video up for just how to do that. If you want to do it now, all you have to do is reverse the logic going to each pin that is used, and then wire in the LED's Annode to the pin, and its cathode to the NodeMCU's GND pin.
I am a newbie to all this hence I won't be able to do this on my own. A tutorial video will be helpful for me. Thanks for the reply.
Waiting for the video
Would love to have a reply!!!!!!
Sorry, YT studio never notified me of your comment. It's super buggy. Amazon changed the way their API worked and it broke this code. I apologize for that, but it's not something I have control over. I'll try to get a new video up soon.
@@Themakersworkbench
Vert excited to get a reply, almost gave up
Please let me know when there is an update so my big project continue to respond to Alexa
Kind regards
Erik Hoffman
HEllo
I have succe'sfully upload code
serial log seems to be OK
onnecting to WiFi
Connected to reseaualamaison
IP address: 192.168.0.12
Begin multicast ..
Udp multicast server started at 239.255.255.250:1900
WiFi Connected
reseaualamaison
WebServer started on port:
80
WebServer started on port:
81
WebServer started on port:
82
WebServer started on port:
83
Adding switch : Light O
But Alexa discovering device detect anything
Do you have an ideas pleases ?
I have the same problem, did you solved the problem?
@@blaze1701 I have cha,ge the code , i use the code this for 1 Device (D1) up to 10 devices you can set
#include
#ifdef ARDUINO_ARCH_ESP32
#include
#include //if you get an error here please update to ESP32 arduino core 1.0.0
#else
#include
#include
#include
#endif
String ValText;
int count = 0;
char line[80];
boolean connectWifi();
// Change this!!
const char* ssid = "xxxxx";
const char* password = "xxxxxx";
EspalexaDevice* d1;
boolean wifiConnected = false;
Espalexa espalexa;
#ifdef ARDUINO_ARCH_ESP32
WebServer server(80);
#else
ESP8266WebServer server(80);
#endif
void setup()
{
float temperature;
Serial.begin(115200);
// Initialise wifi connection
wifiConnected = connectWifi();
if(wifiConnected){
server.on("/", HTTP_GET, [](){
server.send(303);
});
server.on("/test", HTTP_GET, [](){
server.send(200, "text/plain", "This is a second subpage you may have.");
});
server.onNotFound([](){
if (!espalexa.handleAlexaApiCall(server.uri(),server.arg(0))) //if you don't know the URI, ask espalexa whether it is an Alexa control request
{
//whatever you want to do with 404s
server.send(404, "text/plain", "Not found");
}
});
d1 = new EspalexaDevice("poulailler", Device1,0);
espalexa.addDevice(d1);
espalexa.begin(&server); //give espalexa a pointer to your server object so it can use your server instead of creating its own
server.on("/Device1_on", Device1OnHttp);
server.on("/Device1_off",Device1OffHttp);
server.begin(); //omit this since it will be done by espalexa.begin(&server)
} else
{
while (1)
{
Serial.println("Cannot connect to WiFi. Please check data and reset the ESP.");
delay(2500);
}
}
// Force the ESP into client-only mode
WiFi.mode(WIFI_STA);
}
void loop()
{
server.handleClient();
//server.handleClient() //you can omit this line from your code since it will be called in espalexa.loop()
espalexa.loop();
delay(1);
}
//our callback functions
void Device1(uint8_t brightness) {
if (brightness == 255) {
d1->setValue(255);
Serial.println("Device1 ON");
server.send(200,"text/plain","OK");
server.sendHeader("Location","/");
server.send(303);
}
if (brightness == 0) {
d1->setValue(0);
Serial.println("Device1 OFF");
server.send(200,"text/plain","OK");
server.sendHeader("Location","/");
server.send(303);
}
}
//our callback functions
void Device1OnHttp() {
d1->setValue(255);
Serial.println("Device1 ON");
server.send(200,"text/plain","OK");
server.sendHeader("Location","/");
server.send(303);
}
//our callback functions
void Device1OffHttp() {
d1->setValue(0);
Serial.println("Device1 OFF");
server.send(200,"text/plain","OK");
server.sendHeader("Location","/");
server.send(303);
}
// 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.");
}
delay(100);
return state;
}
@@Gyver4000 Thanks! :)
hello alexa not see devices
I have the same problem, did you solved the problem?
I have the same problem, did you solved the problem?
I HATE YOU ECHO!!!!!!!!! ;) LOL
LMAO! You just have to be able to speak proper English for it to understand you Jamie!