ESP8266 Relay Control via Web Browser

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ส.ค. 2024
  • Subscribe for more weekly videos!
    Follow me on Twitter @itkindaworksinc
    This next video builds off the getting started video and swaps out the LED for a relay module controlled by an optoisolator. Instead of simply blinking an LED, we can control anything that can be plugged into a wall socket. This project also demonstrates using the aRest libraries to create a webpage to control our relay rather than just turning it on or off as we did in the last video.
    Link to breadboard layout & code in this video:
    github.com/ItK...
    Hardware you'll need for this tutorial:
    Breadboard
    ESP8266-01 Module
    FTDI (or similar) 3.3v USB to Serial Adapter
    5V supply (my FTDI adapter supplies 5V and 3.3V, yours may not)
    USB Cable
    5 Male to Female Jumper Cables
    4 Male to Male Jumper Cables
    3 Pin JST female connector
    Small Extra Jumpers
    Optoisolator
    5V Relay Module
    220 Ohm Resistor
    4.7k Ohm Resistor
    100uf Capacitor
    Pushbutton
    Let me know what you want me to show you next!

ความคิดเห็น • 60

  • @gregm.857
    @gregm.857 7 ปีที่แล้ว +1

    Excellent. Very clear explanation and instructions. Very good spoken delivery ... nice speed and clear pronunciation. After watching a handful of other videos on the same topic, this is definitely the best. This is bookmarked for future reference; I will order some ESP8266s tonight!
    Two minor suggestions: (1.) Your screen text was unreadable even when full screen on my system; please zoom in on the text if you can. (2.) I've always heard the term "optocoupler" and NOT "optocouple." Wikipedia and Google Search confirm this. It isolates and couples two different circuits, so it's an isolator and coupler. I don't know where you got the variant without the final "R."
    Otherwise, as I said ... excellent tutorial. (PS: I am an adult education instructor / trainer / mentor; I think I know a good presentation when I see one.)

    • @aofddofa6661
      @aofddofa6661 5 ปีที่แล้ว

      hello Prof. for the blurred text issue.... click full screen square then click on thr gear (setting, then Quality then choose the best for you)... mine looks perfect at HD 1080 then i can see very clear sharp text .... if u r instructor ; please give high notes to make kids happy :) ..

  • @DevilbyMoonlight
    @DevilbyMoonlight 6 ปีที่แล้ว +1

    Thanks for sharing this, I have only just found out about the esp 8266 and this here is verything I need to get started with it

  • @anokhautomation4453
    @anokhautomation4453 ปีที่แล้ว

    Nice useful tutorial and project 👍. expecting more tutorials related to ESP 01 can control using mqtt server.

  • @ThomasPalowitchSr
    @ThomasPalowitchSr 7 ปีที่แล้ว +2

    Excellent tutorial. You speak clearly and distinctly.I had the module up and running until I switched my cable service to AT&T. They installed a Page model 5268AC modem/router and I lost my connectivity to the LAN WiFi. Something in the RF link or protocol I guess. Do you have any idea what I can try to regain connectivity?

    • @ThomasPalowitchSr
      @ThomasPalowitchSr 7 ปีที่แล้ว

      FYI: Got it fixed. 2nd call to ATT support led to very knowledgeable IT specialist.The fix was to widen the WiFi security Authentication Type for the 2.4Ghz radio configuration.

  • @MaxReckless99
    @MaxReckless99 7 ปีที่แล้ว +1

    very helpful. thank you..
    please keep up the good work

  • @Neo929
    @Neo929 7 ปีที่แล้ว

    i have a problem, the line in wich stands "myRest.button(2);" I made a mistake. the "button" gets not in orange, I think i missed here something, but I installed both libraries. Any idea? .. When I stard the ESP-module it connects to my network, but i can't open the website.

  • @Jack_Mehoff_
    @Jack_Mehoff_ 8 ปีที่แล้ว

    Great vid.....is there anyway to get the current status of the pin displayed so I will know if it is either on or off?

  • @89elmonster
    @89elmonster 7 ปีที่แล้ว

    Hi, great tutorial. One question though, why are you using that led/diode chip to control the relay? Does the wifi module not provide a 5v signal to directly turn on or off the relay?

    • @ItKindaWorks
      @ItKindaWorks  7 ปีที่แล้ว

      There are 2 reasons to use the optocoupler. The first is because yes, the ESP does not provide 5V so it cannot trigger the relay alone but also because there are large voltage spikes from the relay so the optocoupler isolates the GPIO pin from the relay

  • @musicalshibu4959
    @musicalshibu4959 7 ปีที่แล้ว

    sir, the relay already has an inbuilt opto-isolator then why did you use another one externally??

  • @guatagel2454
    @guatagel2454 5 ปีที่แล้ว

    Where I was in 2016? Damn...

  • @MaxReckless99
    @MaxReckless99 7 ปีที่แล้ว

    the off button is turning it on and on button turn it off. how can I fix this ?

  • @mdkamruzzamanrussel612
    @mdkamruzzamanrussel612 7 ปีที่แล้ว

    awesome tutorial

  • @didiersee
    @didiersee 6 ปีที่แล้ว

    Congratulations from Belgium, i'm testing this programme but i have error message "error compilation for generic carte ESP8266 and i have a same ESP8266 that you.Could you help me please?

  • @miksa3981
    @miksa3981 6 ปีที่แล้ว

    Hi! I want to make same thing using nodemcu and instead one i want to use 8 relays. Can i use same code as you did? And can i later use https request to turn off/on lights using my phone instead of pc/laptop...

  • @erlingliteigen916
    @erlingliteigen916 7 ปีที่แล้ว

    Hi, I saw you answered below what optocoupler you normally use (PC817C). I don't have that available, but I have a broken 5V relay that has a DP 817C. Do you think that can be used?

    • @ItKindaWorks
      @ItKindaWorks  7 ปีที่แล้ว

      It'll probably work yeah! Try it out!

  • @Al-bd8hm
    @Al-bd8hm 7 ปีที่แล้ว

    Please, share the connection of all elements.
    What is the switch for?

  • @nurizzati3128
    @nurizzati3128 7 ปีที่แล้ว

    hai .. good tutorial sir , i like it .. i just want asking, if we use esp8266 wifi node MCU can it ?

  • @finalproject8365
    @finalproject8365 7 ปีที่แล้ว

    GREAT TUTORIAL. I will like to know how to use the library in android app. I want to control the relay from my android phone. thank you in advance

  • @GameDownloader112
    @GameDownloader112 8 ปีที่แล้ว

    Good vid , but can you change appeareance of buttons or are they default in libary which you cant change?

    • @ItKindaWorks
      @ItKindaWorks  8 ปีที่แล้ว

      +Spike key Theres no easy way to change the way the button looks without changing the library unfortunately. You can of course forgo the UI library all together and just use the RESTful service and control the ESP via an external UI not hosted onboard the ESP. This is a more likely scenario anyways for real world projects.

  • @PanosB
    @PanosB 8 ปีที่แล้ว

    Very good tutorial! As for powering the esp8266, I think you power it by usb. Could you strip a phone charger and use the AC both for the light and the charger at the same time? I am trying to do it that way, but I get weird interference.. Cheers

    • @ItKindaWorks
      @ItKindaWorks  8 ปีที่แล้ว +1

      You can totally do it! I actually do that for a lot of the lights in my house. You just have to make sure that the charger is on the incoming side of the plug so you don't accidentally turn it off with the relay. I'd also add a large (220uf+) capacitor on the charger output if you're getting some noisy power especially if it's a cheap charger. What kind of interference are you getting? Like how has it been affecting things?

    • @PanosB
      @PanosB 8 ปีที่แล้ว

      I took apart this type of charger:) www.amazon.in/Callmate-Charger-Cable-iPhone-Touch/dp/B00EPEHNF2, and I have two symptoms when connected: a) The blue light on the esp8266 stays on and doesn't connect to wifi and fixed (1/5 times) only if I unplug the esp8266 and replug it again.. b) The relay module makes a buzzing noise :S, which fixed again if plugged and unplugged. My setup is this: www.dropbox.com/s/l8fabj891w3zpiy/esp8266_220v.png?dl=0 and I connect the relay module to gpio02 of the esp.. :)

  • @jaytech7514
    @jaytech7514 7 ปีที่แล้ว

    i have a relay with built in optoisolator. so can i just use a level shifter? for the 3.3v gpio to relay to make it 5 v? any suggestions?

    • @ChupoCro
      @ChupoCro 7 ปีที่แล้ว

      If you have the most common relay board from eBay with optocouplers and JD-VCC jumper then you can drive it with 3.3 V from ESP8266's GPIO without level shifter but you have to:
      #1: Remove JD-VCC to VCC jumper (important!)
      #2: Do NOT connect the same GND as to ESP8266 (if you want to have opto-isolation between two circuits but it will work the both ways)
      #3: Connect a separate 5 V power supply to JD-VCC and relay GND pins
      #4: Short the LED on the relay board (remove the LED and solder the contacts) so 3.3 V can be enough to control the optocoupler
      #5: Connect relay board Vcc pin to the same +3.3 V as ESP8266
      #6: Connect GPIO output pin to the INx pin on the relay board (GPIO = HIGH --> relay = OFF, GPIO = LOW --> relay = ON)
      Or you can just use NPN transistor (collector to +5 V, emitter to GND, to base from ESP8266) to drive 5 V input of the relay. In that case GPIO = HIGH --> relay = ON, GPIO = LOW --> relay = OFF.

  • @roystervi
    @roystervi 7 ปีที่แล้ว

    Hi I got the esp8266 12f program and after program the blue light on steady and I can go to the browser and enter 192.168.0.106 and see the switch to turn on/off...\\
    Question when l remove all the wires and only leave the gnd and the vcc, it do not not turn on, meaning no blue light blinking or it connected to my router.... do I have to connect any other wire to just turn it on?
    or what wires I need to operate i relay from the browser?

    • @ItKindaWorks
      @ItKindaWorks  7 ปีที่แล้ว

      Is it possible that you removed the wire connecting ch_en to 3.3v? You have to have that connection in place, gnd and 3.3 for the esp, gnd and 5v for the relay and then you need the connection for the ESP relayPin as well.

  • @AliAhmed-fi1oj
    @AliAhmed-fi1oj 6 ปีที่แล้ว

    Pl. re-upload the .ino file and schematic those both seem incorrect

  • @yashp1995
    @yashp1995 8 ปีที่แล้ว

    Good tutorial I must say.Can you make tutorial on how to do it with android smartphone?

    • @ItKindaWorks
      @ItKindaWorks  8 ปีที่แล้ว

      You should be able to do it on your android right now without any modifications :) Just go to the same page as on your desktop (the IP address of the ESP) and the on/off buttons should be there

    • @yashp1995
      @yashp1995 8 ปีที่แล้ว

      +ItKindaWorks Sorry but I mean to say using android application and I also watched your home automation tutorial great series thank you for that I just want to include a power monitoring into it if you can help me out in it please let me know thank you.

  • @3092rti2oewgn
    @3092rti2oewgn 7 ปีที่แล้ว

    How can I go back to use the AT commands after doing this tutorial?

    • @ItKindaWorks
      @ItKindaWorks  7 ปีที่แล้ว

      You'll have to re-flash the ESP with a firmware that uses AT commands. You'll lose the arduino/self programmed code but you'll be able to access through the AT commands. A little ways down this page there seems to be a good explanation for how to do this. www.allaboutcircuits.com/projects/update-the-firmware-in-your-esp8266-wi-fi-module/

  • @thefailingstudent
    @thefailingstudent 6 ปีที่แล้ว

    is it possible to make a timer for it from the webpage?

    • @ItKindaWorks
      @ItKindaWorks  6 ปีที่แล้ว

      I don't see why you couldn't do that! :)

  • @MPElectronique
    @MPElectronique 7 ปีที่แล้ว +1

    where is the aRest ?? plz ?

    • @3092rti2oewgn
      @3092rti2oewgn 7 ปีที่แล้ว +1

      Download these:
      github.com/marcoschwartz/aREST_UI
      github.com/marcoschwartz/aREST
      then in arduino ide go to Scetch, Include Library, Add Zip Library.

  • @clementmurphy4762
    @clementmurphy4762 8 ปีที่แล้ว

    Hi can you please tell me where to find #include
    #include libraries would very much any help
    Regards Clem

    • @ItKindaWorks
      @ItKindaWorks  8 ปีที่แล้ว

      Yup no problem
      github.com/marcoschwartz/aREST_UI
      github.com/marcoschwartz/aREST

  • @unthinkablecreations6878
    @unthinkablecreations6878 7 ปีที่แล้ว

    good day i loved your video but i dont have a ftdi thingy i have an arduino uno could you please make a video or give me some information on how to program my esp8266 for 2 relay modules i want to use? thanks in advance! :D

    • @ItKindaWorks
      @ItKindaWorks  7 ปีที่แล้ว

      If you have an Uno you can try my other video over here: th-cam.com/video/P_ecAFpUADU/w-d-xo.html

    • @unthinkablecreations6878
      @unthinkablecreations6878 7 ปีที่แล้ว

      okay i got it to send commands and to connect with my wifi but i have some problems. for example i compline and it says it wont find the libray of esp8266.h i would be greatfull if you could make a video using an arduino uno and the relays. plus the way to include the libraries and all . thanks again

  • @visanimator
    @visanimator 8 ปีที่แล้ว

    Can you give me the part number of that optocoupler used

    • @ItKindaWorks
      @ItKindaWorks  8 ปีที่แล้ว +1

      I don't have the # for that particular one anymore but the optocoupler I tend to use most is the PC817C

  •  7 ปีที่แล้ว

    here in england those colours are wrong lol, green is earth white would be live and black neutral

    • @ItKindaWorks
      @ItKindaWorks  7 ปีที่แล้ว

      That is great to know! I always assumed the international community had standardized that kind of thing even though sockets are different. I'll keep that in mind for future videos!

    •  7 ปีที่แล้ว

      yer, no problem, also here in England we actually use them colours for dc (well used to, now for dc its black and red / white) and for AC we use blue for neutral brown for live and green for earth these days. also what country are you in, usa? also again, you may be interested in my voice control vid i just uploaded using Alexa Dot and web extractor, plz check it out. great vid aswell btw :)