Welcome back to Tech Rover, today’s post is all about how to Load firmware to NodeMCU using OTA(Over the Air). This method will be beneficial when you are building some product using NodeMCU. It is useful for the updation of the firmware, to perform security patches or on the other hand, for a total firmware upgrade.
- How Secure it is?
- Safety Practices
- Loading the Basic OTA firmware
- Loading New Program Over The Air
- Loading Updates Over The Air
OTA is extremely handy to load firmware to your ESP module wireless. So let me walk you through following methods to achieve it:
- Arduino IDE
- Web Browser
- HTTP Server
Let’s take one step at a time, I will introduce you to Programming ESP module Over The Air using Arduino IDE in part 1. Later on, we will be discussing OTA using a web browser and HTTP server in the upcoming tutorials. Wait for it! In any case, Arduino IDE is used initially to set up OTA firmware over the serial port.
How Secure is it?
For you to update the firmware “Over The Air ” the module has to be connected to a network, right. It’s true that it creates chances of the module being hacked and packed with some other program. In order to cut down the possibility of being hacked, you can make use of various techniques such as: try protecting your uploads with the help of a password, selecting certain OTA port, hashing the password, etc.
Fortunately, various security practices are already built-in and do not call for any subsidiary coding on part of the developer. ArduinoOTA and espota.py make use of Digest-MD5 to verify the upload. By using MD5 checksum, the uprightness of transferred data is verified on the ESP side.
OTA process get hold of ESP’s resources and bandwidth during the upload. Then the module is restarted and a new sketch will be executed. Beware, this might affect the current functionality of the device during the process.
So let me warn you to decide on, how to put this equipment into a safe state before the updation begins. For instance, your module might be controlling a solenoid valve, and as OTA takes over the control, when the valve is in the open state and after the OTA finished it might be left open.
I will help you with some functions to handle your application as changes occur through OTA.
void onStart(OTA_CALLBACK(fn)); void onEnd(OTA_CALLBACK(fn)); void onProgress(OTA_CALLBACK_PROGRESS(fn)); void onError(OTA_CALLBACK_ERROR (fn));
Loading the Basic OTA firmware
To implement OTA, the ESP board support must be prefixed to Arduino IDE. Feel free to skip step 2, if you are familiar with adding ESP board support on your own. Those who need assistance to add ESP board support, follow my lead. 😊
Step 1 : Adding ESP Board Support
Copy the code that follows and paste the below URL in Preferences -> Additional Boards Manager URLs
Select Board Manager from tools->Board->Board Manager and search for ESP. Install the module.
Step 2 : Loading Basic OTA Firmware
- Select Basic OTA from Examples->Arduino OTA
- Configure your wifi credentials
- Load the program using serial port
Loading New Program Over The Air
- Open the Basic OTA code
- Add your new program along with Basic OTA code
- Go to tools->port
- You can see a new section named “network ports“
- Select your device listed under network ports
- Upload your code
Loading Updates Over The Air
- Make changes in the previous code
- Select the same network port previously selected
- Compile and upload your sketch
That’s all for this short update. Stay tuned for our next updates. Have a lovely weekend! Next tutorial you will get to explore on How to Load firmware Over the Air using Web Browser. I wish you good luck and happy coding. 😊
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?