Over the Air Programming(OTA) using ESP8266 Node MCU

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone this is ajay again with another video uh in this video we are going to uh see uh how to uh upload a code into uh esp nodemcu uh esp8266 node mcu uh like wirelessly uh we will be doing an ore over the r uh programming uh so uh basically uh we need uh the following thing these are requirements like uh we will need a esp8266 node mcm and then uh our pc with uh wi-fi if you have a laptop with wi-fi uh built-in wi-fi you can go for it or you can use a dongle wi-fi dongle in case of a desktop pc and then next is your wi-fi router or uh mobile phone uh which uh which supports uh hotspot wi-fi hotspot so either like a wi-fi router or uh mobile phones or hotspot uh once these are ready we can go for uh ota that is over the app programming and now basically uh when we upload a code um so now let's get into our arduino ide so here you can see we have the base sketch the usual programming method is we just go for basics and we have blink code here so that's what is here and it's like we have a built-in led which is going to be switching on and off but now with the thousand millisecond delay that's one second delay and we upload this code uh here and that is like you can see i have connected my esp8266 to the pc as shown in this image and um here it is com4 that is serial port it says serial port and com4 so now esp8266 is connected to com4 and now uh i have selected the board here and uh here it is esp ah a two double c that is nodemc one uh 12e module so that's what i am using here so we set our border it and um it is like uh the uh code is uploaded uh an esp using the cable so that's how the serial programming happens now what hap what we are going to do here is we are not uh the first for the first time we will be uploading the code using the serial uh port lattice will be using the usb cable and uploading the code and then once the device is ready for ota we can go for uh wireless programming so we'll be uploading the code wirelessly you can connect the nodemcu somewhere like like plug it somewhere uh in like power it somewhere and then you can upload the phone so that's what you are going to do so here um um [Music] the base basic uh ota that is the ota library is like you uh make sure your sys you are connected to internet and then you can click on manage libraries and here uh it will search for the latest libraries and net updates the library and one once it is done you here you can search for arduino ota or you can get arduino otl library separately from google and then you can install like update the library using add library method so here we have arduino ota that is upload sketch over network to arduino board with the wi-fi ethernet library and you can see it supports uh these mini boards here so you can install click on install and directly install this library or you can get uh ordinal library zip file and then add to uh to the uh the usual method like we use it uh here like sketch uh include library ad zip library and then we can add it and now i have already added it and you can see here in under examples i have arduino ota and it shows the bc basic ota code and the basic oda code here you might have a different header files so what happens now is here you will have to do certain changes like for esp8266 you will have to have add this header file and then the mdns dot h and then ssid is here now i have my mobile hotspot so i'm going to use my username and password here so next is you can use your wi-fi ssid password and your pc as well as nodemcu needs to be connected to this common uh hotspot or the wi-fi router and which will have the same ssid and password and the these are like uh the basic uh structure or usual ordinary structure where we have the serial port control serial port configured with uh the battery and um it prints something here like booting and then it checks for whether the wi-fi connection uh is uh the esp checks for like whether it is connected to a wi-fi or not if not it tries to restart the esp device and now here you can see it's like arduino ota start these are the ota commands which is there like uh ota start and ot and and then when ota is in progress that is over the app update is or the program is in progress uh it shows the progress status here and there are uh many um if so in such case like if otf fails like if some error happens authentication fails all those errors will be displayed in the serial console uh now um uh this library take care of uh takes care of uh ot and then um uh now if we upload this particular code into uh esp then the esp will be ready to go for ota um that is over there over there programming you can keep away the esp module somewhere and power it and instead of connecting to a pc through the serial port you can keep it somewhere like power it somewhere and then you can upload the code now we can just try doing it it's like now uh for the first time i have to upload this code so now it is not ready for ota so we have to upload it uh upload the code using the normal serial communication method so we have com4 and my device is connected here and com4 and then i am going to upload the code here i missed something okay ot is something like um we can see in smart phones like we will have a syste updates updates provided by the uh the latest os updates provided by the manufacturers so just provide us the latest updates likes uh the system updates so uh that is also a similar kind of other like we download the file and then we used to reboot it to get the new firmware updated for like the latest android software so all those are like otm so that is what is already performed uh in the mobile and uh it is somewhat similar to what we are doing here you can we are going to upload the code um and it can also be used for updating uh like uh which happens in the mob smartphones so that is called ota update it's like over there update so that's that can also be performed um it's almost uh the code is uploaded so now it's 100 complete and now i'm going to open the com port um reset the board once so it says like it has acquired an ip that is 192.168 and you can see it's like it shows booty and that's what is here in the code and now um how to select the port like instead of the serial communication port what to select here for a ota so we will see that it's like in tools under tools you can see com port and here you will get the network ports that is esp8266 something like a a a f five two b four at one ninety two dot one sixty eight for forty three dot two not four this will differ for you based on your routers and on your mobile phones hotspot so you will have an ipa here and you can see under port and we'll be selecting this so once this is selected now we can see like the board is connected to on the network ip here instead of com port that means like now it is ready for the ota and if you don't get this you can just try uh closing the arduino ide and you can restart the arduino ide and then it will definitely get the port here there is a network port so now here we have the we have the asp 2 6 ready for ota what i'm going to do now is remove it and now i'm going to connect this dsp a2 double six just like i'm gonna normally power it now uh it's like my esp8266 it's not connected to um this pc and it is connected to uh it is directly powered using my um mobile pc uh mobile adapter uh now what i am going to do is select the basic example that is a led display example basics on blink code and now we have the billing code and you can see here under tools the port is selected as esp8266 and the ip is 192.168.43.204 and the com port is missing here so now i'm going to try uploading the code so so the code is going to upload get uploaded wirelessly so let's see if this happens so you can see the control output here like what is happening sometimes like you you will have to definitely disable your firewall it's like if you have a public or private network that is like the hotspot is a public of a private network you will have to disable the firewall and then you will have to upload the code or else you will not be able to upload the code now you have the code ah getting uploaded it's like now the code is uploaded it says done uploading so it is wirelessly uploaded and now i've got the output here you can see a led flashing and now next uh okay uh what is the next thing we are going to do is it's like now we can see that the earlier code was ota code and now we have our led uh blink code which is being uploaded in this esp8266 it means like the ota code is already erased so what is the best thing is to like we have to retain the ota code it's like if i am going to place my uh esp on and i wish to upload the code again and again wirelessly then i definitely the ot code has to be retailed so in such case what we are going to do is just copy this and we are going to paste it here and then like the led code is i'm going to bring the led code here inside the ota code next the digital write and read code and now uh i've already uh commented the lines here so i'll remove the comments now uh the earlier blink code is like we have uh uh this code uploaded and it's flashing at a rate of one second on and one second off that is thousand millisecond on and off and now what i'm going to do is uh now i'm going to upload this code so for uploading this code we will not be able to upload the code because now the uh code which sits which is sitting inside esp8266 is the blink code the earlier ot code has been erased now let us try once still it is like a port es that is connected to the network port and i'm going to try uploading the code so just to show you that ota code is erased so now what happens is it will say that it is unable to get connected to the port so now we got the output here you can see it says uh no answer uh that is it is not able to communicate with the network port so what we are going to do is now we are going to upload the the uh we are going to do something like we are going to upload the ota code along with the uh um blink code so that we can any time upload the every time when we upload a new code we should have these part of ota code so that the next time when we upload we can do it wirelessly so what i'm going to do is remove my esp and connect it back to this serial port that is again back to my pc so now it's connected and uh here you can see i have my com port back and now i'm going to select com port and now i'm going to change this to one second back and we'll do uh ota again so it's like now i'm uploading the blink code along with the ota code so what i'm going to do is upload this code to esp using serial port so let's wait uh let's see if the code is getting uploaded once this is done we will remove this esp8266 connected back to the remove from the pc and connect it to the direct power so that we can do a wireless programming so now it just like it is getting uploaded serially um so we'll have a blink code ota code and blink code together sitting in esp2266 and the blink code is going to have a honorable flash on okay now we have the uh blink code you can see the blink code happening here it's like on and off now i'm going to check if i have the port here so i'm going to change it to again back to the network port and what i'm going to do is uh now um you can see the led is blinking at the rate of 1000 milliseconds and now i'm going to change this to 100 to make it a little faster it's like it will the blink rate will be little faster so but we are going to do this over the air so i removed it and i'm going to power it directly with my usb adapter now i powered it powered the esp and i will only have my network port i don't have the com port listed here and now i'm going to try uploading the new code here we have changed only this 100 milliseconds and now i'm going to upload the code so let's see what's happening and so now what happens is still you will be able to uh now we are going to we are trying to upload the code along with the ota uh code so what happens now is the next time when we upload the code you can definitely upload uh wirelessly because the volte code is already sitting along with the led blink code so this is how we'll have to write the code so in order to continuously have a wireless programming so now it's like the code is uploaded and you can see the blink rate is faster now it's like 400 milliseconds and again i'll be able to program any other code like along with this we can write in any applications of our interest and then upload the code but still the ota code has to pretend for the next uh wireless programming so uh this is how we'll have to perform the ota and so i wanted to explain you otn details for uh i took this much time so um thank you we will meet in another video thank you thanks a lot
Info
Channel: ChipRide
Views: 537
Rating: undefined out of 5
Keywords: esp8266 ota update, esp8266 ota, esp8266 ota programming, arduino ota update, arduino ota esp32, arduino ota upload, arduino ota no answer, arduino ota example, ota nodemcu arduino, esp8266 ota tutorial, arduinoota, esp8266 ota webserver, ota esp8266
Id: j9AZPDHqswM
Channel Id: undefined
Length: 20min 18sec (1218 seconds)
Published: Mon Dec 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.