Promini ADC read moisturesensor not correct

Hello,

i'n doing a watering system for plants. My sensor is built of 2 parralel nails (around 50k resistance) and an 1k resistor to ground (see picture).

Therfore the ADC reading is from around 300-900.

But I got a problem with fluctuating readings.
For example with the actual really dry pot:

In the beginning he reads around 540 then each next reading decreases until it settles at 300.

When I add a 10 or 20 second delay (depends on the sketch) it reads correctly from the beginning:

Just to mention:
I did not put the sensor on Vcc because of electrolysis. Therefore I do enable an Dout of the arduino shortly before reading to give power to the sensor.

Both of these give the same good results:

----------------------------------------------------

void setup() {
Serial.begin(115200);
pinMode(A0, INPUT);
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
analogRead(A0);
}

void loop() {
delay(0);
digitalWrite(2, HIGH);
delay(10000);
Serial.println(analogRead(A0));
digitalWrite(2, LOW);
}

----------------------------------------------------

void setup() {
Serial.begin(115200);
pinMode(A0, INPUT);
pinMode(2, OUTPUT);

digitalWrite(2, HIGH);
analogRead(A0);
digitalWrite(2, LOW);
delay(20000);    					// Needs to be 20000 instead of 10000 to be the same accuracy as the sketch above
}

void loop() {

digitalWrite(2, HIGH);
Serial.println(analogRead(A0));
digitalWrite(2, LOW);
delay(200);                                               //  Tested even after 15 min of waiting before reading the second time and worked
}

So why do I need such a long delay and is there a better way?

I also thought of using a 47R resistor instead 1k to get "dry" value lower to zero then adding an OPAmp with 5x amplification to broaden the reading. but would prefer not to need that.

Also maybe does the Dout of the Arduino not deliver enough current maybe?

Any Idea?

ADC Verlauf - Schaltung.png

it reads correctly from the beginning

Why do you say that the settled reading is correct and the initial reading is not correct? Allowing the current to flow for some time is clearly affecting the sensor probes or the soil between them. So maybe the initial reading is correct and the "settled" reading is incorrect because it had been affected by prolonged current flow. Who can say which reading is more correct?

I found the same effect using resistive soil moisture probes very similar to yours. I decided to enable the voltage for the shortest time possible, take an immediate reading and disable the voltage again. I find the readings taken this way indicate the soil moisture level "correctly" enough to indicate when watering is required.

Here is the reading from my sensor over the last week. The readings are scaled from 0 to 100 (=1023 ADC reading).

I must water the plants!

Because the first reading decreases until it settles forever therefore the last should be the correct on in my opinion.

Also I had it run with the short measurements but it worked just for a short period of time (3 days or so) then it watered the hell out of the pots, because the readings dropped down more and more (that's why I want to change it to be more correctly).

Also.... My other Idea to lower the sampling rate of the ADC to get better results but I don`'t know how to do that and could not really find anything about that by googling.....

Thankyou for your opinion. For the moment, I will keep an open mind.

My plan is to take a reading every 15 minutes, and if the moisture level is below a threshold, water for perhaps 30 seconds or 1 minute, then wait a further 15 minutes before taking another reading, to allow the water to penetrate the soil.

The difficulty with resistive soil moisture probes is that the process of measuring changes the soil and the probes.

The soil contains salts and other minerals that are involved in reduction/oxidation (redux) reactions in the presence of electrical current. These reactions change the resistivity of the soil beginning immediately the probes are in the soil in the presence of moisture.

The probes suffer from electrolysis which in a few days or weeks changes the surface of the probe so that it's resistivity at the probe/ground interface changes constantly, and not in a linear fashion. Before electrolysis affects the probes, they also suffer from changes in their electrical conductivity with respect to the ground interface, because of the redux reactions that occur at the surface of the probe. the probes are metal and the salts in the ground moisture are metals (chemically), and when dissimilar metals are together in the presence of moisture, one metal will reduce and the other will oxidise, due to differences in their nobility.

These issues are why capacitive probes are most commonly used in commercial designs. To a limited extent, the degradation of the probes can be extended by switching the power on and off as you have seen. That doesn't help with the other issues noted above. Some people have had success by alternately powering the probes in reversing directions - positive -negative in one sample, negative positive the next time. Your approach of not putting the sensor on VCC does not help because the ground / probe interface does not care which way around you have the polarity. It will happily cause the same problem in either direction. The only thing that matters is some current flows through some moisture in some direction.

While resistive probes are interesting to experiment with, they will not provide a stable reading over time. If the problem matters more than the experimenting, then I suggest capacitive probes are the way forward.

Because the first reading decreases until it settles forever therefore the last should be the correct on in my opinion.

Due to current flow and resulting chemical reactions, the resistance between the nails is changing with time.

There is no way to know whether any of the readings correspond to the "true" soil resistance.

Ok I assumed so but I also assumed my very short powering will make this take forever until I see any mattering value on this....

But this spike in the beginning can't really be caused by that since once read the ADC one time then it never occurs again even if I wait one hour between the measurements....

But when I restart the Arduino it instantly occurs again....

Gorkde:
once read the ADC one time then it never occurs again even if I wait one hour between the measurements....

But when I restart the Arduino it instantly occurs again....

I see. That is different to my experience. The different initial reading and settled readings I have seen occur every time I energise the sensor, even with only a minute between readings.

How long and far apart are your nails?

My sensors are steel nails about 11cm long and 5mm diameter.
But it semms really to be to unrelyable to work with.

Sometimes he waters the hell out of the plants after days and now I did another test with different values in my sketch and he read to high values after a day so the plant is drying out.

Can anybody recommend a capacitive sensor from Aliexpress that is not so wide and works well?

Something like this:

If not which other can you reccomend? There are some with only a transistor on it others have an IC on it. Where is the difference?

If you look through this forum, soil moisture sensors come up frequently. None of them seem to work very well, if at all.