Back to Guides
Intermediate • ~15 min read

Wiring Sensors

Connect soil moisture, temperature, humidity, and rain sensors to your MudPi unit.

Sensor Overview

MudPi supports both analog and digital sensors. This guide covers the most common sensors used in garden automation.

DHT22 Temperature & Humidity Sensor

The DHT22 provides both temperature and humidity readings from a single sensor, making it ideal for greenhouse monitoring.

MudPi sensor wiring diagram
Example wiring for a DHT sensor on Raspberry Pi GPIO
DHT22 Pin Connection Notes
VCC 3.3V
Data GPIO pin Add 10KΩ pull-up resistor to VCC
GND Ground

Configuration for a DHT22 sensor:

JSON
{
  "pin": 22,
  "type": "dht22",
  "name": "Greenhouse Climate",
  "poll_interval": 60
}

Capacitive Soil Moisture Sensor

Capacitive sensors are preferred over resistive ones as they don't corrode over time. They output an analog voltage that corresponds to moisture level.

Why Capacitive?

Resistive soil moisture sensors have exposed metal that corrodes in wet soil within weeks. Capacitive sensors use a protected circuit board and last much longer in outdoor conditions.

Since the Raspberry Pi doesn't have native analog inputs, you'll need an ADC (Analog to Digital Converter) like the ADS1115 or MCP3008:

JSON
{
  "pin": 0,
  "type": "soil_moisture",
  "name": "Raised Bed A",
  "adc": "ads1115",
  "poll_interval": 30
}

Rain Sensor

Rain detection sensors use a conductive pad that changes resistance when wet. Connect the digital output to a GPIO pin for simple wet/dry detection.

JSON
{
  "pin": 27,
  "type": "rain",
  "name": "Rain Detector",
  "poll_interval": 10
}

Tips for Outdoor Wiring

Weather Protection

Outdoor electronics fail primarily from moisture ingress. Take weatherproofing seriously to avoid replacing components.
  • Use weatherproof enclosures for your Pi and relay boards. IP65-rated boxes work well.
  • Solder connections rather than using breadboards for long-term setups. Breadboard connections loosen over time.
  • Seal wire entry points with silicone sealant or cable glands to prevent moisture ingress.
  • Keep wire runs short to minimize signal noise. Use shielded cable for runs longer than 2 meters.
  • Strain-relieve cables where they enter enclosures to prevent wire fatigue from wind movement.