Introduction to NodeMCU ESP8266 WiFi Development board with HTTP Client example- Robojax

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hi, welcome to an Arduino tutorial from Robojax. my name is Ahmad Shamshiri and I am from Canada. in this video I'm going to show you how you can get started with node MCU esp8266 Wi-Fi microcontroller unit. if you just want to prepare your arduino ide to write simple program a separate video for that the link will be below this video. this has a full detailed explanation of node MCU with all inputs and outputs voltages and I'm going to explain the hardware I'm going to explain the datasheet different types of the board and then we're going to learn simple a blank program after that we are going to check different input and outputs GPIO pins and also we will run a simple HTTP request so this module can send an information over the web or receive information you can get the code and length folders by clicking at the link below the video in the description. let's get started with this. internet-of-things have revolutionized the industry because of added capability of connectivity of different devices even from kitchen to industry to labs different equipment can be connected monitors or logged the data in a remote location or a server for processing monitoring security and many other reasons. esp8266 is a microcontroller with Wi-Fi built in in the same module by ESPRESSIF systems. this is a microcontroller similar to Arduino, you can program it but with the add-on features. there are a lot of similarity for example it has input and output and pins can be programmed but it has different features which I'm going to explain. so keep that in mind that if you are familiar with Arduino IDE this will be very easy for you. with a price of seven to twenty five dollars which you can get it from Amazon Aliexpress or eBay this is an excellent choice for learning and developing. and also in practical applications the module can be used. esp8266 is offer such that you can directly solder your own pins or wires and program it or solder it on a PCB or it is sold as a development module like nude MCU and D1 Mini many and many other different variation of this module. you can connect devices wireless is through Wi-Fi even within the same network in the same environment or over the internet in a remote location. so for example you can send temperature a position of something a sensor whatever value you have you can transmit it continuously or a certain interval whatever we program it and also you can send information from outside or within the network back to microcontroller. I'm going to show you how to get 3.3 volts or 5 volts how to connect external power to this device and then we are going to do some examples. these are all based on the same chip with different variation and label esp8266 this microcontroller chip is made by ESPRESSIF this thier website. ESPRESSIF systems. this is the main module and people are offering it in two different sizes for example you might get it at this size. or you might get it a smaller size. but all of these will have almost identical specification because the main chip inside is inside this one is esp8266. and here this one has the ESPRESSIF logo with Wi-Fi. and here is a frequency and everything everything is written. this is smaller and this is larger. and here there is a small and large of this type which have AI on it. and this one has AI. These two have Wemos on logo on them. again this is esp8266 this is called d1 and this is also the d1. and this one has a different logo but the whole point is that these are the same chip and the same microcontroller the same software will work. and on the board we have nine digital pin D0 up to D8. at the middle we have 3.3 volts and this is TX Rx. and then again 3.3 volt. when the 5 volts come here via USB it goes to this 3.3 volts regulator that will supply power for this and for the chip. and if you're not using this USB you can connect the external 5 volts to this pin which goes to this 3.3 volt regulator and it will just work fine. the same way for this small one we have VIN and here this is analog pin. we have one analog pin here not unlike or do we know which has multiple pins, this one has only one. analog pin. if you pay attention we have a chip here on this shape and in these two we have desk worship this is CP 2102 for USB and this one a ch340. Datasheet viewed and this is the datasheet here are the key feature for the Wi-Fi the frequency is 2.4 gigahertz this is not the 5.8 gigahertz and the lower frequency. and that also affects the bandwidth(lower). but it can work with a B G and n type support. have other details like TX power, RX sensitivity. protocols type of CPU and the rest is here we are not going to have a look at those I will provide you the link in case if you need further information. operating current is important for us because it consumes 80mA at normal operation. and operating voltage is 2.5 to 3 point 6 volts. This will operate the 3.3 volts because we have voltage regulator of 3.3. Voltage Explained Here I voltmeter one while ground is connected in here ground. and let me connect the positive of this to the to this pin which is labeled 3 volts that's 3.3 volts. and let me connect the USB you will see that we are getting 3.3 volts from this pin. and if you need to get 5 volts you can get the positives connected to this VU pin from this side the third one. so that is 5 volts from this pin. operating this device that's 5 volts is directly connected to USB but you can power this up from external source from this pin. let me connect this for example there's back to 3.3 volts as you can see we have 3.3 volts but now this is my external power here I'm connecting the ground to the ground to this pin ground having connected this pin and here I have 5 volts. As soon as I connected, as you can see we are getting 3.3 volts from this pin without USB. The same is true either for both of this module this Wi-Fi with AI and Wi-Fi with a thumbs type sign. both of these have vu vu so you can connect external power via VIN and have with this however you will not be able to get 5 volts output from this but you can't correct VIN. let me show you first a voltage ground and then 3.3 volts if I connect USB if I connect USB you will see 3.3 volts and if I move this to other pin anywhere that is written as 3 point 3 here this pin I can get 3.3 volts and if I connect external power we can connect the VIN and the external power we are getting 3.3 volts and a module the module is now ON without USB. but again for this module with AI and this module with a thumb they are exactly the same but with comparing to this module they are smaller. Preparing Arduino IDE to work with ESP8266 I'll provide you the link you will come to this page actually we are looking to this address copy it so I am just copying it and then go to Arduino IDE go to File-> preferences and at this area if you have more or less if you have more just click here so we can press control and V paste it. that's the address. click OK and then click OK. now go to Tools->boards->board manager wait for this to complete and then then type here esp8266 and it says esp8266 and here the install click install wait for this to complete. now it shows installed and this portion is completed. now we need to select the board click Tools->board->and then scroll down until you see Generic esp8266 this is 8285 and 8266, select that. it takes few seconds and it becomes ready. Selecting COM port now we are going to select the port by clicking at the Tools and then here the port you select the COM Port.if you don't know what is your COM port, on the Start menu right click go to the device manager and then scroll down until you see ports comm click on this arrow so it collapses and you see my COM port is 11. COM11. now I'm disconnecting the USB you will see that it disappears now if I connect it again you will see that it will appear back COM11. so go to Tools->Port and then COM11 is selected. if not select the port that you see in here. Code:LED Blink now the examples will be available under the File-> examples-> and esp8266 is here you can go to Blink. and this is a sample blink that we will upload now. this is for Arduino UNO. and it will work the same way exactly with this module let's upload it. let me bring this up so you can see it's compiling it the same way as an Arduino Uno I'm just scrolling so you can see it. once it's completed as you can see the LED starts blinking. and readable 10 there's a constant defined and it will just work fine with this as well. Wiring: Pin mapping example and here I'm connecting another LEDs separately. The resistor can be between 300 ohm - maybe 1k ohm I'm using a 1k ohm the value of this is not important because if you put larger value you will reduce the intensity of light of LED and you will point reach reach to a point that the LED will NOT turn ON. let's say if you go to 3 kilo ohm or more or 2 kilo so keep it between these values for the 3 point 3 ohm even even you can go for 200 ohms but I just put 1 kilo ohm and this goes to the positive to the pin that I will send the signal so from microcontroller it comes here and the pin is connected in here and it goes to this point and this led has 2 pins the longer pin is the positive the other one is a negative this is called anode the other is cathode and from the shorter pin I have gray wire this gray wire is going to the ground and here's gray is connected to the ground and this one I'm going to connect it to d1. Code 1:Pin mapping example and have in order to use the pins easily and do not get confused we could use this mapping I took this from one of the repository from github that is for esp8266 so these are the GPIO pin number this is a GPIO four five sixteen so forth because the board have been labeled as d1 d2 d3 and so forth it would be easy for us to use this one without wrecking that at the table. so you can copy this and paste it in your codes if you want to use them and here I've used it here and I'm using d1 as you can see D 1 is GPIO 5 that will work fine. and have once the code is uploaded. The LED is blinking perfectly with this value that I used D1 because it have been mapped to pin GPIO 5. Code 3: HTTP Client now let's see how we can use a HTTP client what is it used for for example you have a temperature sensor that is monitoring temperature of a liquid or something or a room and then this is connected to a Wi-Fi module which is not MCU in this case which has esp8266 Wi-Fi module. and then in order to monitor this temperature and do something you need that a server for example in this case dynamic data analysis systems server which receives the data and responds accordingly. so the temperature is measured by the Wi-Fi module or by the node MCU and then it sends that in a certain interval let's say every second every few seconds every minute every hour or whatever or when the temperature is above certain value below certain value or some sense or other sensor the door is open that the pressure should be sent whatever you want you can program it so that data is sent to the server. and the server can be programmed to respond according to the data either respond same thing to all or respond as the temperature is let's say about certain values respond in one way below certain value respond other way. so for example you have a heater that is heating chemical and the temperature sensor is sending continuously and you want to see if the temperature is above 80 degrees you want to reduce that temperature the heater so the DDAS server responds back let's say with a code 5 3 2, if 5 3 2 means decrease so this data comes back to the Wi-Fi and it sends it to the heater and the heater will reduce the temperature and then the temperature sensor is now is sending back and when it is below the value it doesn't send the value to control the heater or reduce it you just keep it in the same value that was an if it is above it sends another value you reduce it so this heater can be directly controlled with that so this is a feedback but also the server this is the job of the server that remotely can control this. or this can be also an app that somebody is monitoring on a phone on a big screen or somewhere and they can control or take action. so there are a lot of possibilities. now let me give you an example of using this as a HTTP client and HTTP stands for hypertext Transfer Protocol. what it means is that because it can get connected to the Wi-Fi and from Wi-Fi to the Internet it can access any other computer anywhere in the world. Let's open an example by clicking at File-> examples scroll down until you see esp8266 HTTP client and go with the basic HTTP client. once you open it this is the file that will open and it has all these include esp8266 Wi-Fi Wi-Fi multi HTTP client Wi-Fi client. do not worry once you install the driver the way that I shown you everything will be included and they're already there you don't need to do anything. so this is creating from that multi it's creating an instance of it and we call it Wi-Fi multi and inside the serial monitor the serial monitor is started with 115200 you can change it but when you open your serial monitor it must be the same value. and then it just creates three extra lines. and here is just displays a number between zero between 4 to 1 so it translates says wait and then 4 3 2 1 it's just fancy. after that the Wi-Fi mode we use add access point and this is the you are SSID and this is a password I just changed this every time I record a video so this is my Wi-Fi password at the moment SSID and the loop will continuously do this. if the connection happens HTTP client is initialized Wi-Fi client is initialized and it prints HTTP begin and it sends and requested that this is by default included with a code so it goes to this page let me show you copying it pasted I think it here and this is the page that the respond will be sent to. but because Arduino does not have a browser it's just a serial monitor you will not be able to see to see the image you will not be able to see this different size of text you will be able to see something like this. without the is from my antivirus the rest will be seen like this. it's uploaded there could have been uploaded 100%. now let me open the serial monitor. wait for few seconds because it restarts. and if you see here begin get or. if I reset this you will see it says four three two one and let me stop it so you can see what it has sent. it says that begin get it sends get method and then a code 202 that this is a page let me show you this was page (I pressed CTRL+U) that we were receiving and this is the code that we have received. created with a low press and you see all of that. so the text that was there we are getting a now in a serial monitor. and the code 200 is this if you see that the w3 OK means 200. so there are other codes. so that that's why this is okay and this code is such that s Rankine in runs continuously every few seconds. Code 4:HTTP Client and this line this can be just a page or this can be a request to sending a data for this address you're sending a number like 532 or something so that means information is sent. so we are going to replace this with a DDAS server URL which has been just launched except i have created me in URL here and this is ddas.cc and nodemcu01.php like that so this is a URL (you can use your own URL) and this question mark means parameter is being sent. so after this there are parameters and I put here user after that this will come user=ahmd22 and then float temperature=45.3 and we want to send this data user is ahmad22 and temperature is 45 degrees and the type is JSON we want to respond get respond back as JSON so we have these three now I put them together in one line and here so we said mean URL that was a main address class so we put plus and they put another variable this types user is equal ahmad22 and then after that we put ampersand temperature equal and then we put and pressure and type equal the type variable let's change the type variable here for now. I'm putting here K and save. and upload. code has been uploaded. let me open this okay so let me stop this so you can see it. the code if respond is 200 and here it says know them see your test and it's now doing it again. welcome to DDS dot CC user is ahmad22 temperature is 45.3. so it responds back. and we can do other things. this is HTML this is better to be viewed in browser let me show you so this was the text that you just saw and I've sent ahmad55 and temp temperature is 98.3 and then the type is equal K or nothing. and now our server will respond user inside the double quotation and then colon colon means this is the key and this is the value and then comma another key and value and you can respond with so many ways. so it's it's just responding I will create separate video actually changing or turning on and off something with this but for now let's just change it to J and upload it. now I'm making it J so this time we get JSON now let's open the serial monitor and heard a server responded user ahmad22 and temperature 45.3 and these are the values that I just sent continuously. I would like to thank my patrons from Patreon.com Subtitle typed on August 23, 2020 I did my part to help you learn. Now it is your turn. thank you for watching this was how to get started with nodeMCU esp8266 microcontroller Wi-Fi module. if you learned something and found this useful please thumb up 👍 as this will help my video in the search algorithm of YouTube. if you have comment or question posted in the comment section below I always try to answer a reply. and if you want to get updates of my upcoming videos you may subscribe now. I did my part to help you learn. Now it is your turn. You can subscribe to my channel, thumb up 👍 the video and type a comment by saying thank you. If you don't skip ads it will also help you . My PayPal Account link is in the description if you want to make cash donation. Thank you
Info
Channel: Robojax
Views: 46,853
Rating: undefined out of 5
Keywords: electronic, tutorial, training, video, robojax, arduino, code, download, node, mcu, nodemcu, esp8266, wifi, pin, mapping, gpio, http, client, request, web, connect, send, receive, blink, access, point, password, URL, ddas, shamshiri, ahmad, nejrab
Id: pLvqh57T3s4
Channel Id: undefined
Length: 27min 17sec (1637 seconds)
Published: Sun Sep 01 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.