Documentation
Sensor Configuration
Configure sensors on the Raspberry Pi to gather climate data, soil moisture, water levels, and more.
Overview
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, place a sensor configuration object in the sensors array within a sensor type worker. The minimum required options are type, pin, and key:
{
"workers": [{
"type": "sensor",
"sensors": [
{
"type": "Humidity",
"pin": 25,
"key": "weather_sensor"
}
]
}]
}
Settings
| 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 a valid Redis key. |
| `name` | String | No | Friendly display name of the sensor. If not provided, the key is used with underscores replaced by spaces. |
Sensor Types (Raspberry Pi)
There are a number of sensors supported by default with MudPi for the Raspberry Pi. The main limitation of the Pi is digital GPIO only, which is why Arduino nodes are used for analog sensors.
| Type | Returns | Description |
|---|---|---|
| Float | Boolean | 0 or 1 digital read of liquid level. If marked critical it will prevent the pump from running until it returns 1 (true). |
| Humidity | Object | Takes a digital read of humidity and temperature. |
I2C Sensor Configuration
I2C sensors gather pressure, soil moisture, environmental conditions, light intensity and more over the I2C bus. I2C components are useful because multiple devices can run on one bus, reducing the number of GPIO pins needed.
To add an I2C sensor, place a sensor configuration object in the sensors array just like general sensors. The minimum required options are type, address, and name. The main difference is that I2C sensors use an address instead of a pin:
{
"workers": [{
"type": "sensor",
"sensors": [
{
"type": "Bme680",
"address": 119,
"name": "Barometer"
}
]
}]
}
I2C Sensor Settings
| Option | Type | Required | Description |
|---|---|---|---|
| `type` | String | Yes | Type of I2C sensor. Options: `Bme680` |
| `address` | Integer | No | I2C address of the sensor. Since JSON does not support hex, use an integer. Run `int(0x77)` in Python to convert hex to integer. |
| `name` | String | Yes | Name of the sensor. The name is slugged and used as the Redis key if a key is not specified. |
| `key` | String | No | Key to store value under in Redis. If not provided, the name is converted to lowercase with underscores. |
I2C Sensor Types
| Type | Returns | Description |
|---|---|---|
| BME680 | Object | Barometric sensor for pressure, humidity, and temperature readings. |
Extending Sensor Support
If you have a sensor you want to add support for, you can do so by extending the main Sensor class. When MudPi loads on boot it loops through the sensors and looks for a matching class. For example, a sensor with type Humidity will cause MudPi to look for a HumiditySensor class to instantiate. Read more about how to extend MudPi.