Skip to content

Sensors

Paolo Grasso edited this page Aug 20, 2020 · 2 revisions

General info

A sensor script relies on a conf.json files which contains its devID, catalog IP and catalog port. It also uses some general functions stored in sensor_functions.py.

Execution

When launched, a sensor should:

  1. Get the current time (base time BT).
  2. Connect to MQTT broker.
  3. Start a thread which should:
    • Ask the catalog gardenID, plantID and resources which are associated to the sensor, in order to build the MQTT topic.
    • Publish «I’m alive» messages which are processed by the catalog.
  4. Start a thread which collect and publish environmental data every minute.

Message format

The format used for publishing MQTT messages is SenML. It consists in a JSON containing the following keys:

  • bn: It contains devID
  • e: A list of events. Each one contains:
    • n: Type of event (resource or alive)
    • u: Unit of measurement of the resource
    • t: timestamp referred to the basetime BT
    • v: value of the resource
    • topic: topic (for alive messages)
Clone this wiki locally