Moisture measurement with potential divider

Hi folks,

I came accross this thread on soil moisture sensors:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1255471714/all

I am looking to make my own sensor similar to the shown below:

/*  Soil Moisture measurement v0.1 20091017
 Simple circuit
 Not calibrated at this moment

 Started by Mike Rice, October 14, 2009
 Modified by M.A. de Pablo, October 17, 2009

 Circuit:
 To connect two nails and a 10 KOhms resistor as shown:

        digital 2---*
                  |
                  \
                  /
                  \ R1
                  /
                  |
                  |
        analog 0----*
                  |
                  |
                  *----> nail 1
                 
                  *----> nail 2
                  |
                  |
                  |
        digital 3---*
 */


#define moisture_input 0
#define divider_top 2
#define divider_bottom 3

int moisture; // analogical value obtained from the experiment

int SoilMoisture(){
  int reading;
  // set driver pins to outputs
  pinMode(divider_top,OUTPUT);
  pinMode(divider_bottom,OUTPUT);

  // drive a current through the divider in one direction
  digitalWrite(divider_top,LOW);
  digitalWrite(divider_bottom,HIGH);

  // wait a moment for capacitance effects to settle
  delay(1000);

  // take a reading
  reading=analogRead(moisture_input);

  // reverse the current
  digitalWrite(divider_top,HIGH);
  digitalWrite(divider_bottom,LOW);

  // give as much time in 'reverse' as in 'forward'
  delay(1000);

  // stop the current
  digitalWrite(divider_bottom,LOW);

  return reading;
}


void setup () {
  Serial.begin(9600);

}

void loop (void) {
  moisture=SoilMoisture(); // assign the result of SoilMoisture() to the global variable 'moisture'
  Serial.print("Soil moisture: ");
  Serial.print(moisture); // print the analogical measurement of the experiment
  // later i will improve here a calculation for derive Soil Moisture in %
  Serial.println();
  delay(1000);
}

My question is:

By alternating the flow of current through the two digital pins and due to position of the resistor to the analogue pin, will you not get differing analogue readings depending on which way the current is flowing?

If you look into function, there is only one reading, when current goes in one direction. For reverse "equilibration" period no readings performed, just delay.

Ahh OK of course, that was silly.

Thank you

I came accross this thread on soil moisture sensors: - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1255471714/all

I am looking to make my own sensor similar to the shown below:

I'm interested in your results, so if it works can you share therm ?

For those reading this and wondering "Why reverse the current?"...

It is done to undo the electrolysis phenomena which otherwise begin to cause problems.

robtillaart - Will keep you updated on the results. Busy with a few other things so may not be in the near future. Watch this space though

Hi Buycris,

I used this method for a long time, but there is a clear problem with electrolysis.

Few weeks ago i build a new version of the soil moisture sensor based on the new model proposed by GardenBot. Here you have the link to the sensor what use reverse current and double measurement to measure soil moisture and reduce as much as possible the electrolysis. http://gardenbot.org/howTo/soilMoisture/

I stil didn´t have time to conect it to my arduino to start to measure, but i suposse that it will be more efective, i guest.

Enjoy! M.A. de Pablo