Sensors are used to gather climate info, soil moisture, water levels, light intensity and more. MudPi has support for a number of sensors out of the box and is easy to expand support to others.
To add a sensor to MudPi you will put a sensor configuration object in the sensors
array. The minimum required options in a sensor config are type
, pin
, and key
.
{
"workers":[{
"type":"sensor",
"sensors": [
{
"type":"Humidity",
"pin": 25,
"key":"weather_sensor"
}
]
}]
}
Option | Type | Required | Description |
type | [String] | Yes | Type of sensor. Options: Float , Humidity |
pin | [Integer] | Yes | GPIO pin number on raspberry pi the sensor is connected to. |
key | [String] | Yes | Key to store value under in redis. Alphanumeric with underscores only. Must be valid redis key. |
name | [String] | No | Name of the sensor. Mainly just a friendly display value. If a name is not provided it will use the key capitolized and underscores replaced with spaces. |
There are a number of sensors supported by default with MudPi for both the raspberry pi and arduino. The main limitation of the pi is digital GPIO only, that is why we use the arduinos. You can find details about each sensor type under the sensors section in the docs.
Type | Returns | Description |
Float | [Boolean] | 0 or 1 digital read of liquid level. If marked critical it will prevent pump from running until it returns 1 (true) |
Humidity | [Object] | Take a digital read of humidity and temperature. |
If you have a sensor you want to add support for you can do so by extending the main Sensor class in the library. When MudPi loads on boot it loops through the sensors and looks for a matching class to the sensor type. For example when a sensor with a type of Humidity
is loaded, MudPi behind the scenes is looking for a HumiditySensor
class that it will instantiate. You read more about how to extend MudPi here.