Your First Garden Setup
Connect your first sensor and set up basic automated watering with MudPi.
Overview
In this guide, you'll wire a soil moisture sensor, configure MudPi to read from it, and set up a basic relay to control a water pump. By the end, you'll have a fully automated watering system.
Hardware Needed
Step 1: Wire the Soil Moisture Sensor
Connect the soil moisture sensor to your Raspberry Pi:
| Sensor Pin | Raspberry Pi | Physical Pin |
|---|---|---|
| VCC | 3.3V | Pin 1 |
| GND | Ground | Pin 6 |
| Signal | GPIO 4 | Pin 7 |
Step 2: Wire the Relay
Connect the relay module:
| Relay Pin | Raspberry Pi | Physical Pin |
|---|---|---|
| VCC | 5V | Pin 2 |
| GND | Ground | Pin 9 |
| IN | GPIO 17 | Pin 11 |
Step 3: Configure MudPi
Edit your mudpi.config.json to define the sensor, control, and automation trigger:
{
"name": "My First Garden",
"sensors": [
{
"pin": 4,
"type": "soil_moisture",
"name": "Garden Bed 1",
"poll_interval": 30
}
],
"controls": [
{
"pin": 17,
"type": "relay",
"name": "Water Pump"
}
],
"triggers": [
{
"source": "Garden Bed 1",
"condition": "below",
"value": 40,
"action": "Water Pump",
"action_state": "on",
"duration": 60
}
]
}
How the Trigger Works
Step 4: Start MudPi
python3 mudpi.py
MudPi will begin reading your soil moisture sensor every 30 seconds. If the moisture drops below 40%, the water pump will turn on for 60 seconds.
Monitor the live output to verify everything is working:
redis-cli SUBSCRIBE "mudpi:sensors" "mudpi:controls"
Next Steps
Explore more sensors and controls in the documentation, or check out Wiring Sensors for more hardware guides.