Skip to main content

Telemetry Example

This example shows how a regular module publishes live telemetry values to the ArmorLink App through a Gateway.

Telemetry is useful for runtime values such as:

  • Battery voltage
  • Battery percentage
  • Temperature
  • Sensor values
  • System status

Telemetry is on-demand: calls can happen regularly, but ArmorLink only transmits when telemetry is enabled by the App.

Complete Example

#include <ArmorLink.h>

ArmorLinkModule module(
"Battery Module",
ArmorLinkModuleType::Generic
);

const int BATTERY_PIN = 34;
unsigned long lastTelemetryMs = 0;

float readBatteryVoltage()
{
int raw = analogRead(BATTERY_PIN);

// Example conversion only. Adjust this for your divider and ADC setup.
float adcVoltage = (raw / 4095.0f) * 3.3f;
return adcVoltage * 2.0f;
}

float calculateBatteryPercent(float voltage)
{
const float minVoltage = 3.3f;
const float maxVoltage = 4.2f;
float percent = (voltage - minVoltage) / (maxVoltage - minVoltage) * 100.0f;
return constrain(percent, 0.0f, 100.0f);
}

void setup()
{
Serial.begin(115200);
delay(500);

pinMode(BATTERY_PIN, INPUT);

ArmorLinkOptions options;
options.nodeName = "Battery Module";
options.enableGateway = false;
options.enableEspNow = true;
options.enableBle = false;
options.enableSerialLogging = true;
options.defaultLogTarget = "Chest";

ArmorLink.begin(module, options);

ArmorLink.info("Telemetry module started");
}

void loop()
{
ArmorLink.loop();

if (millis() - lastTelemetryMs >= 500) {
lastTelemetryMs = millis();
sendBatteryTelemetry();
}
}

void sendBatteryTelemetry()
{
float voltage = readBatteryVoltage();
float percent = calculateBatteryPercent(voltage);

ArmorLink.telemetryGroup("battery", "main")
.value("voltage", voltage)
.value("percent", percent)
.unit("V")
.send();
}

Why No delay?

Use a millis() interval instead of delay(...) so ArmorLink.loop() can keep processing packets, pairing, config requests and state sync.

defaultLogTarget

For regular modules, set defaultLogTarget to your Gateway name so telemetry and remote logs can be forwarded.

options.defaultLogTarget = "Chest";

Single-node Gateways do not need this because they forward telemetry directly over BLE.

Sending a Single Value

ArmorLink.sendTelemetry("environment", "temperature", 24.5f, "C");

Sending Multiple Values

ArmorLink.telemetryGroup("system", "status")
.value("uptimeSeconds", millis() / 1000.0f)
.value("freeHeap", ESP.getFreeHeap())
.send();

Telemetry vs Logging

Telemetry is structured runtime data. Logging is developer-focused diagnostic output.

ArmorLink.debug("Button pressed");
ArmorLink.warn("Battery voltage low");

Next Steps