Home / Tutorials / ESP32 Tutorial / Update ESP32 Firmware through External Web Server
ESP32 Update Firmware through Web Server

Update ESP32 Firmware through External Web Server

Launching a project into production doesn’t mean it’s 100% finished --- this is why software/firmware updates exist. And your users are not programmers so you want the update process as user-friendly as possible. Thankfully, the ESP32 allows you to update its compiled code, called firmware, to be updated over the air (OTA).

There are a number of tutorials on doing OTA updates on the ESP32 but I haven’t seen one where you can update the firmware from an external website. Like, store the binary file in www.example.com/latest/ and have your ESP32 fetch that file. I believe this approach is easier for IoT projects that have already been released to users -- just send them the firmware via the internet every time there’s an update.

The concept is fairly simple: using the right libraries, create a GET request for a certain file in a website. If the file exists, then create a stream to download the file. We expect the file to be large and won’t fit inside a standard string, so we need to incrementally write it to the ESP32. Once the firmware has been written, restart the ESP32 to load the newly written binary.ESP32 Update Firmware through Web Server

First, make sure your ESP32 supports OTA. The only thing to check is the partition scheme in Tools:

Don't Select No OTA for the partition scheme!

Selecting “No OTA” will disable over-the-air updates so don’t do that. Here I’m just using the default partition scheme.

Then, create the sketch that you want as an update. For example, here's what I want to change my ESP32 code into:

Now, this sketch entirely removes the OTA function of the previous sketch. You wouldn't that if you want to continue doing OTAs. I'm just using this example here for simplicity.

Next, create a binary file for that sketch above. Just go to Sketch > Export compiled Binary (or CTRL+ALT+S on windows) to do that:

A .bin file should now be present with your .ino file.

Next, upload this .bin file into your external web server. For example, our website is server.com. We upload the .bin file to the root folder of the website. Hence, the .bin file is accessible at http://www.server.com/hello_world_esp32.ino.d32.bin

Next, we create another sketch for getting the .bin file from the webserver. The first step is to establish a WiFi connection:

Then connect to the host which is the URL of the .bin file above. And then use an HTTP GET request to check if the file is indeed there.

If the file is present, the value of the resp variable will be 200 which is the HTTP code for ‘OK’. If this is the case then we can start streaming the file.

Here we use a function updateFirmware() which is the one responsible for writing the stream to the ESP32. It uses the Update library, included in the ESP32 for Arduino core.

You can grab the full sketch on this repository. You can just easily recycle this code from line 39 up to the end of setup() and also the updateFirmware() function to use in your own project. Just specify your own URL for the location of the .bin file (defined as HOST in the code) and of course your own WiFi credentials.

Once this sketch is uploaded, open serial monitor to view this:

As you can see, Hello World is now on the bottom of the monitor, which was the output of the .bin file on the webserver.

Again, just be mindful that your new firmware should still have the capabilities of doing OTA. Otherwise, you can't do OTAs anymore!

I hope you find this tutorial helpful. For any concerns, just drop a comment below or send a message via or FB/IG channels.

Check Also

HMC5883L Breakout Board

ESP32 Magnetometer using HMC5883L

For this article, I will show you how to use an ESP32 microcontroller as a …


  1. Hello, Your tutorial is great.
    Unfortunately I got the Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled
    I have posted the details on Git. Have it ever happened to you?

  2. Hello. Nice and helpful tutorial. I was wondering what kind of external web server you used and how I can serve the .bin file from the server and make it accessible over the internet to esp32?
    Do you have any examples/tutorial on how to set that kind of server?
    I am quite new to software world so any help will be useful.'

  3. Hello, nice and helpful tutorial. I was wondering what kind of web server do you use and how it can serve the .bin file and make it accessible to esp32 for the update?
    Do you know any examples/ tutorials on how to set up a server like that?
    I am quite new to the software world , so any help will be welcome.

    • Hi,

      I am using a hosted file server. It's paid so it doesn't take much effort to set up. Basically, it's an Apache server with CPanel. Check out those paid domain services with hosting.

Leave a Reply

Your email address will not be published. Required fields are marked *