content/flux/v0/stdlib/experimental/mqtt/to.md
mqtt.to() outputs data from a stream of tables to an MQTT broker using MQTT protocol.
(
<-tables: stream[A],
broker: string,
?clientid: string,
?name: string,
?password: string,
?qos: int,
?retain: bool,
?tagColumns: [string],
?timeColumn: string,
?timeout: duration,
?topic: string,
?username: string,
?valueColumns: [string],
) => stream[B] where A: Record, B: Record
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
({{< req >}}) MQTT broker connection string.
MQTT topic to send data to.
MQTT Quality of Service (QoS) level. Values range from [0-2]. Default is 0.
MQTT retain flag. Default is false.
MQTT client ID.
Username to send to the MQTT broker.
Username is only required if the broker requires authentication. If you provide a username, you must provide a password.
Password to send to the MQTT broker. Password is only required if the broker requires authentication. If you provide a password, you must provide a username.
Name for the MQTT message.
MQTT connection timeout. Default is 1s.
Column to use as time values in the output line protocol.
Default is "_time".
Columns to use as tag sets in the output line protocol.
Default is [].
Columns to use as field values in the output line protocol.
Default is ["_value"].
Input data. Default is piped-forward data (<-).
import "experimental/mqtt"
import "sampledata"
sampledata.float()
|> mqtt.to(
broker: "tcp://localhost:8883",
topic: "example-topic",
clientid: r.id,
tagColumns: ["id"],
valueColumns: ["_value"],
)