Moisture measurement with potential divider

Hi folks,

I came accross this thread on soil moisture sensors:

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

 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

  // drive a current through the divider in one direction

  // wait a moment for capacitance effects to settle

  // take a reading

  // reverse the current

  // give as much time in 'reverse' as in 'forward'

  // stop the current

  return reading;

void setup () {


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 %

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: -

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.

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