Sensors

An important part of MudPi are sensors. Without them it can be hard to determine the status of our system and surrounding environment. A sensor gathers state on a set interval and any changes are broadcast throughout the system. MudPi supports a variety of both digital and analog sensors through interfaces.

Sensor Fundamentals

All sensors extend from a base Sensor component class and are intended to be as simple as possible. The main responsibility of a sensor is to just get the data and return that to the worker. Sensors should not sleep the thread. Instead that is for workers to handle as well as storing/publishing data.

Sensor Data

Sensors take readings during each worker update cycle. For each loop all the sensor data is packaged in a JSON object keyed based on the key. This data then gets published over the event system.

Available Interfaces

Below is a list of currently supported interfaces for sensors.

InterfaceDescription
exampleReturns a random numberLearn More
gpioGet GPIO reading from linux supported boardLearn More
dhtConnects to a DHT sensor for climate readingsLearn More
bme680Gets environmental readings from a BME680 sensorLearn More
redisGets data from redis memory store or listens to a redis event for dataLearn More
mqttListens to a MQTT topic for dataLearn More
t9602Collect temperature from a T9602Learn More
nanpyGet data from a device running NanpyLearn More

If you would like at add support for another sensor interface read the developer docs and submit a PR!

Available Actions

Sensors provide a force_update action to immediately trigger an update. This is intended mainly for testing only as it can lead to deadlocks if not used correctly.

Action
force_updateImmediately trigger a component update (TESTING ONLY).