Over The Air (OTA) Upload
OTA (Over the Air) upload is the process of uploading your program to an ESP module using a Wifi connection rather than the usual USB connection. This method of uploading is useful if you cannot physically access your ESP module. The main documentation on using OTA is available here. Additional documentation on the basic Arduino WiFi functions is available
This is an advanced project and requires many skills, however, the instructions in this tutorial should be simple enough to quickly get you going.
Parts needed:
The Wemos D1 mini development board has a ESP8266-12 and a USB-to serial adapter built-in. So this is much easier to work with than just the barebone ESP8266. With this you can directly plug in a micro USB cable to program the on-board ESP8266-12. | ||
1 | To program the ESP8266 WiFi module, you need to add the ESP8266 Board definition to the Arduino IDE program. You only need to do this once so if it has already been done then skip this step and go to step 2.
| |
| ||
2 | If you are using the Wemos D1 mini development board then just plug in the micro USB cable between the D1 mini board and your computer, and continue with step 4 below.
If you are using the CP2102 USB-to-serial adapter to program the ESP8266-12 or ESP8266-01 WiFi module, then click here for instructions on how to make the connections. Come back here and continue to step 3 after you have made the connections. | |
3 | Create a new sketch and type in this program.
There are three lines flagged with **** that are needed for OTA to work Replace "your ssid" and "your password" with the ssid and password of the WiFi network that you want to connect to. Note: You can only connect to a 2.4 GHz wifi signal. A 5 GHz wifi signal will not work. Also you cannot use a "Guest" account that requires a response. |
|
4 | Uploading the initial program to the ESP8266 WiFi module.
| |
5 | Running the program.
After the program is uploaded successfully, it will immediately run and you should see something like this if it connects to the wifi successfully. Note the IP address displayed. If there are some garbage characters at the beginning of the printout then just ignore them. If the program doesn't automatically run, then press the reset button on the Wemos board. If it cannot connect to the wifi for about 30 seconds, then make sure that you have entered your ssid and password correctly in the code and upload the program again. Note: You can only connect to a 2.4 GHz wifi signal. A 5 GHz wifi signal will not work. Also you cannot use a "Guest" account that requires a response. | |
6 | Disconnect your ESP module from your computer and connect it to a different power source, either to a power bank or a USB power adaptor. Your ESP module will run the program and should connect to your wifi just like before. | |
7 | To update a new firmware, browse to this webserver's IP address /update. e.g.
192.168.1.114/update You will see this updater webpage. Click on the Choose File button to select the .bin file that you want to upload. e.g. BasicWebServer.ino.bin This bin file should be located in Users/<account>/AppData/Local/Temp/arduino_build_xxxxxx Then click the Update Firmware button. | |
8 | In order for OTA to work in your program you need to include these three lines of OTA code in your program.
|
|