The Things Network (TTN) Integration
Connect your TTN v3 application to DataKubo and start ingesting device data automatically.
Prerequisites
- A DataKubo account with an API key (sign up)
- A TTN v3 application with at least one registered device
- A payload decoder configured on your TTN application
Step 1: Add a webhook
In the TTN Console:
- Navigate to Applications → Your Application → Integrations → Webhooks
- Click Add webhook and select Custom webhook
- Configure:
| Field | Value |
|---|---|
| Webhook ID | datakubo |
| Webhook format | JSON |
| Base URL | https://api.datakubo.com/api/v1/ingest/water-consumption |
| Additional headers | X-API-Key: your_api_key |
- Enable Uplink message under event types
- Click Create webhook
Step 2: Configure your payload decoder
DataKubo reads the decoder's output, not the raw bytes. Your TTN application needs a payload formatter that returns the meter's total reading in one of the consumption fields below. Battery and alarm fields are optional.
// Example: meter that sends the reading in liters (4 bytes) and battery in tenths of a volt (1 byte)
function decodeUplink(input) {
var b = input.bytes;
// ">>> 0" keeps the value positive when the first byte is 0x80 or higher
var liters = ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]) >>> 0;
return {
data: {
cumulativeFlowM3: liters / 1000,
battery: b[4] / 10
}
};
}
Every meter model encodes its data differently, so use the formatter from your meter manufacturer (or the TTN Device Repository) and make sure its output uses the field names below.
TTN messages without a decoded_payload are acknowledged (HTTP 200) but no data is stored. Always configure a payload decoder.
Step 3: Verify data flow
After the next device uplink:
- Check TTN Console → Webhooks → datakubo for delivery status
- Check DataKubo admin → Devices for the new device and readings
Field mapping reference
| TTN Decoded Field | DataKubo Field | Notes |
|---|---|---|
cumulativeFlowM3 | consumption_m3 | Preferred — cubic meters |
water | consumption_m3 | B-Meters alternative |
cumulativeFlow | consumption_m3 | Liters — auto-converted to m³ |
battery / bateria | battery_level | Voltage |
battery_status | battery_level | "OK" → 3.6V, anything else → 2.8V |
alarm_burst, alarm_leakage, alarm_overflow, alarm_reverse_flow, alarm_low_battery, alarm_wrong_installation | Hardware alarms | true/false only — any other value rejects the uplink. See Hardware alarms |
If several consumption or battery fields are present, the first one in the table wins. If none of the consumption fields is present, the reading is stored as 0 m³.
Next steps
- Webhook Integration — full payload format reference
- API Reference — query ingested data via API