The Things Network
A The Things Network crate takes uplinks from your LoRaWAN devices through a webhook. There is no code to write: The Things Network sends each uplink, and the crate stores the decoded values and the signal quality.
Make a The Things Network crate
On Your crates, tap New crate and give it a name.
Open More options and set Type to The Things Network.
Tap Create crate. Under Send data you'll find your API key and the TTN webhook URL:
https://data.carroted.com/api/v2/ingest/YOUR_CRATE_ID/ttn
The crate type is set when you make the crate. A General crate refuses webhooks, and a The Things Network crate refuses plain HTTP readings, with 403 Ingestion Method Mismatch.
Decode your payload
Your device sends bytes. Add an uplink payload formatter to your application in The Things Network so each uplink arrives as named numbers. For example:
function decodeUplink(input) {
const b = input.bytes;
return {
data: {
temperature: ((b[0] << 8) | b[1]) / 100,
humidity: b[2],
battery: b[3],
},
};
}
Only numbers are stored. Text, true/false and nested objects are skipped.
Add the webhook
In your application in The Things Network, open Integrations, then Webhooks, then Add webhook and Custom webhook.
Use the TTN webhook URL as the Base URL, and JSON as the format.
Add a header named X-API-Key with your crate's API key.
Tick Uplink message and save. Readings arrive as they come in.
To check the crate end to end before a device is ready, tap Send a test reading under Send data. It sends a sample uplink from a device called ttn-simulator-01.
What gets stored
| From the uplink | Stored as |
|---|---|
end_device_ids.device_id | The device |
Each number in decoded_payload | A metric with that name |
received_at | The time |
A time key in decoded_payload | The time instead, if it's an RFC 3339 timestamp no more than 24 hours ahead |
Every uplink also stores these metrics, when the uplink includes them:
| Metric | What it is |
|---|---|
rssi | Signal strength at the first gateway, in dBm |
channel_rssi | Channel signal strength at the first gateway, in dBm |
snr | Signal-to-noise ratio at the first gateway, in dB |
frequency | The frequency, in Hz |
spreading_factor | The LoRa spreading factor |
bandwidth | The LoRa bandwidth, in Hz |
Troubleshooting
Nothing arrives
Open Live data in The Things Network and look for webhook errors. Check that Uplink message is ticked and that the X-API-Key header has no extra spaces.
The reply says "No numeric data extracted" The uplink had nothing that is a number. Check your payload formatter returns numbers.
429 replies The crate has hit its daily limit or its rate limit. See Limits and errors.