Skip to main content

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​

Step 1: Start a new crate

On Your crates, tap New crate and give it a name.

Step 2: Pick the type

Open More options and set Type to The Things Network.

Step 3: Create

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
note

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​

Step 1: Open webhooks

In your application in The Things Network, open Integrations, then Webhooks, then Add webhook and Custom webhook.

Step 2: Paste the URL

Use the TTN webhook URL as the Base URL, and JSON as the format.

Step 3: Add your key

Add a header named X-API-Key with your crate's API key.

Step 4: Turn on uplinks

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 uplinkStored as
end_device_ids.device_idThe device
Each number in decoded_payloadA metric with that name
received_atThe time
A time key in decoded_payloadThe 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:

MetricWhat it is
rssiSignal strength at the first gateway, in dBm
channel_rssiChannel signal strength at the first gateway, in dBm
snrSignal-to-noise ratio at the first gateway, in dB
frequencyThe frequency, in Hz
spreading_factorThe LoRa spreading factor
bandwidthThe 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.