OTA Updates on ESP Devices
by RoboCircuits in Circuits > Arduino
1285 Views, 5 Favorites, 0 Comments
OTA Updates on ESP Devices
If you are an electronics enthusiast and know about IoT you must have installed any home automation project in your house. But once installed it's tough to change the code dumped on that device.
Even if there is an issue with the board from the software part you have to take it out to reprogram it.
What if there is a way to change code without taking the system out of the switchboard. And you could update codes inside hundreds of devices easily without touching them.
In this article, we are going to solve that. You can watch my video on the same by clicking here
Before continuing make sure to subscribe to the channel by clicking here and press the bell icon to get notified about videos like this.
Theory
We are
going to learn about OTA updates or "Over The Air" Updates. We are going to implement OTA updates in esp8266/esp32 so that you can update the program directly from the internet into the device.
For this process we need
1. esp8266 or esp32
2. own website to upload the code
Process of OTA updates are really easy.
1. We will upload the compiled code on our website.
2. Then we will use "HTTP update" library to download the code into our esp
3. And esp will install the new code itself
But we will add one more step to control the version number of the code we are running
1. In each code we will define the version number
2. Then we will create a JSON file on our website which will consist of the latest version and link to that version
{
“ver” : 0.00,
“link” : “link-to-that-code”
}
3. The esp will check that file multiple times a day. If the version on the website is greater than the current version it will download the code. Else it will do nothing.
Designing PCB for Device
For performing this we need a Home Automation Device
on which we will implement these updates.
I designed a PCB using a NodeMCU and 4 relays. This PCB includes SMD components and an integrated power supply. As we are dealing with AC and DC at the same time along with SMD components so Altium designer was the best choice for designing this PCB. Because Altium provides best in class features like
1. Advanced routing
2. Latest Design Rule Check
3. 3D visualization
4. Industrial level designing tools
Another good service from Altium is Altium 365 which allows you to collaborate your project with your team members over the cloud.
Get 30 days free trial Altium Designer - https://www.altium.com/yt/robocircuits
Ordering PCB and Assembling
Let’s order
the PCB from JLCPCB.com. go to fabrication and get PCB fabrication files and click order at JLCPCB.
JLCPCB order page will open.
Verify dimensions and select no of PCBs. Select surface finish and click add to cart. Now let's check out, fill in your details, and pay using PayPal.
$2 for 1-4 Layer PCBs, sign up to get $18 new user coupons: https://jlcpcb.com/IYB
With over 10 years of experience in PCB manufacturing, JLCPCB has more than 200,000 customers, with over 8,000 online orders of PCB prototyping and small quantity PCB production per day.
Once we get the PCBs we have to assemble them. First go with SMD components by soldering them with a thin soldering iron.
Then all the THT components.
First Code
Go to your website file manager... you will find it on your hosting space.
Then in the public HTML folder make a Firmware.json file with the following content
{
“ver” : 0.00,
“link” : “link-to-that-code”
}
then we have to create our first code
Downloads
Second Code
Now we will do minor changes in the code to blink the inbuild led on the board.
and change the version number to 0.10
now we will compile its bin file and upload it to the same folder where firmware.json is saved.
now we will update the firmware.json as
{ “ver” : 0.10, “link” : “link-to-that-code” }
and give bin file link in the link section
when we will save changes esp will download the code.
Downloads
Installing Board
Finally, we will install our board with devices and give OTA updates through the internet and our touch switches will start to work.
to get this code you need to install the last code on your device it will automatically download the code.
This is how OTA works on esp.
Thanks for reading, do follow on Instructables and youtube.