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.
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.
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.
Below is a list of currently supported interfaces for sensors.
|Returns a random number
|Get GPIO reading from linux supported board
|Connects to a DHT sensor for climate readings
|Gets environmental readings from a BME680 sensor
|Gets data from redis memory store or listens to a redis event for data
|Listens to a MQTT topic for data
|Collect temperature from a T9602
|Get data from a device running Nanpy
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.
|Immediately trigger a component update (TESTING ONLY).