Introduction: Remote ESP32 Firmware Upate (OTA)

In this instructable we will demonstrate how to remotely update a ESP32 firmware.

  • No physical connection (means that no need to connect the ESP32 to the computer to upload the firmware).
  • No need to be in the same network (i.e. your ESP32 at your home and you at work)

Supplies

You will need:

  • An ESP32 compatible
  • An Google Firebase account ( see this instructable https://www.instructables.com/Google-Firebase-Account-Setting-for-IOT/ )

Step 1: Create a Google Firebase Storage

Create a Google Firebase console as link included on supplies


Step 2: Upload the Code to ESP32

To implement this OTA, the first firmware (code attached) must be uploaded by cable. So, connect your ESP32 to your computer and upload it.

The following code lines must be modified for you account and project details:


const char* ssid = "YourWifiNetworkName";const char* password = "YourWifiPassword";#define API_KEY "GoogleFirebaseAPIKEY"               // Firebase: Define the API Key#define USER_EMAIL "GoogleFirebaseUserEmail"         // Firebase: Define the user Email#define USER_PASSWORD "GoogleFirebaseUserPassword"   // Firebase: Define password#define STORAGE_BUCKET_ID "GoogleFirebaseBucketID"   // Firebase: Define the Firebase storage bucket ID e.g bucket-name.appspot.com#define FIRMWARE_PATH "test/firmware.bin"            // Firebase: Define the firmware path on Firebase


Step 3: Ok, and Now?

After successfully uploading the code to your ESP32 and restarting it, it will connect to your Wifi network and will search for the firmware file on the Firebase Storage.

If no file is present in the storage, the code will move on.

IP address: 10.92.61.230Firebase Client v4.0.0  Token info: type = id token, status = on requestToken info: type = id token, status = readyChecking for new firmware update available...New firmware update not available or download failed, Not Found.Not Found.


If a file is found, the ESP32 will download it, delete it after download and restart the device.

WiFi connectedIP address: 10.92.61.230Firebase Client v4.0.0Token info: type = id token, status = on requestToken info: type = id token, status = readyChecking for new firmware update available...New update foundDownloading firmware test/firmware.bin (1048000 bytes)Downloaded 0%Downloaded 2%Downloaded 4%Downloaded 6%Downloaded 8%Downloaded 10%...Downloaded 90%Downloaded 92%Downloaded 94%Downloaded 96%Downloaded 98%Downloaded 100%Donwload firmware completed.Delete file... okRestarting...

At this point, the new firmware will run at your device.

Step 4: Import a New Firmware to the Storage

To provide a new firmware for your device, you shall upload to the Firebase Storage the binary file created by your compiler, usually it is named "firmware.bin".

If your are using Visual Studio with PlataformIO, the binary file can be found on the path similar to:

...\PlatformIO\Projects\WebUpdate\.pio\build\wemos_d1_mini32\firmware.bin


You shall have a storage like the picture.