a smart indoor irrigation system

15
i A REPORT ON SMART INDOOR IRRIGATION SYSTEM Embedded Systems Design (EEE G512) by Abhijit Hota ---------------------------- 2008A7PS095G BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI April 2012

Upload: abhijit-hota

Post on 18-Jul-2016

48 views

Category:

Documents


1 download

DESCRIPTION

The project deals with the design and implementation of anautomatic plant irrigation system. This system uses an 8-bit 8051 microcontroller based SoC and abasic soil moisture sensor that samples the soil water content at a user defined time interval andcontrols the watering unit if the sampled data crosses the threshold value. The user may changethe sampling rate and threshold moisture content depending on the environmental factors and thetype of sapling or crops planted. The system also provides the functionality to monitor the sourceof water for sufficiency and notifies the user accordingly. (BITS Pilani, 2nd Semester 2011-2012)

TRANSCRIPT

Page 1: A Smart Indoor Irrigation System

i

A REPORT

ON

SMART INDOOR IRRIGATION SYSTEM

Embedded Systems Design (EEE G512)

by

Abhijit Hota

----------------------------

2008A7PS095G

BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI

April 2012

Page 2: A Smart Indoor Irrigation System

ii

TABLE OF CONTENTS

Introduction 1

System Implementation and Components 2

Functioning Flowchart 5

Pin Diagram 6

Code 7

Conclusion 12

Bibliography 13

Page 3: A Smart Indoor Irrigation System

1

INTRODUCTION This project aims to develop a system to automate irrigation/watering of plants installed inside a

household/office space. It samples the moisture content of the soil and automatically waters the

plants to the required amount of saturation. The user just has to input the sampling rate and the

threshold soil moisture content, which can be changed as required, and the system functions

accordingly. It also monitors the sufficiency of water from the source, which could be a reservoir or

a tank, and raises an alert when required. The state of the system is constantly monitored and an

LCD display notifies the current overall status. The system helps save time, prevents unnecessary

water wastage and avoids any inconvenience that is caused by watering the plants manually. It can

be extended to a large scale irrigation system for a complete building or a farm with increased

complexity of watering.

Page 4: A Smart Indoor Irrigation System

2

SYSTEM IMPLEMENTATION AND COMPONENTS

The system is implemented using the PSOC-001 Kit.

Components of the system:

1) 4X4 Matrix keypad.

2) LCD HD4470

3) ADC

4) Soil Moisture sensor.

5) DC Motor.

6) Buzzer.

7) Water level Detector.

8) Push Button

Out of these components, the ADC and LCD are found on the P-SoC development board.

Implementation of various steps and the components used:

1) Input values from 4X4 Matrix keypad:

A lookup table was used to recognize the keys pressed. 4 bits each for rows and columns are

used. At the start, the LCD displays the message “Enter moisture“. Here, the threshold soil

moisture content value (Min = 0 and Max = 63) is entered. Once a number is typed, it can be

deleted using the “D” button of the keypad. Only when key “E” is pressed, the number is

stored. Thus, “E” functions as the confirm button. Once the moisture threshold is entered, the

LCD displays “Enter delay“. A similar arrangement for delete and confirm is available for setting

the delay in sampling. This delay is in seconds and represents the sampling rate.

2) Soil Moisture sensing module:

The soil moisture sensing module basically consists of Resistors and electrodes. Resistors are

used to limit the current. Copper electrodes are used to test the moisture content.

Conductivity of soil at various moisture content is the principle behind the operation.

Page 5: A Smart Indoor Irrigation System

3

From the diagram: Rs = resistance offered between electrodes.

For our system R1= 2k , R2 = 1k , Vcc = 5V

Hence, when there is no conduction (in case of dry soil), Rs = very large, Vsensor = Vcc. And

when the electrodes have no resistance between them (or under complete conduction of soil),

Rs = 0 and Vsensor = Vcc/3. The value of Vsensor is used to determine the soil moisture

content. A look-up table mapping the values of Vsensor at various level of soil water saturation

is used to determine the required threshold.

3) Water level sensor :

This is implemented exactly as the soil moisture sensor. However, we use electricity

conducting plates instead of the electrodes for the sensing mechanism. One of them is fixed at

the bottom (minimum level of water) and the other floats at the water surface level. Whenever

the water level reaches the minimum level, the plates touch and Rs becomes 0 and hence,

Vsensor = Vcc/3 = 1.67 V (in this case). Vsensor value is checked for sufficient water level

indication.

4) ADC module :

The ADC module is inbuilt in the board and is implemented using SAR-6 block in PSoC designer.

The Soil moisture Sensor output, Vsensor, is given as input to the ADC and the output is a 6 Bit

value. Therefore, the ADC output range varies from 0 – 63. According to our system, the

resolution comes out to be 4.88/64 = 0.076 volts. Two ADC modules are used for the moisture

sensor and the level sensor respectively.

5) DC motor : A DC motor is used to water the plants whenever the motor output pin goes high.

The LCD displays “watering“ whenever the motor is on.

Page 6: A Smart Indoor Irrigation System

4

6) Buzzer : A buzzer is used to raise an alert whenever the water level falls below the minimum

level (sensing from the water level sensor). Once the level sensor module detects insufficiency

of water, the LCD displays “no water“ and the buzzer is sounded.

7) Push Button : Once the level sensor module detects for water insufficiency (i.e. Vsensor voltage

value drops close to 1.67V), LCD displays “no water“ and the buzzer is turned on. The user

would need to ensure that the tank is filled and then press the push button to check current

water level. Only if sufficient water is filled (Vsensor voltage close to Vcc), the buzzer goes off

and watering/monitoring starts again.

Page 7: A Smart Indoor Irrigation System

5

FLOWCHART

The working of the system is summarized in the flow chart below :

In flow chart : D = delete , E = confirm , Y = yes , N = no

Page 8: A Smart Indoor Irrigation System

6

PIN DIAGRAM

The pin configuration diagram is shown below : shows all the hardware interfacing with the processor

Page 9: A Smart Indoor Irrigation System

7

CODE

The actual PSoC code in C language using specific APIs to control and interact with various components:

//---------------------------------------------------------------------------

-

// C main line

//---------------------------------------------------------------------------

-

#include <stdlib.h>

#include <m8c.h> // part specific constants and macros

#include "PSoCAPI.h" // PSoC API definitions for all User Modules

void LCD_PrintInt(int val)

{

char str[3];

itoa(str, val, 10);

LCD_1_PrString(str);

}

int input()

{

int row, col, result, final, c;

result=0;

final=0;

while (1)

{

while(result==0)

{

PRT1DR=0xF0;

col=PRT1DR;

PRT1DR=0x00;

PRT1DR=0x0F;

row=PRT1DR;

result=col&row;

switch(result)

{

case 17:result=1;

break;

case 18:result=2;

break;

case 20:result=3;

break;

case 33:result=4;

break;

case 34:result=5;

break;

case 36:result=6;

break;

Page 10: A Smart Indoor Irrigation System

8

case 65:result=7;

break;

case 66:result=8;

break;

case 68:result=9;

break;

case 130:result=10;

break;

case 136:result=11;

break;

case 129:result=-1;

break;

default:result=0;

break;

}

}

if(result<0) //Pressed ‘E’

break;

if(result==10)

result=0;

if(result==11) //Pressed ‘D’

{

final=0;

result=0;

LCD_1_Position(1,0);

LCD_1_PrCString(" ");

}

else

{

final=(final*10)+result;

LCD_1_Position(1,0);

LCD_PrintInt(final);

}

result=10;

while(result!=0) //Wait until button is released

{

PRT1DR=0xF0;

col=PRT1DR;

PRT1DR=0x00;

PRT1DR=0x0F;

row=PRT1DR;

result=col&row;

}

}

return(final);

}

void nowater()

{

char c;

int f=0;

while(f==0)

{

PRT0DR=0xFF;

Page 11: A Smart Indoor Irrigation System

9

if((PRT0DR&0x10)==0x00)

{

Swtch_On();

c = SAR6_2_cGetSample();

c = c-224;

if(c > 32)

{

f=1;

Swtch_Off();

}

}

else

{

Swtch_Off();

}

}

}

void main(void)

{

int moist,delay,current;

char a, b;

M8C_EnableGInt;

LCD_1_Start();//LCD Initialization

LCD_1_Init();

motor_Start();//LED Initialization

buzzer_Start();

SleepTimer_1_Start();//SleepTimer Initialization

SleepTimer_1_SetInterval(24);

SleepTimer_1_EnableInt();

PGA_1_Start(3);//ADC & PGA for moisture Initialization

SAR6_1_Start(3);

PGA_2_Start(3);//ADC & PGA for water Initialization

SAR6_2_Start(3);

LCD_1_Position(0,0);

LCD_1_PrCString("Enter Moist");

SleepTimer_1_TickWait(1);

moist=input();

LCD_1_Position(1,0);

LCD_1_PrCString(" ");

LCD_1_Position(0,0);

LCD_1_PrCString("Enter Delay");

SleepTimer_1_TickWait(1);

delay=input();

LCD_1_Position(1,0);

LCD_1_PrCString(" ");

LCD_1_Position(0,0);

LCD_1_PrCString(" ");

a = SAR6_1_cGetSample();

Page 12: A Smart Indoor Irrigation System

10

a = a-224;

current=(int)a;

while(1)

{

LCD_1_Position(1,5);

LCD_1_PrCString(" ");

LCD_1_Position(1,6);

LCD_PrintInt(current);

if(current>moist)

{

b = SAR6_2_cGetSample();

b = b-224;

if(b < 32)

{

buzzer_On();

LCD_1_Position(0,4);

LCD_1_PrCString("No Water");

LCD_1_Position(1,5);

LCD_1_PrCString(" ");

nowater();

buzzer_Off();

}

motor_On();

LCD_1_Position(0,4);

LCD_1_PrCString("Watering");

LCD_1_Position(1,6);

LCD_PrintInt(current);

while(current>=moist-6)

{

b = SAR6_2_cGetSample();

b = b-224;

if(b < 32)

{

motor_Off();

buzzer_On();

LCD_1_Position(0,4);

LCD_1_PrCString("No Water");

LCD_1_Position(1,5);

LCD_1_PrCString(" ");

nowater();

buzzer_Off();

motor_On();

LCD_1_Position(0,4);

LCD_1_PrCString("Watering");

}

SleepTimer_1_TickWait(1);

a = SAR6_1_cGetSample();

a = a-224;

current=(int)a;

LCD_1_Position(1,6);

LCD_PrintInt(current);

}

motor_Off();

LCD_1_Position(0,4);

LCD_1_PrCString(" ");

}

Page 13: A Smart Indoor Irrigation System

11

SleepTimer_1_TickWait(delay);

a = SAR6_1_cGetSample();

a = a-224;

current=(int)a;

}

}

Page 14: A Smart Indoor Irrigation System

12

CONCLUSION

The system can be implemented for household usage and can be extended to a work in a larger system,

such as a building or a farm. The system implements a soil moisture sensor, a keypad for entering

monitor parameters, a sensor to check for water sufficiency before watering, a buzzer to alert the user,

a LCD display notifying the current system status and a switch to turn off alarm when raised. These

features make the system user-friendly as well as reliable, and the components are easy to set up with

minimal cost.

Page 15: A Smart Indoor Irrigation System

13

BIBLIOGRAPHY

1 .CY8CKIT-001 documentation

2. Analog Electronics : by prof.L.K Maheshwari