How do I batch multiple Simple Time Series Data points into a single MQTT message?
Build the JSON payload manually and publish directly. One message can carry multiple data points at a single timestamp.
Payload format (device Temperature Sensor, three data points at one timestamp):
{
"name": "Temperature Sensor.point",
"dt": "string",
"t": 1730171535,
"d": 30,
"v": {
"point1": 25.5,
"point2": 25.5,
"point3": 25.5
}
}
name:<DeviceName>.<GroupParameterName>t: Unix timestampd: TTL in days (0 = never expire)v: object containing all data points; keys and structure are user-defined
Publish to cloud:
esp_err_t esp_rainmaker_report_simple_ts_data(char *buf, size_t buf_size)
{
char publish_topic[150] = {0};
esp_rmaker_create_mqtt_topic(publish_topic, sizeof(publish_topic),
"simple_tsdata", "esp_simple_ts_ingest");
return esp_rmaker_mqtt_publish(publish_topic, buf, buf_size, RMAKER_MQTT_QOS1, NULL);
}
When using this method, the parameter does not need PROP_FLAG_SIMPLE_TIME_SERIES — the application controls all reporting.