
1. Introduction
The Capacitive Soil Moisture Sensor measures the moisture content in soil using capacitive sensing, which is more durable than resistive sensors. Since it gives an analog output, we use the MCP3008 to interface it with the Raspberry Pi.
2. Components
- Raspberry Pi 4 Model B
- MCP3008
- Capacitive Soil Moisture Sensor
- Breadboard
- Jumper wires
3. Circuit and Connections
 |
| MCP3008 ADC Pinout Diagram |
Sensor to MCP3008
| Sensor Pin | Connection |
|---|
| VCC | 3.3V |
| GND | GND |
| AOUT | MCP3008 CH0 |
MCP3008 to Raspberry Pi (SPI Connection)
| MCP3008 Pin | Function | Raspberry Pi Pin |
|---|
| 16 | VDD | 3.3V |
| 15 | VREF | 3.3V |
| 14 | AGND | GND |
| 13 | CLK | GPIO11 (SCLK) |
| 12 | DOUT | GPIO9 (MISO) |
| 11 | DIN | GPIO10 (MOSI) |
| 10 | CS/SHDN | GPIO8 (CE0) |
| 9 | DGND | GND |
4. Detailed Step By Step Circuit Working
- Sensor measures soil moisture based on capacitance
- Output voltage changes with moisture level
- MCP3008 converts analog voltage to digital value
- Raspberry Pi reads digital data via SPI
- Higher value → Dry soil, Lower value → Wet soil
5. Libraries to be Included
6. Code (Python)
7. Detailed Step By Step Code Working
- Reads analog value via MCP3008
- Converts to digital (0–1023)
- Compares values to determine moisture level
- Prints status (Dry / Wet)
- Loops continuously
8. Tips
- Do not power with 5V (use 3.3V)
- Avoid immersing full sensor in water
- Calibrate values for your soil type
- Use corrosion-resistant sensor (capacitive type)
- Keep wiring short
9. Uses
- Smart irrigation systems
- Agriculture automation
- Plant monitoring
- Greenhouse control
- IoT farming projects
10. Conclusion
The capacitive soil moisture sensor is reliable and long-lasting. With MCP3008, Raspberry Pi can easily monitor soil conditions for smart agriculture systems.