/v1.6/devices/{DEVICE_LABEL}
/v2.0/devices/{DEVICE_LABEL}

To send data, set the unique Device label in the topic path.

Ubidots accepts MQTT data JavaScript Object Notation or JSON. JSON is a collection of name/value pairs in various programming languages, this is treated as an object, record, struct, dictionary, hash table, keyed list, or associative array. It is also human readable and language independent. An example of a JSON data type that Ubidots accepts can be referenced below:

{"temperature": {"value":10, "timestamp": 1534881387000, "context": {"machine": "1st floor"}}}
The keys context and timestamp are optional.

mosquitto_pub 
-h "industrial.api.ubidots.com" 
-t "/v1.6/devices/weather-station" 
-u "BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB" 
-p 1883 
-q 1 
-m '{"temperature": 27}'
mosquitto_pub 
-h "industrial.api.ubidots.com" 
-t "/v1.6/devices/weather-station" 
-u "BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB" 
-p 1883 
-q 1 
-m '{"position": {"value" : 1, "timestamp": 1514808000000, "context":{"lat":-6.2, "lng":75.4}}}'
mosquitto_pub 
-h "industrial.api.ubidots.com" 
-t "/v1.6/devices/weather-station" 
-u "BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB" 
-p 1883 
-q 1 
-m '{"temperature": {"value": 27, "timestamp": 1514808000000}, "humidity": 55, "pressure": {"value": 78, "context":{"name" : "John"}}}'

📘

timestamp and context

Please Note: The timestamp and context parameters are optional.

🚧

Timestamp Format

All timestamps must be in milliseconds. You can easily convert dates to timestamp values here.

👍

Location Data

You have a lot of ways to include longitude and latitude when sending your dots to Ubidots. Please refer to this documentation.

If you wish to send more than one value, then you need to separate them using commas. Below you can reference a typical structure for MQTT payloads:

{
  "VARIABLE-LABEL": 
    {
      "value":VALUE, 
      "timestamp": TIMESTAMP, 
      "context":
        {
          "context_key":CONTEXT_VALUE
        }
    }
}
{
        "variable-label-1": 
                {"value": VALUE, "timestamp": TIMESTAMP, "context": {"key": CONTEXT_VALUE}},
        "variable-label-2": 
                {"value": VALUE, "timestamp": TIMESTAMP, "context": {"key": CONTEXT_VALUE}},
        ... ,
        ... ,

        "variable-label-n": 
                {"value": VALUE, "timestamp": TIMESTAMP, "context": {"key": CONTEXT_VALUE}}
}

Global timestamp

It is possible to send several values with the same timestamp. This is useful to save data upload costs and to create lower rom memory scripts. You can use the global timestamp as follows:

Topic: /v2.0/devices/{DEVICE_LABEL}
Payload Structure:

{"var1": <value>, "var2":<value>, ... , "varn": <value>, "timestamp": <timestamp>}}

{"var1": {"value": <value>, "context": {"key1": <key_value>, ... , "keyn": <key_value>}, ... , "varn": {"value": <value>, "context": {"key1": <key_value>, ... , "keyn": <key_value>}, "timestamp": <timestamp>}}

Examples

Note: All the bash examples from this section make use of the Eclipse Mosquitto library, if you wish to test them please install it using the official instructions.

  • Single dot: {"temperature": 27}

  • Multiple dots: {"temperature": 27, "humidity": 55, ... ,"pressure": 78}

  • Single dot: {"temperature": 27}

  • Multiple dots: {"temperature": 27, "humidity": 55, ... ,"pressure": 78}

  • Multiple dots with global timestamp: {"temperature": 27, "humidity": 55, ... ,"pressure": 78, "timestamp": 1601414731000}

Including additional keys like context and timestamp

  • Single dot: {"position": {"value" : 1, "timestamp": 1514808000000, "context":{"lat":-6.2, "lng":75.4, "name" : "John"}}}

  • Multiple dots: {"temperature": {"value": 27, "timestamp": 1514808000000}, "humidity": 55, "pressure": {"value": 78, "context":{"name" : "John"}}}