While our REST API provides a good way to access all of our resources (devices, variables and values) programatically, sometimes you just need to send data from your device using a simple protocol like TCP or UDP.

We have designed a simple payload format you can use to send data from your devices to Ubidots using these protocols.

TCP/UDP Endpoint Basics

For the host and port configuration just use: 

URL

translate.ubidots.com

Port

9012

To send data over TCP or UDP just use:

Payload

{useragent}|POST|{token}|{device_label}:{variable_label}=>{value}${context_property1}={context_value1}${context_property2}={context_value2}@{timestamp}|end

Where:

  • {useragent}: An identifier of your choice to help us to log your data for possible debugging in the future. It's a good practice to include a version in case you're wrapping these requests within a library. Examples: "CompanyIoT/1.0" or "Particle/1.3".
  • {token}: Your Ubidots account token
  • {device_label}: Your device label
  • {variable_label}: Label of your variable. You can add several variables.
  • {timestamp}: Optional timestamp in milliseconds, to assign to the value sent

Examples

Here some examples to update a device with the API label "my-device":

Update two variables

microchip/1.0|POST|p4uuT2OIIFJwv7ncTVfoVqcfImwRQW|my-device=>temperature:14,humidity=12|end

Update two variables, where one contains GPS data

mbed/1.2|POST|p4uuT2OIIFJwv7ncTVfoVqcfImwRQW|my-device=>temperature:14,position=0$lat=6.2$lng=-76.3|end

Update two variables, each with a user-defined timestamp

microchip/1.0|POST|p4uuT2OIIFJwv7ncTVfoVqcfImwRQW|my-device=>temperature:14@1492641596000,humidity=12@1492631497000|end

Testing

A quick way to test this is using "netcat" from a Unix shell:

UDP

nc -u translate.ubidots.com 9012

Microchip/1.0|POST|GNfHQ6X5yLidjhwZe7EQGDhk1UfkTD|device-udp=>temp:20$lat=-6.2$lng=2.3,humidity:10|end 

TCP

nc translate.ubidots.com 9012

Microchip/1.0|POST|GNfHQ6X5yLidjhwZe7EQGDhk1UfkTD|device-udp=>temp:20$lat=-6.2$lng=2.3,humidity:10|end 

Result:

Please note that the "temp" variable has the "lat" and "lng" properties, which you can later use to add a map widget:

To receive the last value over TCP or UDP just use:

Payload

{useragent}|LV|{token}|{device_label}:{variable_label}|end

Where:

  • {useragent}: An identifier of your choice to help us to log your data for possible debugging in the future. It's a good practice to include a version in case you're wrapping these requests within a library. Examples: "CompanyIoT/1.0" or "Particle/1.3".
  • {token}: Your Ubidots account token
  • {device_label}: Your device label
  • {variable_label}: Label of your variable. 

Examples

Here is an example to get the last value from a variable with the device label "my-device"  and variable label "my-variable"

microchip/1.0|LV|p4uuT2OIIFJwv7ncTVfoVqcfImwRQW|my-device:my-variable|end

Testing

A quick way to test this is using "netcat" from a Unix shell:

UDP

nc -u translate.ubidots.com 9012

microchip/1.0|LV|p4uuT2OIIFJwv7ncTVfoVqcfImwRQW|my-device:my-variable|end

TCP

nc translate.ubidots.com 9012

microchip/1.0|LV|p4uuT2OIIFJwv7ncTVfoVqcfImwRQW|my-device:my-variable|end

NOTE: If you're a business license user, feel free to contact your account executive to request a custom protocol (i.e. TCP/UDP/SMS/CoAP) with privately allocated capacity under your own URL.

Did this answer your question?