25-08-2016, 09:55 AM
The project is intended to provide proper amount of irrigation to agricultural fields by observing the moisture content of soil. The project automates the process of manually irrigating the fields by switching the pump ON/OFF. It is implemented by using an 8051 series microcontroller, programmed such as to collect input signals that measures moisture content of soil through sensing arrangement. Sensing arrangement is made by inserting two stiff metallic rods into the field at some distance. An op-amp is used as a comparator that interfaces microcontroller and the sensing arrangement. On receiving the signal, the microcontroller produces an output that drives a relay and operates the water pump. Also LCD is used which is interfaced with microcontroller for displaying the moisture content of soil and water pump status. Hence the system reduces human intervention and provides required irrigation to field.
MikroC Source Code :
sbit LCD_RS at LATB7_bit;
sbit LCD_EN at LATB6_bit;
sbit LCD_D4 at LATB5_bit;
sbit LCD_D5 at LATB4_bit;
sbit LCD_D6 at LATB3_bit;
sbit LCD_D7 at LATB2_bit;
sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB2_bit;
// End LCD module connections
double source=0;
int view=0;
char txt[6];
void main() {
ADCON1=0x0D; // Configure RE1 pin as input
CMCON=7;
TRISC.F4=0;
ADC_Init(); // Initialize ADC
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
// char code for degree
// Display "C" for Celsius
while(1){
source=Adc_Read(1);
source=100*source;
source=source/744;
inttostr(source,txt);
if(source>96){
source=100;
}
if(source>83){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,3, "Water!!");
Lcd_Out(2,1, "Hum:");
Lcd_Out(2,5,txt);
Lcd_Chr(2,11,0x25);
Lcd_Chr(2,12,' ');
Lcd_Chr(2,13,' ');
Lcd_Chr(2,14,' ');
Lcd_Chr(2,15,' ');
Lcd_Chr(2,16,' ');
delay_ms(1000);
}
else if(source>40&&source<=83){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,3, "Humid Soil");
Lcd_Out(2,1, "Hum:");
Lcd_Out(2,5,txt);
Lcd_Chr(2,11,0x25);
Lcd_Chr(2,12,' ');
Lcd_Chr(2,13,' ');
Lcd_Chr(2,14,' ');
Lcd_Chr(2,15,' ');
Lcd_Chr(2,16,' ');
PORTC.f4=0; //motor off
delay_ms(1000);
} else{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,3, "Dry Soil");
Lcd_Out(2,1, "Hum:");
Lcd_Out(2,5,txt);
Lcd_Chr(2,11,0x25);
Lcd_Chr(2,12,' ');
Lcd_Chr(2,13,' ');
Lcd_Chr(2,14,' ');
Lcd_Chr(2,15,' ');
Lcd_Chr(2,16,' ');
PORTC.f4=1; // motor on
delay_ms(1000);
PORTC.f4=1;
}
}
}