ESP32/ESP8266 Relay Module - Control AC Appliances (Web Server)

  Переглядів 248,288

Rui Santos

Rui Santos

4 роки тому

ESP32 Project (schematics + source code) ► RandomNerdTutorials.com/esp32...
ESP8266 Project (schematics + source code) ► RandomNerdTutorials.com/esp82...
Using a relay with the ESP32 is a great way to control AC household appliances remotely. This tutorial explains how to control a relay module with the ESP32. We'll take a look at how a relay module works, how to connect the relay to the ESP32 and build a web server to control a relay remotely (or as many relays as you want).
SAFETY WARNING: in this example, we’re dealing with mains voltage. Misuse can result in serious injuries. If you’re not familiar with mains voltage ask someone who is to help you out. While programming the ESP or wiring your circuit make sure everything is disconnected from mains voltage.
Like my page on Facebook:
/ randomnerdtutorials
Follow me on twitter:
/ ruisantosdotme
Subscribe for more projects like this!
bit.ly/subscribeRNT

КОМЕНТАРІ: 149
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
You can find on my blog the full step-by-step instructions for each ESP board. ESP32 Project (schematics + source code) ► RandomNerdTutorials.com/esp32-relay-module-ac-web-server/ ESP8266 Project (schematics + source code) ► RandomNerdTutorials.com/esp8266-relay-module-ac-web-server/
@ingenierocristian
@ingenierocristian 4 роки тому
Rui Santos Hi, I bought your ESP32 course, it turns out that I need to send digital values from 16 GPIOS, and send them to a platform called Ubidots, but I still don’t know how can I doit, can you please help me about?
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
@@ingenierocristian hello, unfortunately I've never used that platform before. Have you tried their sample projects from the library? Thanks!
@ingenierocristian
@ingenierocristian 4 роки тому
@@RuiSantosdotme Ubidots is quite similar to the project you made in the Module 7 of your course, except this platform integrate its broker, it uses the MQTT protocol
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
@@ingenierocristian I think they have a library with a bunch of examples that show how to use the platform. Did you try their library examples? You can also use any MQTT example (instead of using an IP address, you use their domain name, then check which topics you need to subscribe to)
@MrSpock-sm3dd
@MrSpock-sm3dd 3 роки тому
This is the third project I'm trying. Yours was the only one who works. Thank you a lot my friend, hugs from Brazil
@RuiSantosdotme
@RuiSantosdotme 3 роки тому
Thank you for your kind words, I'm glad it was helpful. Greetings from Portugal, Rui
@jtrain1653
@jtrain1653 Рік тому
Thank you so much for sharing this wonderful video!It means alot to show and educate people who are trying to do gadgets like these.
@Banjoba
@Banjoba 4 роки тому
Clear and concise. Great video. Thanks.
@edsonferraz1
@edsonferraz1 2 місяці тому
Congratulations Rui!! Great solution, thanks so much.
@CreativeDesk
@CreativeDesk 4 роки тому
Your video is always so clear and also your website .all the necessary things are present in website Keep posting ...
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
Thanks! I'm glad you found it helpful
@pelouis9413
@pelouis9413 2 роки тому
Thank you my friend by your project ,Im come from Vietnam.
@edsonferraz1
@edsonferraz1 2 місяці тому
Congratulation Rui!! Great solution. Thanks so much.
@jag_3d
@jag_3d 3 роки тому
Hey great video! I got a question, do I have to find a 3.3v relay for using in with my ESP32? or what is the model youre using in this video? Thanks, I apreciate your work!
@rishujain21
@rishujain21 3 роки тому
Hi Rui, Thank you for this fantastic video. Is there a limit to the number of Channels which can be controlled using a single 8266 NodeMCU component?
@WPGinfo
@WPGinfo 2 роки тому
Thank you. This was very useful!
@ldt_
@ldt_ 4 роки тому
This is great... you are great... where the hell was this video 8 months ago when I needed you? lol. Good work!
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
Thanks!
@ldt_
@ldt_ 4 роки тому
@@RuiSantosdotme Hey, so going through your posted project, do you have any recommendations for setting this up and accessing the ESP without port forwarding on the firewall? Something like a websocket server/client with an Android app? Thanks
@walterr8115
@walterr8115 7 днів тому
Thank you😃, i was wondering why it doesn't work, then i realize the jumper caps were removed!
@kaiomatico
@kaiomatico 4 роки тому
Wow now that is really awesome and clean code! Thank you so much:)
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
You're welcome! thanks for watching
@3DprintRC
@3DprintRC 4 місяці тому
simple and usefully video.thanks.
@sameneko8979
@sameneko8979 4 роки тому
Thank you for the video sir.
@RoMecha_lb
@RoMecha_lb 2 роки тому
Great tutorial dear
@dons3357
@dons3357 4 роки тому
Thank you. Helpful as always.
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
Thanks!
@danielwarnock4157
@danielwarnock4157 Рік тому
I followed your tutorial and built a similar project Thank You it was a fun build! is there a way to name the relays independently in the web server? I have them performing specific functions and I'd rather them have a name other than Relay #1 - GPIO 16 etc... I'd really appreciate your help
@Leo-db6mi
@Leo-db6mi 3 місяці тому
really good stuff keep it up
@bishop34644
@bishop34644 3 роки тому
Great job if I wanted to only be able to have one really on at a time example if I have four relays and I turn on number one then I turn on number two in the code how would I have it so when you switch relays it auto shuts off pervious one
@cizainnocent8392
@cizainnocent8392 2 роки тому
Very nice video. It worked perfectly when I repeated it. Could do you please improve it by making it accessible from anywhere over the internet? thx
@Eduardo-ro4bv
@Eduardo-ro4bv 2 роки тому
Thanks for your video dude. I have a question? If I need a relay that can handle a 48VDC out with 6A. Can i connect to 2 relay that give 30VDC and 10A each to control only this 1 equipment?
@carloselmano6725
@carloselmano6725 3 роки тому
Olá Rui. Parabéns pelo video e pelo canal. Gostava de saber se é possivel fazer o seguinte: ter o som ambiente por zonas com botão no Home assistant... será que é possível com esp 8266 ou wemos Com relé E adicionar o sistema ao HA com botões? Tipo - ligo o sistema de som e as colunas estão todas ligadas - se ligar o botão 1 toca na sala - se ligar o botão 2 toca no WC se ligar os 2 tocam em ambos os espaços. Obrigado
@raffaelebarlotti9017
@raffaelebarlotti9017 11 місяців тому
Hi, great project! I need to use all 8 channels with ESP8266 could you tell me which pins to connect the remaining 3 channels to? Thank you.
@andys6
@andys6 Рік тому
This is great! thank you
@gurumurthykola8520
@gurumurthykola8520 4 роки тому
Hi Rui, The tutorial is nice. i have tried using the information provided in your tutorial. Able to control the relays only when my ESP8266 and Laptop (where i am opening the web page to control the relays) are connected to same network. If both are connected to same Wifi network, the ip address is not opening. What might be the issue? Do you have any inputs?
@BootlegEL
@BootlegEL 2 місяці тому
Thanx this was helpful
@2ds.service200
@2ds.service200 Рік тому
A good work. Really i like
@societateanationala6207
@societateanationala6207 2 роки тому
Took me 10 mins ... Thx
@christiangenebrozo2126
@christiangenebrozo2126 3 роки тому
Hi good video, could you tell me how did you do the app to your celphone, thanks a lot
@kamalambrator4332
@kamalambrator4332 4 роки тому
nice presentation! thank you
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
You're welcome!
@user-dl3hj3cw9o
@user-dl3hj3cw9o 4 роки тому
Отличный проект. Можно ли добавить простой таймер, например после движения ползунком влючается реле, а через 5 сек. отключается и ползунок возвращается в состояние выкл.
@Luismaia00
@Luismaia00 2 роки тому
Very nice , let´s say as is 5 relay, each controled by each button now how to add a button to turn off/on all at the same time,the idea is that leaving house and turn OFF all ligths or getting home turn on ligths ON, is it possible ?
@NEWBI3GAM1NG
@NEWBI3GAM1NG 4 роки тому
nice video.. but anyway i have a little question about how to change the credentials without hard coding again.. thanks in advance..
@bossdonalan6840
@bossdonalan6840 4 роки тому
Good explanation
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
Thanks!
@mr3748
@mr3748 3 роки тому
Good day Mr Santos, thank you for your videos, Ive learned a lot from all of them. I was wondering if you could help me regarding relays... So I have a simple webserver where I can turn a relay on/off and I have three LDR sensors as inputs for the three status LED of the water pump I want to control. Ive used the meta-refresh to refresh my web server every 30s, BUT once the server refreshes, my relay quickly turn off and back on again during the reset. Is this one of issues related with using meta-refresh or does this sound like bad coding? EDIT: I fixed it within an hour of typing this message, Ive connected the relay to GPIO2 but I was so focused on my coding and other stuff that Ive failed to remember that the buildin LED is also controlled from GPIO2. Luckily this is an easy fix. Ive used the buildin LED to give me wifi status updates as well as data coming from the client, that is why my relay went mad. Ill leave this comment to help others.
@chubbyvery1339
@chubbyvery1339 2 дні тому
Hi, Followed your video and it works. The problem I encounter is that when I open my motor, I need to close it before I can open other device. I believe they should work simultaenously. Whats wrong with my circuit?
@DeepRoy4600
@DeepRoy4600 3 роки тому
Vou testar isso assim que tiver tempo. Serias capaz de me tirar umas dúvidas?
@mojtaba3296
@mojtaba3296 Рік тому
fantastic!!
@gurunanjaiahkembhavimath8728
@gurunanjaiahkembhavimath8728 2 роки тому
Good video
@sandorfarkas7193
@sandorfarkas7193 3 роки тому
Hello. do you have any idea how it can work with xlights with an esp32 16 channel relay?
@blukobalto
@blukobalto 3 роки тому
I have an esp and i want to monitor the lights of an electromechanical pump's control box. The lights are 24v ac i need to read their status on or off with the esp is it possible to read the relays status with this module?
@treeyuono9372
@treeyuono9372 3 роки тому
Thank u....Rui...
@Dancopymus
@Dancopymus 2 роки тому
Hi Rui, Greetings from Brazil! I have two questions: 1) I have a Module with 8x Relays, but it works with 12V, so how should I connect it to ESP32/ESP8266? I know I must use External Power, but how do I make the connections? 2) And that JDVcc jumper I don't understand what it's for. Thanks
@danisxatzi6282
@danisxatzi6282 3 роки тому
Hello!! What if i want when i sent the command to close the relay, it will close in one or 2 sec it self? Thanks!!
@hussienmohamed2589
@hussienmohamed2589 2 роки тому
Could I use the same project to control more than one home light bulb? Or I need to buy 8 channel relay module to control all the ceiling light bulbs in my room? "I mean the main voltage home light bulbs not the external light bulbs". Thank you.
@GurinderSingh
@GurinderSingh 2 роки тому
Is internet connection or wi fi compulsory with this module can I use this module for switch on off with mobile directly
@sukasa9374
@sukasa9374 4 роки тому
I see this tutorial only control 5 chanel ? Can this device use 8 chanel ?
@nursyazwani8846
@nursyazwani8846 3 роки тому
hi, may i know what database u are using for this project?
@sanmeetsingh8219
@sanmeetsingh8219 Рік тому
hi i like your video , but i have question that, i am using esp 32 for my rgb lights {wled} and i also want that esp board to turn off things that i link in this video, so plzz tell me can i makeor run 2 commands always on a single esp board u can also make video on that
@abur9976
@abur9976 2 роки тому
una pregunta, estoy estoy trabajando en un proyecto para automatizar el reguio de un cultivo por bonbas de agua, el control de la automatización se hara mediante una aplicacion wed, tengo un modulo esp8266 y un rele de dos canales, la pregunta es a pesar que el rele dice que solo soporta 10-15A Y 125 VAC - 250VAC, no hay problema si lo utilizo para una bomba de agua de 110 vcc?
@christiangenebrozo2126
@christiangenebrozo2126 3 роки тому
Good video, i have a problem my relé module needs 5v and the esp8266 just send 3.3v and it doesn't work please help, thanks a lot
@exmexh4713
@exmexh4713 4 роки тому
Hello. Can I control 24V relay with 3.3V(12mA) output GPIO? So using ohms law i need 2k ohms to get 24V. Will this work?
@user-dm8sm3gw5o
@user-dm8sm3gw5o 4 роки тому
Hello and thanks for this beautiful video. Can you tell me how to connect to this Esp32 from WEB and not only from same network??
@yoursinger4014
@yoursinger4014 3 роки тому
You can use Firebase or any sort of database. Connect it to your Esp32 , make an android or IOS app.. and you are done! There are plenty of videos on how to connect Esp32 with Firebase. Hope it helps!
@mekszii
@mekszii Рік тому
Hello! if I want to supplement it with a LoRa module due to the longer range, what should i do?
@sonupradeep1996
@sonupradeep1996 3 роки тому
how to acces the node mcu from external network...do we have to perform things like port forwarding to acces the same throuh the internet
@Kunal_Joshi
@Kunal_Joshi 3 роки тому
Hi Rui, is there a way to do the same using softAP.
@valdirturquettes8715
@valdirturquettes8715 4 роки тому
Olá ! Amigo Seus videos são bons Faca em português , que vc vai ter muitos seguidores no aqui no Brasil ATt
@vojtasmolik3547
@vojtasmolik3547 4 роки тому
Hi Rui don't you want to make weather station based on your ESP-32 weather shield with another wirelessly connected another shield that one will be inside and one outside that will be shown on display and on internet and maybe solar powered i think that would be awesome sorry for my poor english keep what are you doing and happy holidays!
@ingenierocristian
@ingenierocristian 3 роки тому
Hi, I need to make an I2C communication between an Esp 32 and Esp8266, where can I find info about?
@Circuitsplanet
@Circuitsplanet 2 роки тому
Excellent
@RajatGupta_Pune
@RajatGupta_Pune 3 роки тому
@rui Santos : can you help me with code in your Relay code, to have the Internal LED of ESP8266 Blinking while the WIFI is being Connected, and stays ON once connected to wifi, Unable to be sure if it was connected or not if not connected to computer.
@elpetitcafe5385
@elpetitcafe5385 3 роки тому
Hi Rui, I though you need 5v to move the coil of the relay, are the 3v of a nodemcu enough to control relay? Or do you use an extra power source to make it work?
@adrianshawuk
@adrianshawuk 3 роки тому
Elpetit Cafe I had to buy 3v relays as my esp32 couldn't supply enough to use the 5v one I was using with my Arduino that ran on 5v
@hanslubbe9702
@hanslubbe9702 Рік тому
Hi Rui, Just came across this video, i must say very well done, nice clean code and awesome explanation !! i do have a question though, i would like to name the relays, i don't want to see the "Relay#1 - GPIO 14" text, can you please update the esp8266 sketch?
@hanslubbe9702
@hanslubbe9702 Рік тому
Hey Rui, don't worry, i got it working the way i want to :) Still, thank you for your great video, it helped me a lot!!
@NEWBI3GAM1NG
@NEWBI3GAM1NG 3 роки тому
hi sir is it a local server only? thanks in advance
@0124akash
@0124akash 11 місяців тому
This project based on local area network or global ?
@vishwambharjoshi4317
@vishwambharjoshi4317 3 роки тому
Hay we are using it by Wifi, but can we use it by Manually + Bluetooth enabled........if Yes, then what will be the circuit diagram and codes?
@guilhermepaixao1102
@guilhermepaixao1102 4 роки тому
Exelente.obrigado pour partilhar.Bom ano!
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
Obrigado! Abraço!
@Santiter
@Santiter 4 роки тому
Hi ! First of all thank you very much for all your tutorial and content ! Thanks a lot !! I have a question: I'm starting to program an ESP32, and what I want to do is to use data that I wan’t to input through an internal html site, exactly as you do in one of your tutorials using the ESPAsyncWebServer Library, and at the same time I need to be able to auto connect the device without hardcoding the Password and Name of the net, so I can do it more “plug and play” Where should I start studying? Is there a way of combining both libraries, or some of those features are also possible to make in both libraries? Thanks a lot !!
@saeedbaloch2
@saeedbaloch2 3 роки тому
that's exactly what I am looking for too, I hope he replies back to this.
@h.p.8379
@h.p.8379 4 роки тому
Thanks for the video. I see use 2 skits for ESP8266 and ESP32. Couldn't you combine both sketches and just use the sketch for both ESP (8266 and 32)? You would then only have one sketch, which then works for both ESPs.
@RuiSantosdotme
@RuiSantosdotme 4 роки тому
The examples demonstrated in this video work for both boards, if you notice I use a condition to include the proper WiFi library if you're using the ESP32 or ESP8266 (time of video 4:42 and lines 7-12 ). I hope that helps!
@quickfixengineeringltd8035
@quickfixengineeringltd8035 3 роки тому
I have a hosted domain. How do I make this project controlled over WiFi not with a local network
@dkeinys
@dkeinys 3 роки тому
Hi Can you please create version of this script that allows to control relays based on Temp & Humidity??
@naufal9104
@naufal9104 4 роки тому
rui, how to post data without refreshing the page?
@evilmode100
@evilmode100 2 роки тому
Hi how to name each gpio? as Relay #4 renamed to garage?
@eldaelda4991
@eldaelda4991 2 роки тому
How reverse the output, Relay 16 channel have positif input.
@bhaskerreddy9054
@bhaskerreddy9054 4 роки тому
Is this can be controlled from anywhere in the world
@enriquebartolini6161
@enriquebartolini6161 2 роки тому
Do you need an ip pubblic? Thanks
@hummingbird2520
@hummingbird2520 2 роки тому
Can we Controll led output of 1 volt
@enriqueolmeda1
@enriqueolmeda1 2 роки тому
Hi Rui, ESPAsyncWebServer is not available... What can I do? Could it be that it does not exist anymore?
@jumbo999614
@jumbo999614 9 місяців тому
Is this tutorial for RELAY with active LOW? Mine is active low. Can you also explain the code? the lines with code: request->send_P(200, "text/html", index_html, processor); The function: String processor(const String& var) { .....} I thought you have to pass argument into processor function on "request->send...."
@MFORMAAZ
@MFORMAAZ 4 роки тому
Can I control 1 phase AC motor
@technotricks7627
@technotricks7627 Рік тому
Sir i need, auto on relay when connected to wifi can u help me? M a beginner
@titsik
@titsik 4 роки тому
you are genios
@christianrojano6470
@christianrojano6470 4 роки тому
Good Day Sir!, In my current project I am combining your codes for the dht22 and relay. I encountered a problem and it says "relayState is not declared in this scope"...can I ask sir why is that?
@prakharverma2286
@prakharverma2286 2 роки тому
put this at the starting of the code: String relayState(int i);
@Circuitsplanet
@Circuitsplanet 2 роки тому
Is there anyway to control it through internet is????? Plzzzz
@NuMwhan-bg4fq
@NuMwhan-bg4fq Рік тому
when connecting my 4 channel module to the gnd and 5V pins of my esp32wroom32u wifi disconnects and can't access webpage (I made my own) What could be the issue? the module is taking too much energy?
@danielapetroaie8217
@danielapetroaie8217 Рік тому
when i run the code i don't get any error but nothing shows up on the serial port i pressed the rst button why?
@CharDhue
@CharDhue 3 роки тому
I use this relay module but the relay won't change even thou the led change with 3.3v from nodemcu
@shandradm911
@shandradm911 Рік тому
how to make if turn off relay 1 turn on relay 2?
@technophile01
@technophile01 3 роки тому
Hi. Can we access to esp8266 from anywhere ? Thanks.
@Dean.Michael.Winchester
@Dean.Michael.Winchester Рік тому
What if I want to control the relays using blynk?
@FlorinIonitaAdrian
@FlorinIonitaAdrian 3 роки тому
Hello! i have a question. if you close the webpage, and you open it again, does it still show the relay state? if the device is on or of?
@prashantpandey2299
@prashantpandey2299 3 роки тому
Yes
@tyson_gaming1013
@tyson_gaming1013 2 роки тому
How can I add a name to each relay
@user-xe5fg8yy3l
@user-xe5fg8yy3l 2 місяці тому
i know it is long time this video was relased but i tried it and is wdt reseting can somebodz help me????
@magicianofelectronics951
@magicianofelectronics951 3 роки тому
Compiling error for ESP8266, Wemos D1 R1 mini, Thank you
@mikepatton9684
@mikepatton9684 2 роки тому
and webserver with espalexa?
@kashifthemaker3945
@kashifthemaker3945 3 роки тому
You are doing an amazing job, love you and your website randomnerdtutorials.com
@AshiqurRahman
@AshiqurRahman 2 роки тому
Is the relay module 3.3v or 5 v
@NeliKouneli
@NeliKouneli 2 роки тому
5v
@Circuitsplanet
@Circuitsplanet 2 роки тому
But what about esp 01??
Connecting a Relay Module to a Microcontroller
11:41
Brad Henson
Переглядів 200 тис.
ESP32 Web Server - ESP32 Beginner's Guide
11:52
Enjoy Mechatronics
Переглядів 41 тис.
Не покупай эти гиперзаряды 👎
00:36
Повістки у Києві: «Яке право вони мають забирати всіх мужиків?» #війна #мобілізація #військові
00:41
Слідство.Інфо | Розслідування, репортажі, викриття
Переглядів 343 тис.
12 Useful & Interesting ESP32 Projects for Beginners!
9:41
ToP Projects Compilation
Переглядів 561 тис.
10 заповедей по пайке. Учимся паять
12:05
We can do THIS now! - Lumafield CT Scanner
18:37
Linus Tech Tips
Переглядів 1 млн
Arduino IOT Cloud with ESP32 Relay Control
6:17
Ahmad Logs
Переглядів 7 тис.
inventor aw - This Device is very helpful ,, you can make at home
6:47
Game Boy games that did the impossible.
15:33
Modern Vintage Gamer
Переглядів 159 тис.
If you do wire soldering with paste, soldering can be done very easily
0:26
Tech Electronics BD
Переглядів 2,2 млн
Broken Flex Repair #technology #mobilerepair
0:55
ideal institute aligarh
Переглядів 14 млн
The Worst Product I've Ever Reviewed... For Now
25:04
Marques Brownlee
Переглядів 7 млн