Smart Irrigation System using Arduino UNO

Hello everyone, we are back with a new project and we hope you all are doing well. In this article, we will discuss a project named Smart Irrigation System using Arduino UNO. We will use different sensors to measure the environmental and crop parameters which are responsible for good production. We will also make the water pump system automatic which will open the water valve automatically according to the soil moisture of the crop.

We will discuss all points and concepts briefly in this article and also provide a Proteus Simulation to observe how it will work in the real world. Complete fully explained code and simulation are also provided below as you go ahead in this article. You can download it from there.

Smart Irrigation System using Arduino UNO

Let’s start with an Introduction:

Where To Buy?
No.ComponentsDistributorLink To Buy
1LCD 20x4AmazonBuy Now
2LDR SensorAmazonBuy Now
3MQ-135AmazonBuy Now
4Arduino UnoAmazonBuy Now

Introduction 

In the late decades, there has been a quick advancement in Smart Agricultural Systems. Show that agriculture has great importance worldwide. Indeed, in India for example, about 70 % of the people rely upon the vital sector of agriculture. In the past, irrigation systems used to be dependent on the mills to irrigate the farm by conventional methods without knowing the appropriate quantities of these crops.

These old systems are a major cause of the waste of large quantities of water and thus destroy some crops because of the lack of adequate quantities of water. However, with the recent technological developments, there have been innovative systems for irrigation without the farmer interfering in the irrigation process. We will discuss it in brief below.

We will do a simulation on Proteus 8 Professional Software.

Working

The working of this project is like, we will use a Soil Moisture sensor for measuring the moisture of Soil according to which water valves are controlled. When the moisture level gets below a threshold value, valves will open with the help of a relay or solenoid till the soil is well moisturized.

  • The BMP180 sensor will measure the Atmospheric Pressure.
  • The DHT11 sensor will measure the temperature and humidity of the climate.
  • The MQ135 sensor will measure the Air Quality Index of the environment.
  • LDR will measure the sunlight intensity.
  • We will use a 20x4 LCD Screen for displaying the data gathered from the sensors.
  • And the main thing, we will use an Arduino UNO microcontroller as the brain of the project.

In a used case, when the moisture level gets below a threshold value, valves will open with the help of a relay or solenoid for a required time interval.

Block Diagram

  • Here's the Block Diagram of Smart Irrigation System:

Components Required

Here's the list of components used in this project:
  • Arduino UNO
  • BMP180 Sensor
  • DHT11 Sensor
  • LDR Sensor
  • MQ135 Gas Sensor
  • Soil Moisture Sensor
  • 20x4 LCD Display
  • PCF8574 remote 8-bit I/O expander for the I2C bus
  • Breadboard.
  • Jumper wires (Male to Male, Male to Female, Female to Male.)

Since we are designing a prototype of this project, we will use jumper wires instead of soldering.

  • Power Supply

You can use a Battery, Adapter or any DC source of 5-8v(recommendable).

Circuit Diagram

Since we are making a prototype of this project, we will make connections on the breadboard and avoid soldering the components. We will use male to male, male to female and female to female jumper wires. 

Pins Connections

These are the pin connections of all components.
Pin Connections of Smart Irrigation System
No. Sensor Pinout
1 Soil Moisture Sensor Data - A0 (Arduino)
2 LDR Sensor LDR-Resistor Junction - A2 (Arduino)
3 MQ135 Gas Sensor Out - A1 (Arduino)
4 DHT11 Sensor Data - D2 (Arduino)
5 BMP180 Pressure Sensor SDA-SDA (Arduino) SCL - SCL (Arduino)
 

Arduino Libraries Required

You need to install these third-party Arduino Libraries, in order to interface sensors:

  1. Adafruit_BMP085.h
  2. DHT.h
  3. LiquidCrystal_I2C.h

We have added comments in the code for better understanding so it can be understood easily.

Note - Change the Address of the LCD Screen while you run the code in Proteus, change it to 0x20 instead of 0x27 or anyone else. In the real experiment, we can alter the address of the LCD by changing the configurations of A0, A1 and A2 pins of the PCF8574 module.

Proteus Libraries Required

We will show you a demo of this project as a simulation. We are using Proteus 8 Professional Software for the simulation.

Proteus Simulation Connections

  • This potentiometer defines the soil water content in the proteus simulation.
  • When the resistance is maximum at the test pin, the circuit shows zero volts across the voltmeter, which means the sensor is either in the dry ground or taken out of the ground, i.e. giving zero moisture value of the water content.
  • And when resistance is zero, the circuit will show the maximum voltage across the voltmeter which indicates the sensor is inserted in a wet ground i.e. water contents in the soil are too high.
  • This is important. We have attached the output pin with an LC filter. This filter is not required in real hardware implementation.
  • We are using it in Proteus Simulation only as Proteus gives the peak-to-peak value and we have to convert that PP value into Vrms.
  • If you are working on a real sensor then you don’t need to add this LC circuit.
  • Similarly for Gas sensor, as we increase the potentiometer, in simulation it means good air quality.

Steps for Simulation

These are the steps for simulation. Follow them to create a fully working simulation.
  • Download the Zip Files given at the start of this tutorial.
  • Extract them in the LIBRARY folder. You will find it inside the Labcenter Electronics Folder.
  • Go to Arduino IDE and open the code, go to Tools and select the board Arduino UNO.
  • Go to Sketch and Click on Export Compiled Binary. It will create a compiled .hex file of the code which will be used as the main program in the simulation ahead.
  • Open Proteus software and add components by searching like Arduino, DHT11, BMP180, 20x4 LCD, etc.
You can see the components listed here.

Note - We used a simple LED instead of the valve because the valve component is not available in the Software, simply replace the LED with a valve in a real project. Make connections according to the circuit diagram and add virtual terminals to Serial pins to see the readings and Data.

  • Paste the Program File here for all the sensors.
  • Paste the Compiled Binary File as a Program file of Arduino UNO.
  • Run the simulation and you can see the readings by opening the virtual terminal.

Observations and Results

 
  1. In this simulation and project, you can see the sensor's information first in the terminal.
  2. After that, we are getting well organized and easily understood data on the terminal by every sensor according to code.
  3. According to the code, when the value of the soil moisture sensor gets less than a threshold value, the LED gets on.

This means when the soil gets dry the valve will open and water will be provided to the crops.

How to use Arduino PWM Pins

Hello friends, I hope you all are doing great. In today's tutorial, I am going to show you How to use Arduino PWM Pins. It's the next tutorial in our new Arduino Tutorial for Beginners series. We will design a small code in which we will be controlling a dc motor's speed using the Arduino PWM Pins but before going into the details, let me first give you an introduction to Arduino PWM Pins because without understanding the PWM, which is the abbreviation of Pulse Width Modulation, you won't be able to understand How to use Arduino PWM Pins. In our previous tutorial, we have seen How to use analogWrite in Arduino and I have told you in that tutorial that we use this command for PWM as well. So, today we will have a look at How to do that. PWM is an abbreviation of Pulse Width Modulation, its a simple technique in which we just modulate the width of a pulse to get our required results. Suppose, we have a 12V DC signal but my requirement is to get the 6V instetad of 12V so here what I need is PWM. I will use PWM on 12V signal and then reduce it to 6V. Another important thing related to PWM is duty cycle. Duty Cycle is the percentage for which the pulse remains HIGH. For example, if the pulse is of 12V and you turn it into 6V using PWM then the duty cycle of PWM is 50%. I have posted many tutorials on PWM for example you should have a look at How to Generate PWM in 8051 Microcontroller. In this tutorial, I have explained in detail about PWM signal. Moreover, you can also have a look at DC Motor Speed Control using Arduino in which I have controlled the speed of DC Motor with LDR Sensor. Anyways, let's get back to How to use Arduino PWM Pins:

How to use Arduino PWM Pins ???

  • You can download the complete simulation along with its Arduino code for Arduino PWM by clicking the below button:

Download Simulation & Cod

  • First of alll, we should know which pins of Arduino can be used for PWM purposes.
  • So, if you have a look at the below figure, its an Arduino UNO and all the pins of Arduino UNO which has this sign "~" in front of them are PWM pins.
  • If you have a look at the above Arduino UNO image then you can see that "~" this sign is placed in front of six pins.
  • So, Arduino UNO PWM Pins are:
  • Pin # 3
  • Pin # 5
  • Pin # 6
  • Pin # 9
  • Pin # 10
  • Pin # 11
  • Using these PWM Pins, you can create the PWM pulse which we are gonna do rite now. :)
  • So, design a simulation in Proteus as shown in the below figure:
  • As you can see in the above figure that I have used LDR Sensor with Arduino UNO and I have plotted the PWM output coming from Arduino UNO on the oscilloscope.
  • For PWM output the command used in Arduino is:

analogWrite(PWM_Pin, PWM_Value);

  • As, you can see its just an analog Write command and using it you can write any value to the PWM Pin ranging from 0 to 255.
  • At 0 the duty cycle of PWM will be 0% and at 255 it will be 100%.
  • So, what I did in the above example is I just take the analog value coming from LDR and then transferred it to PWM Pin of Arduino UNO.
  • So, now upload the below code in your Arduino board:
int PWMControl= 6;
int PWM_Input = A0;

int PWM_Value = 0;

void setup() {
    pinMode(PWMControl, OUTPUT);
    pinMode(PWM_Input, INPUT);
    Serial.begin(9600);
}

void loop() 
{
    PWM_Value = analogRead(PWM_Input);
    PWM_Value = map(PWM_Value, 0, 1023, 0, 255);
    analogWrite(PWMControl, PWM_Value);
}
  • So, now Get your Arduino Hex File and upload it in your Proteus software.
  • You will also need to download Arduino Library for Proteus, if you wanna use this Arduino UNO in Proteus.
  • Now, if everything goes fine then you will get results as shown in below figure:
  • Now you can see in the above figure that I have shown the PWM pulse in the oscilloscope and now when you change the LDR value then this pulse's PWM will also change.
  • You can download the complete simulation with Arduino code by clicking the button above.
  • If you have any problems or issues in this Arduino PWM tutorial then let me know in comments.
I hope you have enjoyed today's post on Arduino PWM Pins and I would suggest you to have a look at DC Motor Speed Control using Arduino, it will help you a lot in understanding the basic concept of Arduino PWM. So, that's all about Arduino PWM, will see you guys in the next tutorial. Till then take care and have fun !!! :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir