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.
Interface | Description | |
example | Returns a random number | Learn More |
gpio | Get GPIO reading from linux supported board | Learn More |
dht | Connects to a DHT sensor for climate readings | Learn More |
bme680 | Gets environmental readings from a BME680 sensor | Learn More |
redis | Gets data from redis memory store or listens to a redis event for data | Learn More |
mqtt | Listens to a MQTT topic for data | Learn More |
t9602 | Collect temperature from a T9602 | Learn More |
nanpy | Get data from a device running Nanpy | Learn More |
If you would like at add support for another sensor interface read the developer docs and submit a PR!
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_update | Immediately trigger a component update (TESTING ONLY). |