# 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="https://1722507258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2tTe7YNQtbpNi3ve2r6s%2Fuploads%2F0TiaapjPJmTh1s6RZ2k0%2FScreenshot%202024-09-04%20at%201.49.29%E2%80%AFPM.png?alt=media&#x26;token=74765818-28a8-42c3-8f2a-b0f1ac31569c" 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="https://1722507258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2tTe7YNQtbpNi3ve2r6s%2Fuploads%2F4uPuJHgwUKKJrHHFyoM9%2FScreenshot%202024-09-04%20at%201.50.24%E2%80%AFPM.png?alt=media&#x26;token=3ec287d6-a63b-41dc-9645-f08d5b327d19" 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.
