Skip to content

Sending data to BinBotPlatform

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.

from pub_data import publish

# Generate json data
data = {
   "key1": "value1",
   "key2": "value"
}

# Define which measurement the data belongs to. Battery stats for example
measurement = "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.

  1. The measurement will the topic used in the MQTT message. For example is you used batteryStats the mqtt topic would be binBot/batteryStats
  2. The measurement will be the name of the measurement (Similar to Collections in Mongodb) that the data will be put into.

Clone this wiki locally