I read a long time ago that someone just uses nails in a moisture detector as part of a resistor dividor.
The trick he applied was not to use 5V + GND but two digital pins [A, B] as 5V and GND . The measurements alternated the current so the oxydation process was partly compensated. The voltage was switched off [A&B both LOW] when there was no measurement in progress.
something like this
PIN A -------NAIL1 NAIL2 ------AnalogIn ------[Resistor] ---- PIN B
code would look like
int getMoisture()
{
static int n = 0;
int rv = 0;
n = 1 - n;
if (n == 0)
{
digitalWrite(PINA, HIGH);
rv = analogRead(A0);
digitalWrite(PINA, LOW);
}
else
{
digitalWrite(PINB, HIGH);
rv = 1023 - analogRead(A0); // reversed read => reversed value;
digitalWrite(PINB, LOW);
}
return rv;
}
hopes this helpes