Sensorclouds
OTA Updates

Device OTA Protocol

What your firmware receives for an OTA update, and the progress messages it must send back

This page is for firmware developers. It describes the MQTT messages a device exchanges with Sensorclouds during an OTA campaign.

Overview

Sensorclouds ──/cmd──▶ device   "ota:update" (where to download, checksum, size)
device ──HTTPS GET──▶ downloadUrl
device ──/ack──▶ Sensorclouds   "downloading" (with progress) … "installing" … "ok" / "failed"

1. The update command

The device receives this on its /cmd topic:

{
  "commandId": "c41e…",
  "command": "ota:update",
  "parameters": {
    "firmwareId": "f0a9…",
    "version": "2.1.0",
    "downloadUrl": "https://<host>/api/ota/download/<token>",
    "checksum": "9b74c9897bac770ffc029102a200c5de…",
    "fileSize": 1048576,
    "timeoutSeconds": 1800,
    "campaignId": "7c2d…"
  },
  "timestamp": "2026-09-18T07:30:00.000Z"
}
ParameterMeaning
versionThe firmware version being installed
downloadUrlAn HTTPS link to the file. Single-use and time-limited, and needs no login
checksumSHA-256 of the file (hex). Verify it before installing
fileSizeSize in bytes
timeoutSecondsHow long the platform waits before marking this device failed
campaignIdInclude it in every progress report

2. Progress reports

Publish these to the /ack topic. Always include commandId, command: "ota:update", and campaignId.

StageMessage
Downloading{"commandId":"c41e…","command":"ota:update","campaignId":"7c2d…","status":"downloading","progress":45}
Installing{"commandId":"c41e…","command":"ota:update","campaignId":"7c2d…","status":"installing"}
Success{"commandId":"c41e…","command":"ota:update","campaignId":"7c2d…","status":"ok","firmwareVersion":"2.1.0"}
Failure{"commandId":"c41e…","command":"ota:update","campaignId":"7c2d…","status":"failed","error":"checksum mismatch"}
statusCampaign shows
downloading (with progress 0–100)DOWNLOADING and a progress bar
installingINSTALLING
okSUCCESS
failed or errorFAILED, with your error text

Send downloading every 10–20% rather than for every chunk. It's enough for the progress bar and keeps traffic low.

Receive ota:update and check that version is newer than what's running.

Report downloading at progress: 0.

Download downloadUrl over HTTPS, reporting progress as you go.

Compute the SHA-256 and compare it with checksum. If they differ, report failed.

Report installing, then write the image.

Reboot into the new firmware.

After reconnecting, report ok with firmwareVersion.

If the device never reports ok or failed, it's marked failed after timeoutSeconds. Report failed with a clear error whenever you can. It makes the campaign page much more useful.

Download links are single-use. A retry from the campaign sends a new ota:update command with a fresh link.

Rollback

The platform may also send an ota:rollback command. Acknowledge it on /ack with command: "ota:rollback" in the same way.

Next Steps

On this page