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

Поделиться
HTML-код
  • Опубликовано: 17 дек 2019
  • 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
  • НаукаНаука

Комментарии • 152

  • @RuiSantosdotme
    @RuiSantosdotme  4 года назад +13

    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 года назад +9

    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 года назад +2

      Thank you for your kind words, I'm glad it was helpful. Greetings from Portugal, Rui

  • @jtrain1653
    @jtrain1653 Год назад +1

    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 года назад +1

    Clear and concise. Great video. Thanks.

  • @edsonferraz1
    @edsonferraz1 5 месяцев назад

    Congratulations Rui!! Great solution, thanks so much.

  • @rishujain21
    @rishujain21 4 года назад +2

    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?

  • @muneebbutt7101
    @muneebbutt7101 2 месяца назад

    i have watched a lot of videos about home automation using esp 8266 but nothing worked . but to my surprise, this time it worked . means a lot bro

  • @edsonferraz1
    @edsonferraz1 5 месяцев назад

    Congratulation Rui!! Great solution. Thanks so much.

  • @jag_3d
    @jag_3d 3 года назад +5

    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!

  • @CreativeDesk
    @CreativeDesk 4 года назад +1

    Your video is always so clear and also your website .all the necessary things are present in website
    Keep posting ...

  • @ldt_
    @ldt_ 4 года назад +1

    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

  • @WPGinfo
    @WPGinfo 3 года назад

    Thank you. This was very useful!

  • @kaiomatico
    @kaiomatico 4 года назад

    Wow now that is really awesome and clean code! Thank you so much:)

  • @pelouis9413
    @pelouis9413 3 года назад

    Thank you my friend by your project ,Im come from Vietnam.

  • @bishop34644
    @bishop34644 4 года назад

    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

  • @dons3357
    @dons3357 4 года назад

    Thank you. Helpful as always.

  • @Leo-db6mi
    @Leo-db6mi 6 месяцев назад

    really good stuff keep it up

  • @3DprintRC
    @3DprintRC 7 месяцев назад

    simple and usefully video.thanks.

  • @sameneko8979
    @sameneko8979 4 года назад

    Thank you for the video sir.

  • @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

  • @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

  • @RoMecha_lb
    @RoMecha_lb 3 года назад

    Great tutorial dear

  • @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?

  • @cizainnocent8392
    @cizainnocent8392 2 года назад +1

    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

  • @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?

  • @andys6
    @andys6 Год назад

    This is great! thank you

  • @user-dl3hj3cw9o
    @user-dl3hj3cw9o 4 года назад

    Отличный проект. Можно ли добавить простой таймер, например после движения ползунком влючается реле, а через 5 сек. отключается и ползунок возвращается в состояние выкл.

  • @raffaelebarlotti9017
    @raffaelebarlotti9017 Год назад

    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.

  • @societateanationala6207
    @societateanationala6207 2 года назад

    Took me 10 mins ... Thx

  • @2ds.service200
    @2ds.service200 Год назад

    A good work. Really i like

  • @kamalambrator4332
    @kamalambrator4332 4 года назад

    nice presentation! thank you

  • @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 ?

  • @BootlegEL
    @BootlegEL 5 месяцев назад

    Thanx this was helpful

  • @mr3748
    @mr3748 3 года назад +1

    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.

  • @christiangenebrozo2126
    @christiangenebrozo2126 3 года назад

    Hi good video, could you tell me how did you do the app to your celphone, thanks a lot

  • @chubbyvery1339
    @chubbyvery1339 3 месяца назад

    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?

  • @bossdonalan6840
    @bossdonalan6840 4 года назад

    Good explanation

  • @mojtaba3296
    @mojtaba3296 2 года назад

    fantastic!!

  • @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..

  • @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

  • @DeepRoy4600
    @DeepRoy4600 3 года назад

    Vou testar isso assim que tiver tempo. Serias capaz de me tirar umas dúvidas?

  • @sukasa9374
    @sukasa9374 4 года назад +1

    I see this tutorial only control 5 chanel ? Can this device use 8 chanel ?

  • @hussienmohamed2589
    @hussienmohamed2589 3 года назад

    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.

  • @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

  • @gurunanjaiahkembhavimath8728
    @gurunanjaiahkembhavimath8728 2 года назад

    Good video

  • @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?

  • @sandorfarkas7193
    @sandorfarkas7193 3 года назад

    Hello. do you have any idea how it can work with xlights with an esp32 16 channel relay?

  • @walterr8115
    @walterr8115 3 месяца назад

    Thank you😃, i was wondering why it doesn't work, then i realize the jumper caps were removed!

  • @Kunal_Joshi
    @Kunal_Joshi 3 года назад

    Hi Rui, is there a way to do the same using softAP.

  • @Dancopymus
    @Dancopymus 3 года назад

    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

  • @user-dm8sm3gw5o
    @user-dm8sm3gw5o 4 года назад +2

    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!

  • @elpetitcafe5385
    @elpetitcafe5385 4 года назад +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 4 года назад +2

      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

  • @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?

  • @mekszii
    @mekszii Год назад

    Hello! if I want to supplement it with a LoRa module due to the longer range, what should i do?

  • @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!!

  • @sanmeetsingh8219
    @sanmeetsingh8219 2 года назад

    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

  • @treeyuono9372
    @treeyuono9372 4 года назад

    Thank u....Rui...

  • @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!

  • @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?

  • @Circuitsplanet
    @Circuitsplanet 2 года назад

    Excellent

  • @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

  • @elektron2kim666
    @elektron2kim666 Месяц назад

    I need to do this at some point. My solar setup (tiny 12 volt batteries) must be off at night (draining from the controller, mostly) and my sister got some ideas where she lives.

  • @ingenierocristian
    @ingenierocristian 3 года назад

    Hi, I need to make an I2C communication between an Esp 32 and Esp8266, where can I find info about?

  • @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!

  • @RajatGupta_Pune
    @RajatGupta_Pune 4 года назад

    @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.

  • @nursyazwani8846
    @nursyazwani8846 3 года назад

    hi, may i know what database u are using for this project?

  • @guilhermepaixao1102
    @guilhermepaixao1102 4 года назад

    Exelente.obrigado pour partilhar.Bom ano!

  • @naufal9104
    @naufal9104 4 года назад

    rui, how to post data without refreshing the page?

  • @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!!

  • @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?

  • @MFORMAAZ
    @MFORMAAZ 4 года назад

    Can I control 1 phase AC motor

  • @hummingbird2520
    @hummingbird2520 3 года назад

    Can we Controll led output of 1 volt

  • @dkeinys
    @dkeinys 3 года назад

    Hi Can you please create version of this script that allows to control relays based on Temp & Humidity??

  • @Santiter
    @Santiter 4 года назад +1

    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.

  • @eldaelda4991
    @eldaelda4991 3 года назад

    How reverse the output,
    Relay 16 channel have positif input.

  • @quickfixengineeringltd8035
    @quickfixengineeringltd8035 3 года назад

    I have a hosted domain. How do I make this project controlled over WiFi not with a local network

  • @bhaskerreddy9054
    @bhaskerreddy9054 4 года назад

    Is this can be controlled from anywhere in the world

  • @NEWBI3GAM1NG
    @NEWBI3GAM1NG 3 года назад

    hi sir is it a local server only? thanks in advance

  • @evilmode100
    @evilmode100 2 года назад

    Hi how to name each gpio? as Relay #4 renamed to garage?

  • @enriquebartolini6161
    @enriquebartolini6161 2 года назад

    Do you need an ip pubblic? Thanks

  • @AshiqurRahman
    @AshiqurRahman 3 года назад +1

    Is the relay module 3.3v or 5 v

  • @christianrojano6470
    @christianrojano6470 4 года назад +1

    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);

  • @technotricks7627
    @technotricks7627 Год назад

    Sir i need, auto on relay when connected to wifi can u help me? M a beginner

  • @jumbo999614
    @jumbo999614 Год назад

    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...."

  • @shandradm911
    @shandradm911 2 года назад

    how to make if turn off relay 1 turn on relay 2?

  • @Circuitsplanet
    @Circuitsplanet 2 года назад

    Is there anyway to control it through internet is????? Plzzzz

  • @0124akash
    @0124akash Год назад

    This project based on local area network or global ?

  • @CharDhue
    @CharDhue 3 года назад

    I use this relay module but the relay won't change even thou the led change with 3.3v from nodemcu

  • @valdirturquettes8715
    @valdirturquettes8715 4 года назад +1

    Olá ! Amigo
    Seus videos são bons
    Faca em português , que vc vai ter muitos seguidores no aqui no Brasil
    ATt

  • @enriqueolmeda1
    @enriqueolmeda1 3 года назад

    Hi Rui, ESPAsyncWebServer is not available... What can I do? Could it be that it does not exist anymore?

  • @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?

  • @titsik
    @titsik 4 года назад

    you are genios

  • @Dean.Michael.Winchester
    @Dean.Michael.Winchester 2 года назад

    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?

  • @user-xe5fg8yy3l
    @user-xe5fg8yy3l 5 месяцев назад

    i know it is long time this video was relased but i tried it and is wdt reseting can somebodz help me????

  • @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?

  • @magicianofelectronics951
    @magicianofelectronics951 3 года назад

    Compiling error for ESP8266, Wemos D1 R1 mini, Thank you

  • @technophile01
    @technophile01 3 года назад

    Hi. Can we access to esp8266 from anywhere ? Thanks.

  • @mbzumzum500
    @mbzumzum500 4 года назад

    i have ESP-01s Relay v1.0 ..... with ESP8266
    how to easily connect to a phone and
    to control the relay

    • @Gam3rsleague
      @Gam3rsleague 4 года назад

      If you have Wifi Access search for "esp http-switch". It let's you controll your ESP by entering URL's in you browser. e.g: "my_esp.local/switch_on" or "my_esp.local/switch_off
      That's the easiest way I know of and it also works with any other device which can run a browser (or some sort of http-request service) :)

  • @mikepatton9684
    @mikepatton9684 2 года назад

    and webserver with espalexa?