Datastreams

Blynk.Cloud MQTT API uses Names to reference Datastreams.

circle-exclamation

Send data to Blynk

Publish topic ds/DATASTREAM, payload: value in plain text (i.e. 123, hello or 3.1415926)

  • DATASTREAM - the datastream name

circle-info

For multivalue (array-like) values, the individual items in the payload are separated using a 0x00 byte, i.e: First\u0000Second\u0000Third. The separator is a NUL character, that is also represented as \u0000 in Unicode.

mosquitto_pub -h blynk.cloud -p 8883 -u device -P '{DEVICE_TOKEN}' -t 'ds/Temperature' -m '21.3'

Send batched data to Blynk

Publish topic batch_ds, payload: JSON-encoded object with datastream name as the key and datastream value as the value. The JSON value type must match with the datastream type. Use string for datastream with String data type, number for datastream with Integer, Double or Enum value type, true or false for datastream with Boolean data type and array of two numbers for datastream with Location data type (use longitude as the first array element and latitude as the second). Example:

{
    "Name": "Sample Batch Uplink",
    "Temperature": 10.3,
    "Location": [30.523333, 50.450001],
    "Device On": true
}
mosquitto_pub -h blynk.cloud -p 8883 -u device -P '{DEVICE_TOKEN}' -t 'batch_ds' -m '{"Temperature": 23.1, "Humidity": 72}'

Send timestamped batch to Blynk

Sometimes a device collects data in its own memory and needs to send multiple timestamped data points at once to reduce the number of TCP messages.

For these purposes, use the ds/DATASTREAM/timestamped_batch topic. Send a comma-separated array of timestamps and corresponding values.

Example payload:

The timestamp should be sent in milliseconds and no older than 1 month. Blynk will also accept points with a timestamp "in the future" within the next 1 month.

Erase datastream value

Publish topic ds/DATASTREAM/erase, payload: empty

  • DATASTREAM - the datastream name

Get data updates from Blynk

Subscribe to topic: downlink/ds/DATASTREAM

  • DATASTREAM - the datastream name

circle-check

Request the latest value from Blynk

Publish topic get/ds, payload: datastream names separated by comma (i.e. Brightness,Color)

The device will receive requested datastream values on downlink/ds/DATASTREAM topic.

Request current values for all datastreams

Publish topic get/ds/all, payload: empty

The device will receive requested datastream values on downlink/ds/DATASTREAM topic.

circle-info

For this to work, open Datastream settings and enable Advanced Settings -> Sync with latest server value.

Last updated

Was this helpful?