A Step-by-Step Guide to ESP32 OTA Updates with OTA Drive
Keeping your IoT devices up-to-date is crucial for performance and security. Over-the-Air (OTA) updates offer a seamless way to deploy firmware updates to your ESP32 devices without physical access. In this guide, we will explore how to use the OTA Drive platform to perform OTA updates on ESP32, ensuring your devices stay current with minimal effort.
Introduction to OTA Updates
Over-the-Air (OTA) updates allow you to remotely update the firmware of your IoT devices. This is especially useful for devices like the ESP32, which are often deployed in inaccessible locations. OTA updates eliminate the need for physical access, making the process efficient and convenient.
Setting Up Your ESP32 for OTA
Before we can perform OTA updates, we need to set up our ESP32 using the ESP-IDF platform in VSCode. Here’s what you need to do:
Install VSCode: If you haven't already, download and install Visual Studio Code.
Install ESP-IDF Extension: In VSCode, go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window. Search for "ESP-IDF" and install the official extension by Espressif.
Set Up ESP-IDF Tools: Follow the setup instructions provided by the ESP-IDF extension to install the necessary tools. This typically involves installing Python, Git, and the ESP-IDF itself.
Clone ESP-IDF Repository: Open a terminal in VSCode and clone the ESP-IDF repository by running:
git clone https://github.com/circuit-tales/ESP32_simple_fota_OTA_drive
Connect Your ESP32: Connect your ESP32 to your computer using a USB cable. Ensure the correct serial port is selected in the ESP-IDF settings in VSCode.
Overview of OTA Drive Platform
OTA Drive is a powerful platform designed to facilitate OTA updates for IoT devices. It offers a user-friendly interface, secure firmware hosting, and comprehensive update management features. With OTA Drive, you can easily manage and deploy firmware updates to your ESP32 devices.
Configuring OTA Drive
Sign Up: Go to the OTA Drive website and create an account.
Add Product : Once logged in, Go to Product tab and add product as ESP32 devices.
Provide a name and description for your Product. Optionally you can add Image also
you can say it's nice feature for Identification.
Click on folder Icon You will see this screen
Open SDK Configuration:
In VSCode, open the SDK configuration settings and ensure the necessary options are correctly set.
Navigate through the configuration menu to make sure all required settings for OTA updates are enabled.
Edit main.c File:
Open
main.c
and comment out the highlighted lines. This will temporarily disable parts of your code for the initial setup.Update your WiFi credentials by replacing
your_SSID
andyour_PASSWORD
with your actual network details.
Copy API Key:
From the OTA Drive dashboard, copy your unique API key.
Paste this API key into your
main.c
file where specified. Optionally, you can also update theapp_version
for easier tracking.
Build the Project:
- At the bottom of the VSCode window, click on the 'Build' button to compile your project. Note that the initial build may take some time.
Flash the Firmware:
- After successful build you will see below log in output tab
- After a successful build, select 'UART' to prepare for flashing the firmware.
- Ensure your ESP32 is connected to the correct COM port, then click 'Flash'.
If you see a 'Connecting' message, press and hold the boot button on your ESP32 for 3 seconds and then release it.
Verify the Flashing Process:
- Upon successful flashing, you should see a confirmation message in the output tab of VSCode.
- Check your ESP32 board. At this stage, only the red LED should be glowing.
Verify Device on OTA Drive:
Reload the OTA Drive dashboard page. You should now see your ESP32 device listed.
Go to the 'Devices' section, click on 'Verify', and confirm by clicking 'OK'.
Now uncomment previous lines
-
Also you can change version here for tracking
Now again build but dont flash this time we need to upload flash file to ota drive and over the air it will flash
Now open the project folder in the file explorer and go to the build folder. Select the highlighted .bin file.
- Now click on 'Upload Firmware' and upload this .bin file, or you can simply drag and drop it.
- After uploading the .bin file, select 'default' to see the updated version of our firmware. Then, click on 'upload'.
Now go to the 'Devices' section, click on the device folder icon, and you will see that FOTA has started.
FIRMWARE OVER THE AIR completed
You should now see the blue LED blinking.
If you found this guide helpful, please leave a comment below and share it with your peers. Follow my blog, Circuit Tales, for more insights and tutorials on embedded systems and IoT. Stay tuned for more!
\===========THE END==========
Subscribe to my newsletter
Read articles from Circuit Tales directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Circuit Tales
Circuit Tales
I am Ritesh K, a Software Embedded Engineer from India with a passion for developing IoT solutions and embedded systems. With extensive experience in C programming and a keen interest in the latest technology trends, I enjoy sharing my knowledge and insights through detailed tutorials and guides. Follow my blog, Circuit Tales, for regular updates on embedded systems, IoT, and programming tips.