Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Soil moisture detection using microcontroller

Status
Not open for further replies.

Netra Agadi

Newbie level 4
Newbie level 4
Joined
Dec 18, 2013
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
53
hi guys..
Im doing the project which automatically turn on and off the water pump depending on the moisture content in soil. Im using Microcontroller 8051, programming done in c.
I have designed a circuit for soil moisture detection which I have attached below. the sensor output is given to adc. the sensor works such a way that voltage across sensor is proportional to moisture content in soil. The problem im facing is adc output value is increasing with decrease in voltage at sensor.
help me with this asap plz...
I have attached my code(it just display the adc o/p) too...check it.


Code:
#include<reg51.h>
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit cs=P2^4;
sbit rd=P2^5;
sbit wr=P2^6;
sbit intr=P2^7;
void delay(unsigned int time)
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
void lcddata(unsigned char val)
{
rs=1;
rw=0;
P0=val;
en=1;
delay(5);
en=0;
}
void lcdcmd(unsigned char val)
{
rs=0;
rw=0;
P0=val;
en=1;
delay(5);
en=0;
}
void lcd_init()
{
	lcdcmd(0x38);
	lcdcmd(0x0e);
	lcdcmd(0x06);
	lcdcmd(0x01);
	lcdcmd(0x80);
}
unsigned char adc()
{
unsigned char adc;
cs=0;
//intr=1;
wr=0;
wr=1;
while(intr==1);
rd=0;
adc=P1;
rd=1;
return adc;
}
void main()
{
unsigned char a;
lcd_init();
P0=0x00;
P1=0xff;
cs=0;
rd=1;
wr=1;
intr=1;
while(1)
{
lcdcmd(0x83);
a=adc();
lcddata((a/100)+48);
lcddata(((a/10)%10)+48);
lcddata((a%10)+48);
delay(30);
}
}
 

Attachments

  • plant-soil-moisture-tester-circuit.gif
    plant-soil-moisture-tester-circuit.gif
    6.4 KB · Views: 178
Last edited by a moderator:

Your image is not visible.

- - - Updated - - -

Your circuit is wrong. The transistor BE junction is not forward biased.

What is the voltage you get in DMM when the soil is dry and when soil is moist?
 
Last edited:

You only showed part of the circuit, where is the output that goes to the ADC?

If you only need to distinguish between dry ground and fully soaked ground, your sensor idea could work. When it is for some serious (agricultural) application, DC moisture measurement will not give you sufficient accuracy and repeatability over time.

In case of a serious application that needs to run for long time without human intervention, you need an AC source and very likely a 4 electrode arrangement. In such an arrangement AC current is injected into the ground via two electrodes. The other two are used to measure the voltage across the soil.

Such arrangement enables you to detect when something goes wrong (for example because of electrode corrosion).
 

Moisture Sensor. Adjust the OpAmp circuit depending upon the voltage range you get for dry soil and moist soil.

99979d1387377684-moisturesensor.png
 

Attachments

  • Moisture Sensor.rar
    73.5 KB · Views: 147
  • moistureSensor.png
    moistureSensor.png
    52.3 KB · Views: 169
Last edited:

the problem is with ADC because voltage across sensor is showing correctly.., for wet soil v/g is 2.07v and for dry soil 0.7v. Im getting 000 as adc o/p for 0.7 volts. . what is the possible changes i can make to adc.
thnks all for your response.
 

Amplify 2.07 V to 5V so that 0.7V will be 1.67 V.


Method 2. Provide 1.25 V to Vref/2 pin of ADC using a voltage divider so that for 2.5V adc input adc value will be 255.

100015d1387415997-moisturesensor3.png


100019d1387416935-moisturesensor4.png
 

Attachments

  • moistureSensor3.png
    moistureSensor3.png
    66.8 KB · Views: 157
  • Moisture Sensor rev2.rar
    132.7 KB · Views: 97
  • Moisture Sensor no opamp.rar
    99.3 KB · Views: 150
  • moistureSensor4.png
    moistureSensor4.png
    60.6 KB · Views: 158
Last edited:
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top