This topic lets you publish one or more dots to a variable in a device.
To send data to one variable, publish to the following topic with these parameters:
Topic
/v1.6/devices/<device_label>/<variable_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
The accepted message payloads for different cases are as follows:
{"value": 27}{
"value": 10,
"timestamp": 1634311791000,
"context": {
"status": "cold"
}
}[
{
"value": 27,
"timestamp": 1634311791000
},
{
"value": 28,
"timestamp": 1634311435000
},
{
"value": 34,
"timestamp": 1634876591000
}
]{
"value": 1,
"context": {
"lat": "6.5423",
"lng": "-70.5783"
}
}
timestampandcontextThe
timestampandcontextparameters are optional.
Timestamp FormatAll timestamps must be in milliseconds. You can convert dates to
timestampvalues here.
Sending location data
You may use the context key to send location data. Ubidots will automatically recognize location data when using these variable labels:
positionlocationgps
There are three ways to send location data:
{
"position": {
"value": 1,
"context": {
"lat": "6.5423",
"lng": "-70.5783"
}
}
}// Because the "value" of a dot is mandatory, this option sets the variable value to "1".
{
"position": {
"lat": "6.5423",
"lng": "-70.5783"
}
}// Because the "value" of a dot is mandatory, this option sets the variable value to "1".
{
"position": {
"latitude": "6.5423",
"longitude": "-70.5783"
}
}
Location DataYou have several ways to include latitude and longitude when sending your dots to Ubidots. Please refer to this documentation.
Examples
NoteAll Bash examples in this section use the Eclipse Mosquitto library. To test them, install it using the official instructions.
Send a value to a variable
Update a variable and let Ubidots apply a timestamp equal to the reception time:
$ mosquitto_pub \
-h 'industrial.api.ubidots.com' \
-t '/v1.6/devices/weather-station/temperature' \
-u 'BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB' \
-p 1883 \
-q 1 \
-m '{"value": 27}'Send multiple values to a variable
Update a variable with multiple values, each containing a specified timestamp:
$ mosquitto_pub \
-h 'industrial.api.ubidots.com' \
-t '/v1.6/devices/weather-station/temperature' \
-u 'BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB' \
-p 1883 \
-q 1 \
-m '[
{
"value": 27,
"timestamp": 1634311791000
},
{
"value": 28,
"timestamp": 1634311435000
},
{
"value": 34,
"timestamp": 1634876591000
}
]'Send a dot to a single variable
Update a variable with a complete dot by specifying context and/or timestamp:
$ mosquitto_pub \
-h 'industrial.api.ubidots.com' \
-t '/v1.6/devices/weather-station/temperature' \
-u 'BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB' \
-p 1883 \
-q 1 \
-m '{
"value": 10,
"timestamp": 1634311791000,
"context": {
"status": "cold"
}
}'Send location data
Update a position variable so that the device displays its location:
$ mosquitto_pub \
-h 'industrial.api.ubidots.com' \
-t '/v1.6/devices/weather-station/position' \
-u 'BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB' \
-p 1883 \
-q 1 \
-m '{
"value": 1,
"context": {
"lat": "6.5423",
"lng": "-70.5783"
}
}'$ mosquitto_pub \
-h 'industrial.api.ubidots.com' \
-t '/v1.6/devices/weather-station/position' \
-u 'BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB' \
-p 1883 \
-q 1 \
-m '{
"lat": "6.5423",
"lng": "-70.5783"
}'$ mosquitto_pub \
-h 'industrial.api.ubidots.com' \
-t '/v1.6/devices/weather-station/position' \
-u 'BBFF-Rfcgaxns6HlVb155WA0RhSY85xNDmB' \
-p 1883 \
-q 1 \
-m '{
"latitude": "6.5423",
"longitude": "-70.5783"
}'
Same timestamp for multiple valuesIf you need the same timestamp for multiple values, publish data with a global timestamp to save payload space. For more instructions, see Publish data with global timestamp.

