Again, I started the adventure to create a platform for my future things which are connected with the Internet. As mentioned in the previous videos, I was so far able to connect to a web service program. The ESP modules, even when they are soldered on a small, PCB and load some initial information from the smartphone to the module programming with my programmer and the pogo pins, is not easy. If the thing is not reachable because it’s built into something so the guys around. Even developed a completely new method to load the software on an esp8266 module, we now can load it over the Wi Fi network or, as engineers say over the air, the abbreviation is OTA. This is extremely convenient and, in addition, quite fast in this video, I show you how to do it and, of course, also some tricks. I learned during my experiments. How is it done? Even and his friends took care that the necessary programs are already implemented in the Arduino one point: 6.5 version, so on our computers, everything is already there in the ESP sketch. However, some additions have to be made to our normal sketches. Just at the beginning, OTA works only with 4 megabyte flash chips. These chips are currently used in the ESP 12 II modules to find out, you can run a sketch and get the size of your flash. Currently, my ESP or 107 and 201 only have 512 K. Flash and cannot be used for OTA.
I already ordered bigger flash chips and if successful, I will show you in a later video on how to change them. Let’S start from what we know in the old world, we load a sketch to the module using serial communication on the ESP s and also on the arduino z’. There is a program called bootloader which takes all the necessary steps on the modules. Many arduino users even do not know about this program because it’s flashed during production. I call this bootloader serial bootloader, because serial boot loaders wait for input on the serial line. They are useless in the over the air world. We need a new Wi Fi bootloader function on the ESP. Currently we have to create this vibe bootloader ourselves and it is part of our normal sketch. Unfortunately, it has no protection mechanism against unattended changes like the serial boot loaders. The principle is the same. We have to put our modules somehow in a Wi, Fi bootloader state, and then it is ready to accept the sketch from the IDE very similar to the procedure with a serial line after the upload, the module boots, and we have to make sure it ends in Our regular sketch, I show you first how simple it works. We load the example provided with the IDE and adapt the access point name and password that the module can connect to our network after a while. A new port shows up the wireless connection to our module.
You choose the OTA communication protocol and this sport, the rest stays the same and off you go with uploading, a sketch, very simple in the OTA mode of the IDE. The serial console does not work anymore and I have to use a trick to show you what happens during upload. I use another serial communications program called potty to connect to the normal serial adapter. Then you still are able to see the result of serial print commands. You see here if I reset the ESP it goes directly into this Wi Fi bootloader mode connects to the Internet and waits for input from the arduino ide. You see here its IP address after the upload, the module automatically resets itself and again waits for programming input. Of course, in future sketches we have to make sure that the sketch goes into normal operation after a successful OTA upload. But for now we loaded a new sketch without any physical connection to the module through the air. Awesome let’s look into the Wi Fi bootloader sketch. It consists of two parts, one part which has to be in the setup and the other part which has to be in the loop in order to use our ESP module not only for a software update, but also for real applications. We have to add our normal sketch in both areas set up and loop. Just after reboot, the sketch has to decide whether it wants to do upload or normal operation.
We have to find a way to signal the board if we want to upload a new sketch or run it here is my example. In my thing, I need anyway to button switches for the normal operation, so during startup, if both buttons are pressed, the sketch goes into the Wi Fi bootloader mode and after the uploading of the sketch, the module goes directly into normal operation. Because I did not push the two buttons anymore, simple trick. Now I want to show you that this really works. I change the welcome text and upload the program. As you can see, the new sketch was really uploaded. Let’S now have a closer look at the code. I will not cover the technicalities of the OTA coding. There are much brighter people out there to explain that. I include a link below to the coding I used. I unleash oh you how to embed the two code snippets into your normal sketch. First, during startup, I have to check the two buttons or you do something else, to make sure that the ESP knows that you want it in the Wi Fi bootloader mode. Then I set the OTA flag and do the part of the OTA script, which has to be placed in setup. I call this part o da in it. If the buttons are not pressed, the sketch continues into normal operation and the OTA flag is set false. My loop is very simple: if the OTA mode was selected, the sketch goes to the OTA receive part, and if not, it goes to the normal loop that’s, all again, very simple, with Arduino Sui all use serial communication for debugging.
As I said before, this does not work here, but I already showed you the trick. I use connect a simple USB to serial adapter and a small program called putty to show the results of the serial communication like that we can debug as usual. Of course, this procedure is not used for modules placed in things, but to test your sketch it is a good way. I have also to mention that this procedure is not yet completely reliable. Sometimes it does not work and the upload is interrupted without an obvious reason. Unfortunately, then, the sketch was destroyed and I had to load it the old way through the serial cable. But I know these guys work hard and I’m sure they were resolve the issues or at least make sure that during an unsuccessful load we do not lose the original program and can try another time. So, as a summary, my workflow is as follows. I still use serial communication for development with a note, MCU board. This is more convenient, but from time to time I load the release to the thing over the air just to check if everything also works in the target system. Before that, I always upload it once over the air, to my note, MCU port, to make sure that the OTA part of my sketch really works before I flash it to my thing. This was all for today in the next video. I will look deeper inside the coding of such things to make them stable and responsive.
arduino ota Video
arduino ota news
Posted on Friday August 23, 2019OTA Flash Tool Makes Fitness Tracker Hacking More Accessible HackadayOver the last several months, [Aaron Christophel] has been working on creating a custom firmware for cheap fitness trackers. His current target is the “D6 … … Continue Reading »
Posted on Thursday March 21, 2019Library Makes ESP Over The Air Updates Easy HackadayPotentially, one of the great things about having a device connected to the network is that you can update it remotely. However, how do you make that happen? … Continue Reading »
Posted on Thursday January 18, 2018Over The Air Updates For Your Arduino HackadayAn Arduino and a data radio can make a great remote sensor node. Often in such situations, the hardware ends up installed somewhere hard to get to – be it in a … … Continue Reading »
arduino ota Social
Originally posted 2016-05-07 04:41:33.