> For the complete documentation index, see [llms.txt](https://docs.consentiumiot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.consentiumiot.com/readme/steps-for-using-consentium-iots-ota-service.md).

# Steps for Using Consentium IoT's OTA Service

## Step 1: Prepare the OTA-Capable Sketch

1. **Create an OTA-Capable Sketch**: Write an Arduino sketch for your **ESP32**, **ESP8266**, or **Raspberry Pi Pico W** that includes OTA functionality.
2. **Set Firmware Version**: Ensure the `FIRMWARE_VERSION` variable is set to `"0.0"`. This indicates the initial firmware version. You can update this to any version number as needed, but `0.0` is used here for demonstration.

   ```cpp
   #define FIRMWARE_VERSION "0.0"  // Initial firmware version
   ```

## Step 2: Upload the Sketch to the IoT Board

1. **Connect the Board**: Connect your IoT board to your development machine using a USB cable.
2. **Upload the Sketch**: Upload the OTA-capable sketch to the board using the Arduino IDE.

## Step 3: Access the Consentium IoT Cloud

1. **Log In**: Log into the **Consentium IoT Cloud**.
2. **Navigate to Device OTA**: Go to the **Device OTA** page. You should see the OTA-capable device listed with its current firmware version displayed.

<figure><img src="/files/Wwp77GYQ4cNbvg46SpS5" alt=""><figcaption></figcaption></figure>

## Step 4: Prepare the Updated Firmware

1. **Disconnect the Board**: Ensure the IoT board is no longer physically connected to the development machine.
2. **Update the Sketch**: Make any desired changes to your code and update the `FIRMWARE_VERSION` variable to `"0.1"` (or any new version number).

   ```cpp
   #define FIRMWARE_VERSION "0.1"  // Updated firmware version
   ```
3. **Export the Compiled Binary**: In the Arduino IDE, go to the **Sketch** menu and click on **Export Compiled Binary**. This action generates a **.bin** file for the updated firmware, which will be saved in a folder under your project directory.

<figure><img src="/files/WGn7zG34SlFOuoXyfgXY" alt="" width="259"><figcaption></figcaption></figure>

## Step 5: Upload the New Firmware

1. **Upload the .bin File**: Return to the **Device OTA** page in the Consentium IoT Cloud.
2. **Select and Upload**: Choose the generated **.bin** file and upload it to the appropriate board.

## Step 6: Verify the Update

1. **Check Firmware Versions**: After the update is pushed, verify that the **Current** and **Board Firmware Versions** are the same to confirm the update was successful.
