Prepare your sketch for future updates over-the-air by just adding two lines of code.
This library is intended as starting point for getting familiar with OTA updates without a too steep learning curve. It intentionally offers a minimalistic interface and isn't bloated with lots of features and options. Just use it to bring up your device and start developing. Over time, when you're deeper into the topic, you likely want to use a more specific OTA mechanism and therefore a "bigger" OTA library with more possibilities. Search on GitHub for "ESP OTA" and you'll see what I mean...
Eventually, I'd highly recommend to have a look at the ESPP8266 documentation on OTA to learn about how to prepare the Arduino IDE for OTA updates.
Most minimalistic example. Can be uploaded via USB without modifications (except WiFi credentials), so that it is prepared for future OTA updates.
Same as BasicOTA
example, except that it introduces a nice trick to store the WiFi credentials outside the sketch,
so that they cannot get published by accident. The other examples also use this technique.
Adding a timeout to BasicOTA.begin() will automatically disable OTA after that time. This can be used as a security feature to prevent the device from unintended or rogue updates. OTA is enabled again after a reset.
When developing with your device OTA you usually don't have access to the serial console anymore. As an alternative, you can use a telnet connection to send the messages over network. Use e.g. PuTTY as a replacement for the Serial Monitor.
Note: This example uses the TelnetStream library. Since that is not (yet) available via Arduino IDE's Library Manager, please download it from there as ZIP file and install it manually.
This library has been heavily inspired by a Video
from Andreas Spiess.
His YouTube Channel is definitely worth having a closer look!