Microcontroller Based Soil Moisture Meter |
Grove - Moisture Sensor :
Basically grove moisture sensor is used to measuring the moisture of the soil. It also can be used as water sensor. We can water plants according to its humidity by using the sensor . Look at the sensor pictures and its pin out.
![]() |
Soil Moisture Meter Project Using Microcontroller |
Basic Concepts:
The Moisture sensor will be connected with a pic microcntroller and a LCD display will also be connected with microcontroller . Moisture sensor will provide voltage into microcontroller's RA1 pin(ADC) according to the humidity of soil . It will provide reading from (0-721). After calculating the percentage and soil condition , the microcontroller sends out that data to the LCD Display . That's the basic concept .ADC(Analog to Digital Converter ) :
We need a basic knowledge about ADC . Let's take a look at here :![]() |
ADCON1 Register |
Basically ADC is like as voltage divider . According to voltage It produce output
bit 5 : VCFG0: Voltage Reference Configuration bit (VREF- source)
1 = VREF- (AN2)
0 = VSS or 0 volt
bit 4 :VCFG0: Voltage Reference Configuration bit (VREF+ source)
1 = VREF+ (AN3)
0 = VDD or 5volt
We will set VCFG0[bit 5]=0and VCFG0[bit4]=0 . So we will get highest value 5volt[1023] and lowest value 0volt[0].The ADCON1 is a 10 bit register that means 2 to the power 10 is it's highest counting capacity and result is 1024 . So this register can count from 0 to 1023 . When 0 volt , we get reading at RA1 pin 0 .When 5 volt , we get reading at RA1 pin 1023. It means 5volt equivalent to 1023 .
As we know in water the sensor provide 722 data and absolutely it should be 100% .
If reading 744 means 100 %
So "" 1 "" (100/744) %
and reading % of source reading will be (100/744)*source %
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
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;
}
}
}
Circuit :
![]() |
Microcontroller Based Soil Moisture Meter circuit |
i woul like to know the model no of sensor to implemntit into proteus
ReplyDeleteIt's a groove soil moisture sensor. As far as I concern It's not available in proteus. It's just a sensor gives you voltage in a range of 0 to 5 volt.
Deleteplease if you Can give me The reference of Soil Humidity sensor
ReplyDeleteYou may search online. It's a groove soil moisture sensor.
Deletelink not working, can you fix this?
ReplyDeleteLink had been updated. Sorry for late replay. I couldn't have replied since it was a problem with my template. Thank you.
Deletei use MPlab for coding this but it dont have inttostr fuction? what can i replace it with? or
ReplyDeleteTry to reach guys using MPLab. I guess there might have been an alternative. Thank you.
DeleteIf i wanted to use the PIC16F877A microcontroller as a replacement what changes would you advice especially on the code? thanks in advance
ReplyDeleteIf you pins as same as mine. it should work.
DeleteCAN I HAVE THIS PROJECT WITH PIC16F877A
ReplyDeleteSure. Why not.
Deletecan i have this project in pic16f877a
ReplyDeleteAbsolutely. You can.
Deletecan i get the schematics for the project soil moisture meter using pic18
ReplyDeleteI have given proteus circuit and some instructions. It might have worked.
DeleteThank you so much for encouraging me!
ReplyDeleteThank you too.
ReplyDeletewhat sthe differece between pic16f877a and pic
ReplyDelete18f2550
difference?
DeleteThis is just two microcontrollers from the same vendor.
Deletei did the same experience with pic18f2550..but i dodnt see any think at lcd..whers the probleme?
DeleteIt's supposed to work. It worked fine when I tried in real life.
DeleteHello There. I found your blog using msn. This is an extremely well written article. I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll certainly comeback. בדיקת חומציות
ReplyDeleteThank you so much!
DeleteGoodness, this is truly intriguing perusing. I am happy I discovered this and got the chance to peruse it. Awesome employment on this substance. I like it.
ReplyDeleteOnline Web Hosting Services
Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. soil thermal conductivity testing
ReplyDeleteThat was a really good blog, the information you mentioned in your post is really good and useful. I like your blog please share more information with us.test and tag services Adelaide
ReplyDeleteYour blog is very useful for those who are searching for this kind of information, this information is a solution for those who are confused about it. Thanks for sharing this blog with us.test & tag adelaide
ReplyDeleteCold cache: OK so Cloudinary was 5x faster than CloudFront….because Cloudinary doesn’t really have a cold cache? Because there is no expiration on the files (unless you get Cloudinary’s premium tier).
ReplyDeleteHot cache: I guess this is the metric that really kolkata ff matters, since it’s the most common case that a CDN is going to contain the file. And boy did Cloudinary impress. By compressing the file from ~700 KB down to 36 KB, Cloudinary beat CloudFront by 3x.
LottoAgent has been around since 2012. The company obtained a license from the Government of Curacao. The website employs a Comodo SSL certificate to maximize user safety. It also complies with security standards related to transactions and credit card payments.LottoAgent has been around since 2012. The company obtained a license from the Government of Curacao. The website employs a kolkata ff Comodo SSL certificate to maximize user safety. It also complies with security standards related to transactions and credit card payments.
ReplyDeleteAmazing, what are creative technology. Technology has really changed the world, the data seems to be very interesting. I ill share this with my engineering friends and I am sure they will thank me later. I was actually looking for cheap windows vps hosting, kindly help to find that.
ReplyDeleteMoisture sensor will be connected with a pic microcntroller Buy Custom Essays and a LCD display will also be connected with microcontroller .
ReplyDelete