Skip to content
NEW AI Solution Creator — get a working IoT prototype in 10 minutes
Stand with Ukraine flag

UDP Integration

UDP Integration connects ThingsBoard to devices that communicate over raw User Datagram Protocol (UDP) sockets. It binds to a configured port, receives discrete UDP datagrams from devices, decodes each message through the Uplink Converter, and maps the result to ThingsBoard telemetry and attributes. It also supports downlink — sending response datagrams back to the source device address.

When to use UDP Integration:

  • Devices use a custom binary or text protocol over a raw UDP socket.
  • Firmware transmits fire-and-forget datagrams to a fixed host and port.
  • Low-overhead, connectionless transport is preferred over TCP (e.g., battery-powered sensors, high-frequency telemetry streams).
  • You need to bridge an existing UDP-based device protocol with ThingsBoard without re-flashing firmware.

Before creating the integration, ensure:

  • You have access to a ThingsBoard Professional Edition instance with integration functionality enabled for your tenant.
  • You have permissions to create integrations and data converters.
  • You know the payload format your UDP devices use.
  • Port 11560 (or whichever port you configure) must be open for incoming UDP traffic on the machine running the UDP Integration process. The remote process also needs outbound access to ThingsBoard’s gRPC port 9090.
  • The echo command piped to netcat (nc) is available for sending test UDP datagrams.

In this tutorial, device SN-003 sends temperature and humidity readings to the UDP Integration server on port 11560.

The integration accepts four payload formats. Select the one that matches your device:

SN-003,default,temperature,25.7,humidity,69

The decoder function receives the raw UDP datagram body as a payload byte array. It must return an object with at least deviceName and deviceType. Optionally, it can include telemetry (time-series measurements) and attributes (device properties) as flat key-value maps.

For the full decoder function reference — all input parameters and output fields — see Uplink data converter.

  1. Go to Integrations center ⇾ Data converters.
  2. Click + Add data converter ⇾ Create new converter.

In the Add data converter dialog:

  1. Converter type — leave Uplink (selected by default).
  2. Integration type — in the search field, enter UDP and select UDP from the list.
  3. Name — enter a converter name, for example UDP Uplink Converter.
  4. Main decoding configuration — paste the decoder function from the appropriate tab below, then continue with step 7.

Select the tab matching your payload type:

/** Decoder **/
// decode payload to string
var strArray = decodeToString(payload);
var payloadArray = strArray.replaceAll("\"", "").replaceAll("\\\\n", "").split(',');
var telemetryPayload = {};
for (var i = 2; i < payloadArray.length; i = i + 2) {
var telemetryKey = payloadArray[i];
var telemetryValue = parseFloat(payloadArray[i + 1]);
telemetryPayload[telemetryKey] = telemetryValue;
}
// Result object with device attributes/telemetry data
var result = {
deviceName: payloadArray[0],
deviceType: payloadArray[1],
telemetry: telemetryPayload,
attributes: {}
};
/** Helper functions 'decodeToString' and 'decodeToJson' are already built-in **/
return result;

The decoder expects a comma-separated string where position 0 is the device name, position 1 is the device type, and positions 2–N are alternating telemetry key/value pairs: deviceName,deviceType,key1,value1,key2,value2,...

To adapt this converter to your device:

  • Change the separator by replacing split(',') with your delimiter (e.g. split(';') or split('|')).
  • If the device name or type is at a different position, adjust the payloadArray[0] / payloadArray[1] index.
  • If telemetry keys are fixed rather than embedded in the payload, replace the loop with explicit assignments: telemetryPayload['temperature'] = parseFloat(payloadArray[2]);.
  • To report device properties instead of measurements, move fields from the telemetry map to the attributes map.
  1. Click Test payload decoder to verify your script. Paste a sample payload matching your format, then click Test and confirm the result contains the expected deviceName, deviceType, and telemetry fields.
  2. Click Add to save the converter.
  1. Go to Integrations center ⇾ Integrations and click + Add integration.
  2. Basic settings:
    • Select UDP as the integration type.
    • Enter a name — for example, UDP integration.
    • Enable integration and Allow create devices or assets are on by default.
    • Click Next.
  3. Uplink data converter:
    • Click Select existing and choose the UDP Uplink Converter created in the previous step, or click Create new to define the decoder inline.
    • Click Next.
  4. Downlink data converter:
    • Click Skip for now. You can add a downlink converter later.
  5. Connection settings:
    • Set the Port — default is 11560. This port must be open on the machine running the UDP Integration process.
    • The Execute remotely option is always enabled for UDP. Copy the Integration key and Integration secret — you will need them to start the remote integration process.
    • Configure the Handler Configuration — select the message framing strategy that matches your device protocol. See Handler Configuration below.
    Read more about each parameter in Connection Settings.
  6. Click Add to save the integration.

Port

UDP port the integration listens on for incoming datagrams. Must be unique per integration on a given host. Default: 11560.

Size of the buffer for inbound socket (in KB)

Size of the receive buffer for the inbound UDP socket in kilobytes. Increase this value if datagrams are being dropped under high load. Default: 64.

Enable broadcast

When enabled, the integration socket accepts broadcast UDP packets (destination 255.255.255.255 or a subnet broadcast address). Disable for unicast-only deployments. Enabled by default.

Execute remotely

Execute remotely is always enabled for UDP Integration. Copy the automatically generated Integration key and Integration secret values — credentials required to launch the UDP Integration as a standalone remote process. See Remote Integration for full setup instructions.

Downlink cache
ParameterDescription
Cache SizeMaximum number of device source addresses remembered for downlink routing. When the limit is reached, the oldest entry is evicted.
Cache time to live in minutesHow long a device’s source address is retained. If a downlink is triggered after the entry expires, it cannot be delivered until the device sends another uplink.

Advanced settings

FieldDescription
DescriptionOptional free-text description of the integration.
MetadataOptional key–value pairs injected into every message and accessible in converter scripts via the metadata object. Click Add to add a row.

Defines how the integration interprets the raw datagram bytes before passing them to the converter. Select the type that matches your device protocol:

Interprets the datagram as a text string encoded in the specified character set. Suitable for devices that send CSV lines or human-readable payloads.

ParameterDescription
Charset NameCharacter encoding used to decode the datagram bytes into a string. Default: UTF-8.

Refer to the remote integration guide to install and start the UDP Integration service.

Use the Integration key and Integration secret from the integration’s Connection settings when configuring the service.

After the integration is created, send a test uplink and confirm that ThingsBoard received the message, decoded it correctly, and provisioned the device.

Once the UDP Integration process is running, the UDP socket is bound and ready to receive datagrams. Use netcat in UDP mode (-u) to simulate a device sending data.

Select your payload type:

Terminal window
echo -e 'SN-003,default,temperature,25.7,humidity,69' | nc -u -w5 localhost 11560

Go to Integrations center ⇾ Integrations, open UDP integration, and click the Events tab. Each successfully processed uplink appears as a row with status OK.

To inspect converter processing, go to Integrations center ⇾ Data converters, click UDP Uplink Converter, and open its Events tab:

  • In — what the integration received (the raw datagram bytes)
  • Out — what the converter returned
  • Error — error text, if any

Go to Entities ⇾ Devices. Device SN-003 is auto-created on the first uplink. Open it and confirm the Latest Telemetry tab shows temperature = 25.7 and humidity = 69.

Downlink allows ThingsBoard to send messages back to devices over UDP — for example, in response to an RPC call or a shared attribute update. The response datagram is sent to the source IP address and port of the most recent uplink datagram received from that device.

The downlink converter transforms a Rule Engine message into the bytes sent back to the device.

  1. Go to Integrations center ⇾ Integrations and open the UDP integration.
  2. Click the pencil icon to enter edit mode.
  3. In the Downlink data converter field, click Create new.
  4. Enter a name, paste the encoder script shown below, then click Add.
  5. Click Apply changes.

Select your script language:

// Result object with encoded downlink payload
var result = {
// downlink data content type: JSON, TEXT or BINARY (base64 format)
contentType: "JSON",
// downlink data
data: JSON.stringify(msg),
// Optional metadata object presented in key/value format
metadata: {}
};
return result;

To send downlinks through the integration, modify the Root Rule Chain:

  1. Go to Rule chains and open the Root Rule Chain.
  2. Find the integration downlink node in the node library panel on the left. Drag it onto the canvas.
  3. In the node configuration dialog, enter a name (e.g. Downlink to UDP integration) and select your UDP integration. Click Add.
  4. Connect the message type switch node to the newly created integration downlink node using the Post attributes and Attributes Updated relation types to trigger downlinks whenever shared attributes are created or updated.
  5. Apply the changes.

Trigger a downlink by adding a shared attribute to the device:

  1. Go to Entities ⇾ Devices, open SN-003, and navigate to the Attributes tab.
  2. Select Shared attributes, click + to add a new attribute.
  3. Set the key (e.g. powerState) and value (e.g. on).
  4. Click Add.

To receive the downlink response, keep the connection open with -w10 and send an uplink:

Terminal window
echo -e 'SN-003,default,temperature,25.7,humidity,69' | nc -w10 -u localhost 11560

The Rule Engine routes the attribute creation message to the Integration Downlink node, which encodes it and sends it to the device. The terminal will print:

Terminal window
{"powerState":"on"}
SymptomCauseFix
No device created after sending datadeviceName is empty or undefinedCheck Debug Events → Out on the uplink converter; verify the decoder correctly extracts deviceName from the payload
Error in converterTBEL or JavaScript exceptionOpen Events → Error on the uplink converter and inspect the stack trace; use Test payload decoder to test against a sample payload
Datagram not received by integrationUDP port blocked or wrong target host/portVerify the integration process is running; confirm the UDP port is open in the firewall; check that nc -u is targeting the correct host and port
Messages decoded incorrectlyHandler type mismatchVerify the Handler Configuration tab matches your device’s actual payload format; use a packet capture (tcpdump -i lo udp port 11560) to inspect raw datagrams
Integration process fails to connect to ThingsBoardWrong host, port, key, or secretVerify host, port, routingKey, and secret in tb-remote-integration.yml; ensure ThingsBoard gRPC port 9090 is reachable
Port already in useAnother process or integration is using the same UDP portChoose a different port in the integration Connection settings and update the configuration file accordingly
Device does not receive downlinkEphemeral source port changes between sendsDevice must send from a fixed source port; single-shot nc -u uses a random ephemeral port — bind to a fixed port with -p or use a proper device client
Data present but timestamp is wrongDevice sends ts in secondsConvert before assigning: ts: data.ts * 1000
Telemetry not savedConverter returns {} or []Ensure telemetry contains at least one field