Back to Guides
Beginner • ~20 min read

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

Raspberry Pi with MudPi installed
Capacitive soil moisture sensor
Single-channel relay module
Small water pump or solenoid valve
Jumper wires
Breadboard (optional)

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:

mudpi.config.json
{
  "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
    }
  ]
}
Click to expand code…

How the Trigger Works

The trigger monitors "Garden Bed 1" soil moisture. When the reading drops below 40%, it turns on the "Water Pump" relay for 60 seconds, then automatically shuts it off.

Step 4: Start MudPi

Shell
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:

Shell
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.