Telemetry Protocol & Network API

Last updated: 2026-06-30

lan

Audience: developers & external integrators

This page documents the communication protocol between Canarin sensors and the Birdhouse ingestion server, as well as the REST API on the Plumage frontend side. For the user panel, see the user guide.

1. Ingestion endpoints (UDP)

The Birdhouse server listens for UDP packets sent by IoT sensors on two ports:

Production: ingest.canarin-sensors.com:59004 (UDP)

Dev / staging: ingest.dev.canarin-sensors.com:59005 (UDP)

UDP was chosen because of the nature of LPWAN/battery sensors: no TCP handshake, packets < 512 bytes, optional application-level ACK. Retransmissions are tolerated (server-side deduplication by composite key device_id + time_bucket + pollutant_id).

2. Packet format

All packets use a comma-separated ASCII text format:

{code},{native_id},{proj_id},{timestamp},{key1:value1},{key2:value2},...

Where:

  • code — message type (see table below)
  • native_id — unique hardware identifier, 6 hex characters, engraved at the factory (e.g. 1A2B3C)
  • proj_id — project identifier allocated during pairing (integer)
  • timestamp — Unix epoch UTC in seconds (integer)
  • key:value — pollutant / measurement pairs (see section 4)

3. Message codes

Code Direction Usage
0device → serverSensor registration / declaration
1device → serverData packet (real-time measurements)
2server → deviceConfiguration push / OTA URL

4. Pollutant keys (legacy IDs)

Numeric keys identify the measurement type. This enumeration is historical; new integrators should use the declarative pollutant_id schema instead (see section 6).

1:lat # GPS latitude (decimal degrees, Pico) 2:lon # GPS longitude 3:pm25 # PM2.5 (ug/m3) 4:pm10 # PM10 5:temp # Temperature (degC) 6:humidity # Relative humidity (%) 7:pressure # Atmospheric pressure (hPa) 8:co2 # CO2 (ppm) 9:voc # Total VOC (ppb) 45:fw_version # firmware version (string, e.g. "NEST v1.0.2") 51:rssi # WiFi RSSI (dBm, signed) 99:msisdn # GSM SIM MSISDN (ThingsMobile billing)

5. Complete example

Pico WiFi sensor 1A2B3C of project 42, packet sent on 2026-05-12 12:00:00 UTC, with GPS, PM2.5 = 12.5 ug/m3, temperature 21.3 degC:

1,1A2B3C,42,1747051200,1:48.8566,2:2.3522,3:12.5,5:21.3

6. EPIC Pollutant: declarative schema (recommended)

The new schema lets sensors declare their pollutants before transmitting, with multi-instance handling (e.g. 2 PM2.5 sensors on the same device), magnitude normalization, and alias resolution. This declaration lives on the Plumage frontend side:

POST /devices/{native_id}/pollutants Content-Type: application/json Authorization: Bearer {api_token} { "pollutants": [ { "code": "PM2.5", "unit": "ug/m3", "granularity": 60, "instance_label": "indoor" }, { "code": "PM2.5", "unit": "ug/m3", "granularity": 60, "instance_label": "outdoor" }, { "code": "CO2", "unit": "ppm", "granularity": 300 } ] }

Response: one integer pollutant_id per declared pollutant. The sensor can then send its UDP packets using these IDs as keys (instead of the legacy IDs from section 4). Idempotent for an identical payload.

7. REST API (Bearer token)

Endpoints accessible with a token generated from api/manage:

Method Endpoint Description
GET/api/verifyVerifies the token and returns user info
GET/api/sensorsList of the user's sensors
GET/api/projectsList of the user's projects
POST/api/dataPush measurements (HTTP alternative to UDP)
POST/GET/api/devicesRegister/list sensors
GET/api/v2/projects/{id}/devices/updatesMobile long-polling (Sprint 3 Plan C.5)

8. Quotas & rate limits

  • UDP: no strict quota on the sensor side, but the recommended minimum granularity is 60 s (anti-flood).
  • REST API: 100 requests / minute / token. X-RateLimit-Remaining header returned in every response.
  • UDP payload: 512 bytes max (typical LoRa/GSM MTU limit). Beyond that, the packet is silently truncated.

9. Validation & quarantine

The ingestion server (Birdhouse, Run 3 EPIC Pollutant) applies this validation pipeline:

  1. Resolution of the pollutant_id via Redis cache (5 min TTL) or DB fallback.
  2. Min/max validation according to the bounds declared on pollutants.
  3. Canonical conversion: value = raw_value × pollutants.scale_factor.
  4. Insertion into data_points_canonical (composite PK = dedup).
  5. On failure: copy into data_points_quarantine with a reason (below_min, above_max, cache_miss, nan_or_inf, etc.).

For debugging, contact contact@canarin-sensors.com mentioning the native_id and the timestamp: we can expose the quarantine trace on request.

10. Limits & excluded uses

The Canarin protocol is designed for indicative environmental measurements. See the disclaimer for the exhaustive list of excluded uses (medical, ATEX, fire safety, etc.).