You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Daemon Macklin edited this page Mar 29, 2020
·
3 revisions
This page will go over how to publish data to the BinBotPlatform MQTT broker.
This snippet would be a sample usage of the publish function.
frompub_dataimportpublish# Generate json datadata= {
"key1": "value1",
"key2": "value"
}
# Define which measurement the data belongs to. Battery stats for examplemeasurement="batteryStats"publish(measurement, data)
This isn't tested so...maybe not.
Data
The MQTT wrapper is expecting data to be in a json format. The json data will be put directly into the Influx database. Since influx is a NoSQL database, you will not need to pre-define the fields in a measurement, or the measurement itself. The measurement will be automatically created with the first insert.
Measurement
The measurement will be used for two things.
The measurement will the topic used in the MQTT message. For example is you used batteryStats the mqtt topic would be binBot/batteryStats
The measurement will be the name of the measurement (Similar to Collections in Mongodb) that the data will be put into.