OTA Firmware Updates

HAMTECH OTA PLATFORM

Update your devices over the air. No cables. No site visits.

Upload a new firmware file once, and every ESP32 you have in the field downloads and installs it by itself — checked, verified and reported back to your dashboard.

7-day free trial·M-Pesa billing·ESP32 · ESP32-S3 · custom boards
ota.hamtechtechnologies.com / devices
DEVICEFIRMWARESTATUSLAST SEEN
pump-ctrl-01v1.2.0Up to date12 s ago
incubator-02v1.1.4 → v1.2.0
Updatingnow
vending-07v1.2.0Up to date48 s ago
gate-sensor-03v1.1.4Offline2 h ago
Dashboard preview — example devices
// What is OTA?

Firmware updates without touching the device

OTA (over-the-air) means your device downloads new firmware through its own internet connection instead of being plugged into a laptop. You fix a bug or add a feature in the office, and the device in a field, a farm or a vending machine updates itself.

WITHOUT OTA

Every update is a site visit

  • Travel to each device with a laptop and USB cable
  • Open enclosures and interrupt the machine
  • Devices end up on different, unknown versions
  • A bug found after installation stays in the field for weeks
WITH HAMTECH OTA

Every update is one upload

  • Upload a .bin file once from your desk
  • Devices update themselves within minutes
  • See every device’s version and last check-in in one list
  • Ship fixes the same day you write them
// How it works

How an update reaches a device

Your device does all the asking — the platform never needs to reach into your network, so it works behind any router, SIM or firewall.

01

You upload

Compile your sketch, upload the .bin in the dashboard and set its version, e.g. 1.2.0.

02

Device checks in

Every minute the device calls check.php with its name, its API key and the version it is running.

03

Platform compares

If a newer version is active for that device type, the reply includes the download link, the file size and an MD5 checksum.

04

Download & verify

The device writes the file to its spare flash partition and checks the MD5. A broken download is rejected.

05

Reboot & report

It restarts into the new firmware and its next ping.php shows the new version on your dashboard.

// Features

Everything you need to run a fleet

01

Automatic updates

Devices check on their own schedule. Upload once and the platform handles delivery to every device assigned to that firmware.

02

Secure delivery

Each device has its own API key, traffic runs over HTTPS and every file carries an MD5 checksum the device verifies before installing.

03

Live device status

See which devices are online, what version each one runs and when it last checked in — all in one dashboard.

04

Version control

Keep every firmware release on file and choose which one is active. Devices always receive the newest active release for their device type.

05

Simple REST API

Two plain HTTPS endpoints — ping.php and check.php. Add them to an existing sketch in a few minutes.

06

M-Pesa payments

Pay for your subscription with M-Pesa STK push. Pick the plan that matches the number of devices you run.

// Get started

From sign-up to first update

Most people push their first update in under 10 minutes.

STEP 1

Create an account

Sign up and start your 7-day free trial of the dashboard.

STEP 2

Register the device

Add the device’s hostname. You get its API key, which looks like DEV_a1B2c3D4e5.

STEP 3

Flash the sketch once

Put the example below into your project, fill in Wi-Fi, hostname and API key, and flash it by USB one last time.

STEP 4

Upload new firmware

Raise FW_VERSION, export the compiled binary and upload it. The device installs it on its next check.

// Code example

Complete ESP32 sketch

Copy this into the Arduino IDE (ESP32 board package), install ArduinoJson from the Library Manager, and fill in the four settings at the top.

ota_example.ino
// HamTech OTA — ESP32 example (Arduino core for ESP32)
// Libraries: WiFi, HTTPClient, Update (built in) + ArduinoJson by Benoit Blanchon (v7)

#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
#include <Update.h>
#include <ArduinoJson.h>

// ---- Your settings -------------------------------------------------
const char* WIFI_SSID       = "YOUR_WIFI_SSID";
const char* WIFI_PASS       = "YOUR_WIFI_PASSWORD";
const char* DEVICE_HOSTNAME = "YOUR_DEVICE_HOSTNAME"; // exactly as registered in the dashboard (no spaces)
const char* API_KEY         = "DEV_xxxxxxxxxx";       // the device's API key from the dashboard
const char* FW_VERSION      = "1.0.0";                // change this every time you build a new release

const char* OTA_SERVER = "https://ota.hamtechtechnologies.com";
const unsigned long CHECK_INTERVAL_MS = 60000;      // ask for updates once a minute
// ---------------------------------------------------------------------

WiFiClientSecure tls;
unsigned long lastCheck = 0;

void pingPlatform();
void checkForUpdate();
void installFirmware(const char* url, const char* md5);

void setup() {
  Serial.begin(115200);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print('.'); }
  Serial.printf("\nConnected. Running firmware %s\n", FW_VERSION);

  tls.setInsecure();   // quick start. For production, pin the server certificate with tls.setCACert(...)

  pingPlatform();      // report "online" + current version
  checkForUpdate();    // install a pending update straight after boot
}

void loop() {
  if (millis() - lastCheck >= CHECK_INTERVAL_MS) {
    lastCheck = millis();
    pingPlatform();
    checkForUpdate();
  }
  // ... your application code runs here ...
}

// Tells the dashboard this device is online and which version it runs.
void pingPlatform() {
  HTTPClient http;
  String url = String(OTA_SERVER) + "/api/ping.php?hostname=" + DEVICE_HOSTNAME + "&version=" + FW_VERSION;
  http.begin(tls, url);
  http.addHeader("X-API-Key", API_KEY);
  int code = http.GET();
  Serial.printf("Ping: HTTP %d\n", code);
  http.end();
}

// Asks the platform if newer firmware is assigned to this device.
// Reply: {"update_available":true,"version":"1.1.0","url":"https://...bin","md5":"...","size":123456}
void checkForUpdate() {
  HTTPClient http;
  String url = String(OTA_SERVER) + "/api/check.php?device=" + DEVICE_HOSTNAME +
               "&version=" + FW_VERSION + "&mac=" + WiFi.macAddress();
  http.begin(tls, url);
  http.addHeader("X-API-Key", API_KEY);
  int code = http.GET();
  if (code != 200) {
    Serial.printf("Update check failed: HTTP %d %s\n", code, http.getString().c_str());
    http.end();
    return;
  }

  JsonDocument doc;
  DeserializationError err = deserializeJson(doc, http.getString());
  http.end();
  if (err) { Serial.println("Could not read server reply"); return; }

  if (!doc["update_available"].as<bool>()) {
    Serial.println("Firmware is up to date");
    return;
  }
  Serial.printf("New firmware %s available (running %s)\n", doc["version"].as<const char*>(), FW_VERSION);
  installFirmware(doc["url"], doc["md5"]);
}

// Downloads the .bin, checks its MD5 and installs it to the spare partition.
// If anything fails, the current firmware simply keeps running.
void installFirmware(const char* url, const char* md5) {
  HTTPClient http;
  http.begin(tls, url);
  int code = http.GET();
  if (code != 200) { Serial.printf("Download failed: HTTP %d\n", code); http.end(); return; }

  int size = http.getSize();
  if (size <= 0 || !Update.begin(size)) {
    Serial.println("Not enough flash space for this firmware");
    http.end();
    return;
  }
  if (md5 && strlen(md5) == 32) Update.setMD5(md5);   // reject corrupted downloads

  size_t written = Update.writeStream(*http.getStreamPtr());
  http.end();

  if (written != (size_t)size || !Update.end() || !Update.isFinished()) {
    Serial.printf("Update failed: %s\n", Update.errorString());
    return;
  }
  Serial.println("Update installed. Rebooting into the new firmware...");
  delay(500);
  ESP.restart();
}
Exporting the .bin: in the Arduino IDE use Sketch → Export Compiled Binary, then upload the .ino.bin file (not the bootloader or partitions file).
Always raise the version: the platform only offers firmware with a higher version number than the device’s FW_VERSION, so give every release a bigger number (1.2.0 → 1.2.1).
Partition scheme: choose a scheme with OTA space (e.g. Default 4MB with spiffs). “Huge APP (no OTA)” has no room for updates.
// Safety

An update can’t brick your device

The ESP32 keeps two app partitions. New firmware is written to the spare one while the old firmware keeps running, and the switch only happens after the whole file has arrived and its checksum matches. Lose power or Wi-Fi halfway, and the device just boots the version it already had.

  • Per-device API keys — a leaked key only exposes one device
  • HTTPS for every check-in and download
  • MD5 checksum verified before installing
  • Old firmware keeps running if an update fails
  • Rate-limited API protects the platform from runaway devices
  • Roll back fast: re-release a known-good build under a new version number
// Supported hardware

Works with the boards you already use

Anything that runs the Arduino core for ESP32 and has Wi-Fi works with the example above.

ESP32 DevKitESP32-S3ESP32-CAMESP32 LoRa (TTGO)Custom ESP32-WROOM boardsHamtech control boards

Using an ESP8266? The same API works — use the ESP8266 ESP8266httpUpdate library instead of Update. Contact us and we’ll send you a matching example.

// FAQ

Questions people ask

Does my device need to be reachable from the internet?

No. The device always starts the connection, so it works on home Wi-Fi, office networks and mobile hotspots without port forwarding or a fixed IP.

How often does a device check for updates?

As often as you set CHECK_INTERVAL_MS in the sketch. Once a minute is a good default; battery devices can check less often, for example once an hour.

What happens if the power fails during an update?

Nothing is lost. The new firmware is written to a spare partition and only used once it is complete and its checksum matches, so the device restarts on its old firmware and tries again on its next check.

Can I go back to an older version?

Yes. Devices only move to higher version numbers, so rebuild the older, known-good code with a new number (for example 1.2.1 after a bad 1.2.0) and upload it. Every device installs it on its next check.

How do I pay?

Subscriptions are paid with M-Pesa STK push from inside the dashboard. You can try everything free for 7 days first.

Can Hamtech build the device firmware for me?

Yes — we design boards and write firmware too. Send us your project on WhatsApp and we’ll set up OTA for you.

// Start updating wirelessly

Push your first update today

Create a free account, register a device and send it new firmware in minutes.

info@hamtechtechnologies.com
+254702125796
+254702125796
WhatsApp
Phone
Email