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:
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 |
|---|---|---|
| 0 | device → server | Sensor registration / declaration |
| 1 | device → server | Data packet (real-time measurements) |
| 2 | server → device | Configuration 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).
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:
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:
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/verify | Verifies the token and returns user info |
| GET | /api/sensors | List of the user's sensors |
| GET | /api/projects | List of the user's projects |
| POST | /api/data | Push measurements (HTTP alternative to UDP) |
| POST/GET | /api/devices | Register/list sensors |
| GET | /api/v2/projects/{id}/devices/updates | Mobile 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-Remainingheader 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:
- Resolution of the
pollutant_idvia Redis cache (5 min TTL) or DB fallback. - Min/max validation according to the bounds declared on
pollutants. - Canonical conversion:
value = raw_value × pollutants.scale_factor. - Insertion into
data_points_canonical(composite PK = dedup). - On failure: copy into
data_points_quarantinewith 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.).