Use this Topic to Publish data to more than one variable of a Device with 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>
Field | Value | Required |
---|---|---|
Host | industrial.api.ubidots.com | Yes |
Port | 1883/8883 (Non-TLS/TLS) | Yes |
Username | Your Ubidots Token | Yes |
Password | Any character or leave blank | No |
Quality of Service | 0 or 1 | No |
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
hierarchyIf a timestamp is provided within a Dot, it will ignore the global timestamp and use the provided one instead. e.g. the "temperature" variable will receive a 10 with the timestamp: 1634378596000 instead of the global timestamp: 1634311791000.
Example
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.
Send data to multiple Variables with global timestamp
Update multiple variables with a global timestamp that is applied 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 global timestamp
Update multiple variables with a global timestamp that is applied 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
}'