---
title: PROJECT 37. SMART IRRIGATION SYSTEM
description: "1. **[Introduction](http://Introduction)** If you work in the agriculture sector, you understand how challenging it can be to determine the right time to water your plants and whether the soil has enough moisture to stop watering. The irrigation system you use…"
url: "https://nedu.rw/documentation/project-37-smart-irrigation-system/"
updated: "2026-10-13"
category: InnoKit MPK A100 / Experiments you can do with MPK A100
---

# PROJECT 37. SMART IRRIGATION SYSTEM

1. **[Introduction](http://Introduction)**

If you work in the agriculture sector, you understand how challenging it can be to determine the right time to water your plants and whether the soil has enough moisture to stop watering. The irrigation system you use plays a crucial role in the healthy growth of your plants. This is why implementing a smart irrigation system is essential for modern agriculture.

1. **[Objectives](http://Objectives)**

- Detecting the amount of water which is inside the soil.
- Turn on and off the irrigation system depending on the water needed in soil.

1. **[Components to be used](http://Components to be used)**

- MPK kit
- Capacitive Soil moisture sensor
- 12V Adapter supply
- 12V Pump

| ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfPL1tOlZJsAu38FUCpdBPVPxRM5fC5vS9K8BygSIZyrlqxNUbQMuNJvSpG6V64GjTHF7Iq_oxGYgbfzvZoPMnbPHzm4e7DxGwyhwwi7IwPHrZAxlvDKb_HBZHa7816bb_Pb6UZByYOw1ddQjxm7Z8SMMcF0AKRQy_M1IQi690Fyh2L?key=EIFaBMwRIuJeDoZo9taXbw) | ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfDrhlYJRlLkfodeVMWycsMaox9WNfvbHc6qSZvUax3N8Uf4OPzQK8Yye6zCNcZekNb7YG6rZYAhf1vNhDSVpS6bYChKUavAgIY2dsxRWDQwcGr7mOsW8g0eLxIgV1v0h4cCpsbSwC2D2JpCh_Ss01B6tg-u81orKhQ6Qglsm97T2zO?key=EIFaBMwRIuJeDoZo9taXbw) |
| --- | --- |
| ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeQov2vfFELuAuYe_ARKuPkr2L-va7Vqy3B0zAD43mipOOlWpFiVO2fftki2PAnuxiCxq8Nn1ZRIdRKxNE3wfJ4Yp3XciqRSpaQEyxoGVnKtf4iwrFL0_N1LTOSsbGPH6qNIXLEwF_dBceEo_HvpAzL58ZSA2Xz3R2MhFEB3uhNiog?key=EIFaBMwRIuJeDoZo9taXbw) |  |
| ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXflwrElZQSItDTQ9ZBQU5VWRQ2vT9ye9JeDlqhnHO2gCo5gaRmceyme8oZaiMsS7oYT82hCa5sH3p6eVYLBABq19avehKKg6YTWjVeIcVq74ciLjlbGjf8ccWFTOcNg2O3KEyyYUo2LImRIYT_rw2kzUFsaHzR1XydL8PdwzjN9PNel?key=EIFaBMwRIuJeDoZo9taXbw) |  |

1. **[Circuit diagram](http://Circuit diagram)**

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcQoNzPcnlgUDE9j0QrVg5Q1RgyMaNjlnQD7vtWhwUgZsODQkdNE294kFY5PuRKOaTw8MEPzQn27YUpcFsOjCArDXYi4pzy4U7hSXGYJSk5xkLpZQqPs5AzK_rXnFd0BXCJTo1YOJQtfYqA?key=EIFaBMwRIuJeDoZo9taXbw)

***Figure: Schematic soil moisture sensor and relay connection***

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeQRK-xwKXxXB6QxMg2UyIviW4spekJJKVv7H3ltRmBGS-J_EiC7srH6V7OGzelkG_BP6mYJdSGk1FTraJqCUImeA1rEGzo8LgKpNHpy3CGk5SzrVhjIwKUT6mQqZ0bl_ufNtr0dq9UmdFe79Ctl5yv2Re_kSOz8HU-kyNLI2LsP9A?key=EIFaBMwRIuJeDoZo9taXbw)

***Figure: Components used to make connection on the board***

1. **[Arduino codes](http://Arduino codes)**

    12345678910 11121314151617181920 21222324    #define RELAY_PIN 2 // The Arduino Nano pin that connects to relay #define MOISTURE_PIN A6 // The Arduino Nano pin that connects to AOUT pin of
moisture sensor #define THRESHOLD 530 // CHANGE YOUR THRESHOLD HERE
 voidsetup() { Serial.begin(9600); pinMode(RELAY_PIN,OUTPUT); }
 voidloop() { int value =analogRead(MOISTURE_PIN); // read the analog value from sensor if (value > THRESHOLD) {  Serial.print("The soil is DRY => turn pump ON");   digitalWrite(RELAY_PIN, HIGH); }else{  Serial.print("The soil is WET => turn pump OFF");  digitalWrite(RELAY_PIN, LOW); } Serial.print(" ("); Serial.print(value); Serial.printIN(")"); delay(500); }

1. **[Code knowledge](http://Code knowledge)**

This Arduino code is designed to control a water pump based on soil moisture levels. Here's a breakdown of how it works, step-by-step:

### **Code Breakdown:**

   13141516171819    if (value > THRESHOLD) {  Serial.print("The soil is DRY => turn pump ON");   digitalWrite(RELAY_PIN, HIGH); }else{  Serial.print("The soil is WET => turn pump OFF");  digitalWrite(RELAY_PIN, LOW); }

- If the moisture value is above the threshold, the code considers the soil dry and:
  - Prints "The soil is DRY => turn pump ON" to the Serial Monitor.
  - Activates the pump by setting **RELAY_PIN** to **HIGH**.
- If the moisture value is below the threshold, the soil is considered wet, and:
  - Prints "The soil is WET => turn pump OFF" to the Serial Monitor.
  - Deactivates the pump by setting **RELAY_PIN** to **LOW**.

    20 212223    Serial.print(" ("); Serial.print(value); Serial.printIN(")"); delay(500);}

- The code prints the sensor value in parentheses on the Serial Monitor, showing the exact reading, which helps with debugging or adjusting the threshold.
- **delay(500):** Pauses the code for 500 milliseconds before the next reading. This allows for a half-second delay between moisture readings.

1. **[Results](http://Results)**

In this project a relay is controlled based on the soil moisture level and provides feedback via the Serial Monitor. Here's what to expect:

***1. Serial Monitor Output***

Every 500 milliseconds, the Serial Monitor displays:

- A message indicating whether the soil is dry or wet.
- The current sensor reading value.

*Examples:*

- If the sensor reading is greater than the threshold (e.g., 600):

*The soil is DRY => turn pump ON (600)*

- If the sensor reading is less than or equal to the threshold (e.g., 450):

*The soil is WET => turn pump OFF (450)*

***2. Visible Output***

The relay connected to the Arduino pin will:

- Turn ON (activate) when the soil is dry (sensor value > threshold).
- Turn OFF (deactivate) when the soil is wet (sensor value
