Skip to content

Meet the humble irrigation system that keeps your plants happy and hydrated! With real-time air data, water level LEDs showing how full your tank is, and cloud connectivity for remote monitoring, it’s got your watering needs covered—no more guessing, overwatering, or dehydration!

Notifications You must be signed in to change notification settings

faithByte/Smart-Irrigation-System

Repository files navigation

Smart Irrigation System

Project Overview:

A cutting-edge solution for precision agriculture. With real-time air data displayed on an LCD screen, LED indicators for water level in tanks, and seamless cloud connectivity for remote monitoring, our system ensures optimal irrigation management.

Table of Contents

Part 1: Irrigation System

In this part we are gonna assemble the components and develop a code to enable the arduino to collect soil moisture data in order to determine whether to turn on or, off pump. Upon detecting a low moisture level, the Arduino must intervene by activating the pump to supply water for the plant.

Equipments

I- Soil Moisture Sensor:


1. Introduction:

A soil moisture sensor is capable of measuring the moisture content in the surrounding soil. It proves to be a valuable tool for keeping track of your garden or plant's water levels, making it an essential component of a smart garden.

soil moisture sensor

This sensor employs two probes to transmit current through the soil and subsequently gauge the resistance to determine the moisture level. Increased water content enhances soil conductivity, resulting in easier electricity flow (lower resistance), whereas dry soil exhibits poor conductivity, leading to higher resistance.

2. Specifications:

  • Required voltage for working: 5V
  • Required current for working: <20mA
  • Required working temperature: 10°C~30°C
  • Type of interface: Analog
  • Depth of detection: 37mm

3. Mounting:

soil moisture sensor mounting

4. Code Functions:

In order to use our moisture sensors it is necessary for us to perform a calibration process. It appears that each of these devices possesses its qualities and even sensors obtained from the same batch may have varying characteristics.

💡 Sensor Calibration: Calibration is a straightforward procedure involving determining the sensor's analog output under two conditions:

Dry Value - Exposed to air with minimal humidity.

Wet Value - Completely submerged in water.

  • The calibration code is quite simple. In our code, we merely read the sensor value and print it to the serial monitor. After a brief pause, we repeat the entire process:

    #define sensor_pin A0
    
    void  setup() {
    Serial.begin(9600);
    }
    
    void  loop() {
      int  sensor_analog = analogRead(sensor_pin);
      Serial.println(sensor_analog);
      delay(1000);
    }

    Run the code and keep an eye on the serial monitor. Record the values in both damp and dry environments.

Dry Value

serial monitor dry value

Wet Value

serial monitor wet value

1- Read sensors values:

moistureValue = analogRead(moistureSensorPin);

2- Determine soil moisture percentage:

moisturePercentage = map(moistureValue, DryValue, WetValue, 0, 100);

3- Make sure that the value is between 0 and 100:

moisturePercentage = constrain(moisturePercentage, 0, 100);

II- Relay:


1. Introduction:

The 5V relay is an electromechanical switch that enables the Arduino Uno to regulate devices, such as water pumps, based on low-power signals. In the smart irrigation system, the relay serves as the interface between the Arduino Uno and the irrigation mechanism, enabling the automated activation and deactivation of the pump.

relay 5v

2. Specifications:

  • Required voltage for working: 5V
  • Type of interface: Digital

3. Mounting:

relay mounting

4. Code Functions:

  • Turn on the relay :
digitalWrite(relayPin, LOW);
  • Turn off the relay:
digitalWrite(relayPin, HIGH);

III- Pump:


1. Introduction:

A soil moisture sensor is capable of measuring the moisture content in the surrounding soil. It proves to be a valuable tool for keeping track of your garden or plant's water levels, making it an essential component of a smart garden.

pump

2. Specifications:

  • Required voltage for working: 5V
  • Required current for working: 130-220mA
  • Flow rate: 80-120L/H

3. Mounting:

pump mounting

4. Code Functions:

By operating the relay we have the ability to manage the pump. When the relay is deactivated the pump turns OFF. When it is activated the pump starts running.

Mounting

irrigation system mounting

Part2: Humidity and Temperature Display

In this part the arduino system is equipped with a sensor that measures the temperature and humidity of the air. These data are then displayed on an LCD screen integrated into the device.

Equipments

I- DHT11:


1. Introduction:

The DHT11 is a temperature and humidity sensor widely used in electronic projects. It can measure both the ambient temperature and the relative humidity of the environment in which it is placed.

  • Temperature Measurement: The DHT11 sensor can provide an accuracy of ±2°C in the temperature range of 0°C to 50°C.

  • Humidity Measurement: The DHT11 sensor can provide an accuracy of ±5% in the humidity range of 20% to 80%.

DHT11

2. Specifications:

  • Required voltage for working: 3.3V to 5V

3. Mounting:

DHT11 mounting

4. Code Functions:

  • Include the necessary library DHT:
#include "DHT.h"
  • Initialize the DHT sensor:
DHT dht(4, DHT11);

dht.begin();
  • Read the humidity and temperature:
humidity = dht.readHumidity();
temperature = dht.readTemperature();

II- LCD 16x2 I2C:


1. Introduction:

This module combines a 16x02 LCD screen with an I2C interface module. The I2C module helps reduce the number of wires needed to connect the display to the Arduino.

LCD 16x2 I2C adapter

~ After soldering:

LCD 16x2 I2C front LCD 16x2 I2C back

2. Specifications:

  • Required voltage for working: 5V
  • Adresse I2C : 0x27

3. Mounting:

LCD I2C mounting

4. Code Functions:

#include<LiquidCrystal_I2C.h>
  • Set the LCD address to the LCD default address (0x27) for a 16 characters and 2 lines display (LCD 16x2):
LiquidCrystal_I2C lcd(0x27,16,2);
  • Initialise and clear the display:
lcd.init();
lcd.clear();
lcd.backlight();
  • Set cursor on (X[column],Y[row]):
lcd.setCursor(X, Y);
  • Print on the LCD:
lcd.print("Hello World!");

Mounting

DHT11 & LCD mounting

Part 3: Monitoring the water level in the tank

This part aims to monitor the water level in a reservoir by measuring the distance between the sensor and the reservoir bottom. Based on this water level, I programmed a visual indicator using an RGB LED, which changes color to reflect the water level variation. When the level is low, the LED displays a red hue, then transitions to orange, yellow, greenish, and finally green when the reservoir is full. This approach provides a clear and intuitive visualization of the water level, making reservoir supervision easier without requiring constant physical inspection.

Equipments

I- HC-SR04:


1. Introduction:

HC-SR04

This sensor is used to calculate the distance to an object.

  • Calculating the distance using HC-SR04 We determine the time required for the sensor to reach the object and return, allowing us to calculate the distance using the following formula:

$$ Distance = Time × SpeedOfSound $$

We know that SpeedOfSound = 340m/s = 0.034cm/µs

So the formula becomes:

$$ Distance = Time × 0.034 $$

💡Note:

We measure the pulse duration of the wave emitted by the HC-SR04, which corresponds to twice the time it takes for the sensor to reach the object and return. So in order to get the real distance between the sensor an the object you need to devide by 2.

$$ {Distance = (Time × 0.034) \over 2} $$

2. Specifications:

  • Required voltage for working: 5V
  • Required current for working: 15mA
  • Frequency: 40kHz
  • The range: 2cm to 4m
  • Ranging Accuracy: 3mm

3. Mounting:

HC-SR04 mounting

4. Code Functions:

  • The length of the pulse (in microseconds) or 0 if no pulse started:
pulseIn(echoPin, HIGH)

II- LED RGB:


1. Introduction:

LED RGB Resistance

In order to mount an LED, resistors are needed to limit the amount of current flowing through the LED and prevent it from burning out.

  • We can use Ohm's Law to calculate the resistance (R) needed:

$$ R = {V_{source} - V_{LED} \over I_{LED}} $$

Vsource is the supply voltage.

VLED is the forward voltage drop of the LED.

ILED is the desired current through the LED.

$$\eqalign { R_{R} &= {5V - 2V \over 0.02A} \\ &= 150Ω }$$

$$\eqalign { R_{G} &= R_{B} \\ &= {5V - 3V \over 0.02A} \\ &= 100Ω }$$

So we gonna use one resistor of 150Ω and 2 resistors of 100Ω.

2. Specifications:

  • Required voltage for working: R:2-2.2V | G:3-3.2V | B:3-3.2V
  • Max current: 20mA

3. Mounting:

LED RGB mounting

4. Code Functions:

-Write an analog value to a pin (turn it on or off).

analogWrite(ColorPin, x);

x between 0 - 255.

Mounting

HC-SR04 & RGB mounting

⚠️ Attention:

Prior to initiating the system, the HC-SR04 should be positioned atop the tank, and the tank must be empty.

Part4: Integrating IoT with Project Components

During this phase, our objective was to seamlessly link all previously developed systems, while integrating IoT through the inclusion of an ESP01 module. This component plays a pivotal role in integrating communication with the cloud, specifically leveraging the Blynk cloud platform. This strategic maneuver facilitates extended connectivity, granting the ability to remotely monitor and control the system.

Equipments

I- ESP8266 - ESP01:


1. Introduction:

ESP8266

The ESP8266 ESP-01 is a compact and affordable Wi-Fi module used for adding wireless connectivity to electronic projects. It's part of the ESP8266 family and is popular for IoT applications due to its small size, low cost, and ease of use.

2. Specifications:

  • Required voltage for working: 3.3V
  • Protocol: TCP/IP
  • Serial/UART baud rate: 115200 bps

3. Mounting:

ESP8266 mounting

4. Code Functions:

  • Print data to the ESP8266 serial monitor:
espSerial.println(data);
  • Read bytes from the ESP8266 serial port into a buffer with a specified buffer size:
espSerial.readBytes(buffer, bufferSize);

5. Blynk Functions:

  • Initialize Blynk with authentication token, Wi-Fi network name, and password:
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  • Check if the device is currently connected to the Blynk server:
  Blynk.connected();
  • Execute the Blynk main processing loop:
  Blynk.run();
  • Send data to a virtual pin in the Blynk app:
Blynk.virtualWrite(PIN, data);
  • Handle a virtual pin write event in the Blynk app:
BLYNK_WRITE(PIN)
{}

II- CH340 Adapter:


1. Introduction:

CH340

The CH340 is a USB to serial converter chip commonly used in microcontroller applications. When paired with the ESP01 module, it enables easy communication between the module and other devices via USB, enhancing functionality in IoT and embedded systems projects.

📝 Note:

You need to install CH34xSER driver to program your ESP using the CH340 Adapter.

To program your ESP follow the next tutorial.

Mounting:

System Mounting

Results:

IOT integration:

IOT


Air temperature & humidity

Air temperature & humidity


Water Level

Water Level


Pump

Pump


📝 Note:

The schems are made using fritzing.

The material and the images are from micro-planet and marocproduit

About

Meet the humble irrigation system that keeps your plants happy and hydrated! With real-time air data, water level LEDs showing how full your tank is, and cloud connectivity for remote monitoring, it’s got your watering needs covered—no more guessing, overwatering, or dehydration!

Topics

Resources

Stars

Watchers

Forks

Languages