Publish data to a Device (v2.0)

Use this topic to publish data to more than one variable of a device with a global timestamp.

You can send several values with the same timestamp. This helps reduce data upload costs and create scripts with lower ROM memory usage. Use the global timestamp as follows:

Topic:

/v2.0/devices/<device_label>
FieldValueRequired
Hostindustrial.api.ubidots.comYes
Port1883/8883 (Non-TLS/TLS)Yes
UsernameYour Ubidots TokenYes
PasswordAny character or leave blankNo
Quality of Service0 or 1No

Payload structure:

{
  "temperature": 10,
  "humidity": 90,
  "pressure": 78,
  "timestamp": 1634311791000
}
{
  "temperature": {
    "value": 10,
    "timestamp": 1634378596000,
    "context": {
      "status": "cold"
    }
  },
  "humidity": {
    "value": 90,
    "context": {
      "status": "High humidity"
    }
  },
  "pressure": {
    "value": 78,
    "context": {
      "status": "Normal"
    }
  },
  "timestamp": 1634311791000
}
🚧

timestamp hierarchy

If a timestamp is provided within a Dot, it overrides the global timestamp and uses the provided timestamp instead. For example, the temperature variable receives a value of 10 with the timestamp 1634378596000 instead of the global timestamp 1634311791000.

Example

📘

The Bash examples in this section use the Eclipse Mosquitto library. To test them, install it by following the official instructions.

Send data to multiple Variables with a global timestamp
Update multiple variables with a global timestamp that applies to all values.

$ mosquitto_pub \
-h 'industrial.api.ubidots.com' \
-t '/v2.0/devices/weather-station' \
-u 'BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB' \
-p 1883 \
-q 1 \
-m '{
  "temperature": 10,
  "humidity": 90,
  "pressure": 78,
  "timestamp": 1634311791000
}'

Send data to multiple Variables with a global timestamp
Update multiple variables with a global timestamp that applies to all Dots.

$ mosquitto_pub \
-h 'industrial.api.ubidots.com' \
-t '/v2.0/devices/weather-station' \
-u 'BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB' \
-p 1883 \
-q 1 \
-m '{
  "temperature": {
    "value": 10,
    "timestamp": 1634378596000,
    "context": {
      "status": "cold"
    }
  },
  "humidity": {
    "value": 90,
    "context": {
      "status": "High humidity"
    }
  },
  "pressure": {
    "value": 78,
    "context": {
      "status": "Normal"
    }
  },
  "timestamp": 1634311791000
}'