ESP8266 Programming Over The Air (OTA) Using Wi-Fi With Arduino IDE (Mac OSX and Windows)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi I'm Cisco with AK robotic and I'm here to show you another tip for working with your esp8266 microcontroller in other videos we've shown you how to upload your code to the esp8266 using the arduino ide we've done this by connecting our development boards over USB to our computers but sometimes this is simply not possible because we won't have access to the board itself in such cases there is a method of uploading your code wirelessly using what's called over-the-air programming or OTA for sure let's see how that's done if you've been following along our series you see not show you how to program the esp8266 using the arduino ide make sure you familiarize yourself with the process before moving on to this next step let's go to the IDE and open up the file menu examples and under arduino OTA basic OTA the first thing we'll need is to put in our Wi-Fi settings next we'll scroll down to about line 27 and uncomment the function called to set password we'll see what that's used for in a little bit finally we'll want to put our own code that we want to run inside the loop function notice that there is a single line calling the handle function of the Arduino OTA objects that line needs to be called in order for you to be able to upload new code over-the-air so we'll need to make sure that our own code doesn't interfere with this process the way I'm going to be doing that is by using a flag that I'll call ulti a flag and I'll initialize that to true I will check that that flag is set with a conditional and if it said then I want that line of code to run of course I don't want to do this forever because I want my own code to run so what I'll do is inside that conditional I will check for the amount of time that has elapsed from when the program started running I'll do this by comparing a variable that I'll define in a second that are called time elapsed with a number that I'll arbitrarily set to 15 seconds I'll do it as 15,000 milliseconds I'm going to update that variable by calling the Middle East function which keeps track of the amount of milliseconds that have elapsed from when the program started running I'll initialize that variable to zero and I'll add a very short delay inside that while loop so that nothing breaks while that code is running after time elapsed reaches 15 seconds I want to make sure that I break out of the conditional by setting the OTA flag to false notice that the conditional at that point will always evaluate to false and the rest of the code inside the loop will run in my case I will simply run a blinking program that toggles on and off the built-in LED on the esp8266 I'll use the do write function on pin two and I'll use a simple trick for inverting the previous state of the pin I'll add a one-second delay and I won't forget to setup the pin as an output inside the setup function let's go ahead and save this file I'll choose my desktop and I'll rename it to basic ot a custom I'll make sure that my Craig board and port are selected in this case as lab USB to UART as well as the node MCU 1.0 upload the code notice that this upload is happening over USB we need this connection to upload the firmware that will allow us to then upload code wirelessly if we go ahead and open up the serial monitor and reset the board we should see the IP address assigned by the wireless router printed on the screen we should also see that after 15 seconds pass our code for blinking the LED once per second should be running now we're able to upload the code wirelessly so if you want to you could unplug the board from usb go back to the arduino ide go to tools for it and you'll notice that there is a new port called esp8266 and at the end we'll have the IP address that your Wi-Fi router assigned to the chip if you don't see this option go ahead and restart the arduino ide once you see it go ahead and select it and at that point you can unplug the board and in my case i'm going to change the delay of the blink from 1000 to 100 milliseconds so that i can see a difference on this new file notice that once you hit upload it'll ask you for a password that's where that line that we uncommented comes into play I let the password at the default 1 2 3 and I'm going to put that in notice that two things happened after I hit upload the password field comes up again and I can read them here that will receive an error with no response from device if you remember we wrote insider loop function a 15 second period of time where the Board expects that firmware to be uploaded after that happens our own code for blinking the LED without checking for a new firmware upload so what we need to do is a little bit tricky we'll need to reset the board type in the password one two three and really quickly hit the upload button as you can see if we do it with enough time the upload actually complete the password field doesn't pop back up is resets the board and after fifteen seconds pass we'll see the new code running in our case the blinking LED is an indication with the faster rate that we modified this is just one solution for programming the esp8266 wirelessly the problem is that if we want new code to be uploaded we need to unplug power to the board and plug it back in so that it resets in another video we will show you how to use a web server running on the esp8266 that can receive that new firmware file without hitting reset if you like our videos you can go to our Channel and click the support button but whatever you do don't forget to Like subscribe or leave us a comment until next time you
Info
Channel: ACROBOTIC
Views: 78,266
Rating: undefined out of 5
Keywords: ESP32, ESP8266, Arduino, IDE, NodeMcu, Tutorials, Makers, Learn, Guide, IoT, Internet Of Things, Raspberry Pi, Wireless, Communication, Weather, Creative, Sensor, Python, Programming, C++, Beginner, Electronics, DIY, MicroPython, 3d Printing, CAD, Fusion 360, Education, Tutorial, Intro, Introduction, Web, Developer, HTML, Datalogger, Project, Sensors, Data, Visualization, Webserver, Server, Client, App, WebApp, Wemos, Robot, Robotics, Robots, Easy, Adafruit, Sparkfun, OS X, Windows, Linux, Embedded, Kickstarter, RC, Fun, Build, Engineering
Id: gFK2EDNpIeM
Channel Id: undefined
Length: 8min 31sec (511 seconds)
Published: Wed Mar 29 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.