Questions about soil moisture sensors (YL-69)

I'm doing an automatic watering project where low power consumption and low cost are important. I'm planning to use YL-69 soil moisture sensors but I have a few questions about them:

1- When it comes to analog reading it looks to my [amateur hobbyist] eyes that this guy actually does nothing. VCC is connected to a 10K resistor, resistor connected to one "leg" of sensor and the other leg is connected to ground. This creates two series resistors: soil + 10K. And analog output is just the voltage at the 10K resistor. So I don't know why I should even pay money for this when I can make something (probably even better quality) with a couple nails and a 10K resistor. I might even be able to get my hands on some galvanized sheets. Is there any reason I shouldn't DIY it?

Specially because I need to minimize current draw as much as possible, and if I'm doing analog reads then the comparator will be drawing unnecessary current. (I'm planning to only turn on the device when I want to measure, but still).

2- Everywhere it is stated the input voltage is 3.3-5v. Now the only real component that this guy has is a LM393 comparator. The datasheet of LM393 says it has an input voltage range of 2-36 volts. So I don't understand where 3.3-5v is coming from. If I decided to use the digital output, is there any reason I shouldn't give this guy 2.5-3 volts? Because I'm planning to use a couple of AA batteries and they're gonna provide somewhere between ~2.5-3 volts depending on how depleted they are.

have you had a look at YL-69 or HL-69 with Arduino

Yeah I know how to use the module.

I wanted to know 1- Can I DIY one with a couple galvanized conductors? Because the "circuit" seems to be just a 10k resistor. 2- Can I power it from 2.5-3volts?

pourduino: Yeah I know how to use the module.

I wanted to know 1- Can I DIY one with a couple galvanized conductors? Because the "circuit" seems to be just a 10k resistor. 2- Can I power it from 2.5-3volts?

What have you tried?

try the experiment! compare your results with the YL-69

Let us know the results.

Idahowalker: What have you tried?

I have tried measuring moisture with VCC from 2.5v to 5v:

Analog output works at any voltage, as expected from a simple resistor. It will vary with varying VCC but given that I can measure the VCC in MCU that won't be a problem. Digital output, as per the datasheet, works from 2v up (I didn't try the maximum 36v). Just below 2volts the comparator stops working.

And I think I now know the answer to the 2nd question "Why everywhere it says 3.3v-5v input voltage". Because the HIGH output of the comparator is slightly below VCC. If you give it less than 3.3v chances are your MCU will register the HIGH as LOW. Also if you give it more than 5v the HIGH could damage an MCU. So they put those values for the average user.

horace: try the experiment! compare your results with the YL-69

Idahowalker: Let us know the results.

Wait a minute, I was trying to get you guys to do the dirty work for me. Now I'm ending up doing the dirty work for you! ;D

But seriously, I asked in order to make sure there isn't anything tricky involved in here that I'm not aware of. Because I don't have electronics education and sometimes I think I've "discovered" a simpler solution but I end up learning I was naive.

I'm gonna try the nail solution and acquire some long-term data and post the results here. It might take a little while tho.

It's plausible - I have seen garduino projects described that did it this way. Cheap to replace when they corrode too.

You dont need a fancy gadget you can do this with 4 additional components, as I have done, powered entirely from the arduino; and make your own probes.

http://www.skillbank.co.uk/arduino/moisture.htm

Doing it that way you can also make measurements at timed intervals so the additional current demand is limited.

johnerrington: You dont need a fancy gadget you can do this with 4 additional components, as I have done, powered entirely from the arduino; and make your own probes.

http://www.skillbank.co.uk/arduino/moisture.htm

Doing it that way you can also make measurements at timed intervals so the additional current demand is limited.

Nice thing you did with alternating current to minimize corrosion. Also it hadn't occurred to me before that with this method I can just use the MCU pins directly and won't need even a transistor! It's perfect for my use case. And very nice point about the system getting more sensitive as Rx approaches R, hence the need to use a lower resistance. This was very useful, thank you.

My pleasure. Its great to get positive feedback.

The main problem with resistance soil moisture sensors are that they are affected by corrosion (thus the good suggestion above to reverse the polarity) and that they are very sensitive to soil salinity.

You might want to look into building a capacitance sensor which is less sensitive to salinity, such as https://www.hackster.io/Pedro52/arduino-capacitive-soil-moisture-sensor-diy-with-esp32-d7ad72. Disclaimer, I haven't tried this but capacitance sensors are the most common commercial sensors (but not as good as Time Domain Transmission).