Arduino Library (OtTelemetry)
OtTelemetry is Ot's official Arduino library for ESP32 and ESP8266 boards. It handles WiFi, the MQTT connection, JSON payload building, and reconnects — your sketch just adds fields and sends.
Installation
Download OtTelemetry.zip from your Devices page (step 2 of device registration), then in the Arduino IDE choose Sketch → Include Library → Add .ZIP Library… and select the file.
One dependency
PubSubClient from the Arduino Library Manager — it is the MQTT client OtTelemetry uses underneath.A complete sketch
#include <OtTelemetry.h>
#include "secrets.h"
OtTelemetry ot(OT_PROJECT_ID, OT_DEVICE_TOKEN);
void setup() {
Serial.begin(115200);
// WiFi + MQTT in one call. Default broker port is 1883.
ot.begin(OT_WIFI_SSID, OT_WIFI_PASS, "broker.hivemq.com");
}
void loop() {
ot.loop(); // keeps WiFi and MQTT alive; call every pass
if (ot.connected()) {
// Batch several fields into one message:
ot.beginPayload();
ot.addField("temp", readTemperature());
ot.addField("moisture", readMoisture());
ot.sendPayload();
// Or send a single field:
// ot.send("battery", 92.5);
}
delay(10000);
}Every field name you send (temp, moisture, ph, anything) becomes a plottable field in your dashboard widgets. There is no schema to declare — the field exists as soon as you send it.
API reference
How it travels
The library publishes JSON to the MQTT topic ot/projects/{projectId}/data, including your device token in the payload. The Ot bridge subscribes to these topics, verifies the token, and writes the reading into your account's storage. Your device never holds database credentials.
Security model