ESP32 Web Server - ESP32 Beginner's Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone and welcome back to my channel so in this new tutorial we are going to create an esp32 web server that allows you to control these LEDs basically we can use the Wi-Fi capability of the esp32 board to control some devices that are connected to the esp32 using Wi-Fi from a mobile phone as you can see we can turn on all of these LEDs by selecting these buttons so before we get started make sure to smash that subscribe button and the notifications Bell so that you don't miss my next videos also I highly recommend you to watch my previous video which is the second part of the esp32 course I've talked about the esp32 Wi-Fi capability and how to use it in depth so without any further Ado let's Jump Right In [Music] so in today's video you will need an esp32 board a breadboard to make the connections and two LEDs I have this red LED with a 220 Ohm resistor so that we can protect it the same thing with the green LED you have to add this Ohm resistor as I said we are going to create an esp32 web server that allows you to control these LEDs from a smartphone or from the computer we are going to use web browser like Google Chrome later on we are going to replace these LEDs with relays so that we can control some high voltage devices like a lamp or the computer itself we can turn it on and off from the esp32 board but that's the topic of another video of course you have to download the project files you could go to this link it's my GitHub account under this project you will have the Eno file which is our sketch as well as the schematic diagram to connect these LEDs to the esp32 board you could go to code then download it as a zip file after that you have to extract it using WinRAR after you download the folder which is this esp32 web server let's open up the schematic diagram basically we will connect it the LEDs we have the green LED which we're going to control using this pen so this pin is the gpio PIN number 16 or 17 I guess to get the number of pens you could look at the back of the esp32 board or use this image so this is the PIN number 16. which goes to the red LED and the pin number 17 goes to the green one of course you have to add these ohm resistors and the other lead of the LED which is the cathode lead goes to the ground of the esp32 board so let's go back to the pin out diagram as you can see we have this pen labeled G and D or ground you could use any of these gpio pens that are labeled gnd so first of all I'm gonna hook up the esp32 board to the breadboard like this so that we can easily connect its pens and let's start by hooking up the red LED first I will take this jumper wire and connect the pin number 16 which is number eight from the side then let's go to one of the points on the breadboard after that I will add the ohm resistor of the red LED so if you don't know how to use a breadboard make sure to watch one of my previous videos I've talked about the breadboard when we have worked with the Arduino Uno basically it allows you to connect these LEDs or any other components very easily now we will add the anode pen in the same column so these points are connected if you put the longer leg which is the anode pen in the same column that means we have connected these two leads and the shorter lag which is the cathode pen goes to the GNT of the esp32 so let's use this jumper wire to complete the circuit and this is the GNT pen with the same way we can connect the green LED but this time I will use the pen number 17. then let's connect the 220 Ohm resistor and let's take the green LED so this is the positive lead and the other one goes to the ground but I can't connect the wire to the gnd pane you could connect it from here because these points are connected it's like a gnd pen or you could use the other one let's go back to the schematic diagram or the pen out of the esp32 board we have this second gnd pin I'm going to use it then let's complete The Circuit by connecting the gnd to the shorter leg of the LED and if you haven't watched my video about the Wi-Fi capability and how to use it I highly recommend you to watch it it's the second part of our series basically we can use the esp32 as a web server with two different ways or two modes the first one is to make the esp32 connects to an existing Wi-Fi network like the Wi-Fi network of the router and the second mode is called access point mode and in this case the esp32 creates its own Wi-Fi network I've talked about that in details in the previous video in our project I have used the access point mode but you could easily switch it to the second one and to understand that let's open up the sketch under our folder using the Arduino IDE before we test the code we have to plug in the USB cable of our esp32 board then we have to select the port prompt tools port for me it's complex then select the kind of board that you are using using tools them board and under esp32 we have different options depending on the kind of esp32 board that you have make sure to select the right one for me it's called node MCU esp32s so I will search for the name which is this one and if you are using the newer version of the Arduino IDE you will see the board as well as the board from this drop menu now let's explain the code a bit first we are including the Wi-Fi Library then we have two variables the first one is called SSID which is the name of the esp32 network you could call it whatever you want for me it is called esp32 Network later on you have to search for this name under the Wi-Fi and the second parameter is the password of the esp32 board for me I have used the esp32- password then we have this kind of server that listens to the upcoming requests from a mobile phone or from the computer anyways let's try to test this code first make sure to select nsid and password then let's hit upload and there you go it's uploading the code in some esp32 boards you have to hold down the boot key in order to upload the code which is this push button for me it's done now we have to get the IP address of the esp32 so that we can access its web server and to do that you have to open up the serial monitor you could select this pattern serial monitor or you could go to tools and Syrian monitor and here's the window first you have to select the portrait from this drop menu I'm using this one which is under the code if you go under this setup function we have the serial that began to begin the serial monitor with this portrait make sure to select it then let's reset the esp32 board using the reset push button and once you do that you see that we have this IP address now we can open up a browser But first you have to connect to the same Wi-Fi network of the esp32 board so let's open up Wi-Fi and you see that we have the name which is the Sid esp32-network and let's hit connect then I will write the password and once you hit next you will be connected to the same Wi-Fi network that is created by the esp32 board and once you do that you see that we have a new client is connected to the esp32 let's go ahead and copy the IP address that is printed on the Syrian monitor using Ctrl C then let's paste the IP address and there you go we have two buttons we have this text esp32 web server and this is the HTML file let's click on the first link or the first button to turn the red LED on and there you go it turns on we can know the state of the LED as you can see we have off the same thing we can control the green LED so this is one example on how to use the esp32 Wi-Fi capability you can control LEDs or even some appliances using Wi-Fi with the same way we can open up a browser from the mobile phone first you have to connect to the Wi-Fi network esp32 network and let's enter the password then let's hit done now it's connecting to the Wi-Fi network and if you get this message don't worry just hit keep Wi-Fi network or connection and once you are connected to the same Wi-Fi network you could open up a web browser like Google Chrome and you have to type in the same IP address and let's enter it and it's working we could know that the first led is turned off and we can turn it on so I think that's pretty much it guys for this video I hope you like it if you have any question or comment make sure to write it under the comment section down below and I will see you in the next one
Info
Channel: Enjoy Mechatronics
Views: 35,356
Rating: undefined out of 5
Keywords: enjoy mechatronics, how to, microcontroller, esp32 beginners, esp32, introduction, beginner, learn, sketch, connected, basic tutorial, pin, internet of things, smart, wifi, howto, basics, wireless, course, espressif, esp32 tutorial, ESP32, esp32 introduction, first esp32 project, diy, how, to, beginners, project, WiFi, control, server, web, easy, automation, internet, ESP32 Web Server, ESP32 HTTP, ESP32 Web Server Tutorial, ESP32 PHP, ESP32 Project, ESP8266 web server, Web Server library, DIY Web Server
Id: z-I-r3PX2lU
Channel Id: undefined
Length: 11min 51sec (711 seconds)
Published: Fri Nov 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.