Getting Started with ESP32 IDF and ByteBeam Part 2 - Over the air updates
Learn to provision over the air updates on your IoT devices using Bytebeam cloud
In Part 2 of this multi-part series of tutorials, we will demonstrate how to do OTA firmware updates using the Bytebeam cloud console. Earlier in Part1 of the series, we learnt about setting up bytebeam espressif SDK, concepts and guidelines of bytebeam cloud, device management, and data visualization using bytebeam dashboards.
In part 2 of this tutorial, we will learn about the following:
- How to create a new firmware and upload .bin to the bytebeam console?
- How do trigger an OTA update?
- How to monitor OTA progress in the bytebeam console?
Why having a provision of OTA is very important for an IoT project?
Recent advancements in cellular and wireless technologies have opened up opportunities for driving these technologies in distant geographical locations. According to the iot-analytics report, the number of devices is increasing exponentially at the rate of 18%. As the number of IoT devices is expanding day by day, regular monitoring and device management have also become critically important.
Remote devices need the provision of OTA updates and remote debugging to fix problems and roll out new features over the air.
Over-the-air updates help companies to install new software or patches to their devices without ever having to recall those devices. This decrease the chances of recalling devices due to software faliure.
Remote updates can help us in efficient device provisioning, and regular supervision of remote devices.
How ByteBeam helps with OTA provisioning and device provisioning?
This guide assumes that you have gone through Part 1 and had set up ESP32 with bytebeam cloud. In this guide, we will add the OTA handler on our ESP32 device and we will monitor the progress of OTA using bytebeam cloud. So let's get started.
Hardware Requirements
- ESP 32 dev module
Building new firmware for updates
- Navigate to examples -> basic_ota -> main -> app_main.c
- Add OTA action handler using bytebeam_add_action_handler function. It contains the following arguments
- bytebeam_client: structure containing host, port, certificates and device id information
- handle_ota: OTA handler function
- “update_firmware”: action name.
bytebeam_add_action_handler(&bytebeam_client, handle_ota, "update_firmware");
- Now make desired changes to app_main.c.
- Navigate back to the project directory and build the application using idf.py. This will make and compile your project.
Idf.py build
- You will see a build directory. Navigate to the build directory and there you will see a <your_project_name>.bin file. This is our new firmware which we have to update using OTA
Pushing file for OTA to ByteBeam cloud
- Now open bytebeam cloud. Navigate through the Device Management tab to see the last heartbeat, last action status and device shadow.
- Now click on the Firmware versions tab and upload a new firmware.
- Click on Upload New Firmware. Then on the next screen enter the new firmware version in Firmware Version Number edit text.
- Click on Browse to upload a new firmware file. and click on Create
- Now you can find a new firmware version in the list of available firmware.
- Now go to the Devices tab and check in the checkbox to select the device to be updated.
- Now click on the Update Firmware and then Select Firmware Version
- Here in Last Action, you can see the Action ID, Action Type as Update Firmware, and Action Status as Initialised.
- On the ESP32 you can see the action id, URL etc.
- You can regularly monitor the process of OTA using device logs and using bytebeam logs.
- After the OTA has been finished The Action Status will change to Complete.
- After the OTA process is completed ESP will get reset and you can see your updated firmware
Conclusion
I hope that this guide has been a helpful introduction to OTA updates with Bytebeam SDK for ESP-IDF and that it has provided you with the knowledge and tools to start developing your OTA-enabled IoT applications. In the next part, we will be discussing the concept of actions in bytebeam and we will learn about creating and handling custom actions. I hope you find this guide useful. We will come up with more interesting tutorials and maker content. Stay tuned.