Soil moisture sensor

I'm planning an indoor garden that will be automatically watered based on soil moisture readings. The moisture sensor will be a voltage divider type:

+-----////----+----| |-----+
d1 r1 a1 probes d2

d1 and d2 are digital out pins, r1 is a 10k ohm resistor, a1 is the analog input.

My question is, can I drive multiple sensors from the same set of d1/d2 pins (using a1, a2, a3, a4, etc)? The resistors would be separate per sense point, but since I'm looking at 15 sense points I'd rather not take up 30 digital pins if I don't have to.

d1 and d2 are digital out pins

Why? Why not use +V and ground?

but since I'm looking at 15 sense points I'd rather not take up 30 digital pins if I don't have to.

You don't. How are you planning on reading 15 analog values, though? With a Mega?

I'm not using V+ and GND because I want to be able to invert the voltage to reduce the wear on the electrodes - my sensors are simple galvanized nails, not anything fancy.

Yes, I am planning on using a Mega - I've also got 15 solenoids and 15 relays to control (for water and lighting respectively), so an Uno just doesn't have the pins.

jwbernin:
I'm not using V+ and GND because I want to be able to invert the voltage to reduce the wear on the electrodes - my sensors are simple galvanized nails, not anything fancy.

Yes, I am planning on using a Mega - I've also got 15 solenoids and 15 relays to control (for water and lighting respectively), so an Uno just doesn't have the pins.

In that case yes, you can drive many such voltage divider/sensor points using a single digital output pin set HIGH. As each divider has a worst case current consumption of .5ma (determined by the 10k resistors) you could safely drive 40 to 60 such points and still be well under the absolute maximum current capacity of 40ma.

Lefty

Thanks, that answers my next question as well! (Can I drive all 15 sense points from one pin set?)

My last question is on the circuit design. Should the resistor be on the high side or the low side of the sense pin when taking the reading? It seems to me it should be on the low side, but the how-to I looked at (and thus the example) has it on the high side (d1 high d2 low for reading, d2 high d1 low for reversal).

jwbernin:
Thanks, that answers my next question as well! (Can I drive all 15 sense points from one pin set?)

My last question is on the circuit design. Should the resistor be on the high side or the low side of the sense pin when taking the reading? It seems to me it should be on the low side, but the how-to I looked at (and thus the example) has it on the high side (d1 high d2 low for reading, d2 high d1 low for reversal).

Well electrically it won't matter, but your readings are not going to be symmetrical (not equal) when taken D1 HIGH D2 LOW Vs D2 HIGH D1 LOW at the same sensor location in either case. A simple 'moisture sensor' as you are using has one very big difficulty and that is 'calibrating' the actual voltage read Vs the actual moisture of the soil. You will have to 'characterize' your readings to determine what readings are equal to 'just right', 'too high', or 'too low'. Plus by driving the sensor current in opposite directions the voltage values will be the inversion of each other, if that makes sense? So you will have to come up with two sets of 'moisture to voltage' values to use in your sketch depending on which direction your sensor current is being driven by your output pins. So you have selected a design trade-off, inexpensive easy and to make moisture sensors that will require enough software tricks to come up with repeatable and reliable control decision points for your application. As I've never worked with trying to measure moisture I can only help with the electrical side, not the calibration or the 'fit for service' question(s).

Lefty

Should the resistor be on the high side or the low side of the sense pin when taking the reading?

You are going to be switching the direction of the current flow. You'll need to experiment to see what readings you get with the current flowing each way, and make sure that you use the appropriate range/limit when the current is flowing each way.

Actually, I was just asking "will it work with the resistor on the high side" - sorry for not being clear. I'm going to write the software such that readings are taken when d1 is high, and not when d2 is high. I'm just inverting the voltage after taking the reading to try to extend the lifetime of the "sensor" parts.

Actually, I was just asking "will it work with the resistor on the high side"

You have a resistor on both sides. The moisture sensor acts like a resistor, too. So, the answer is yes, of course it will work. The value that you read will be different from what you would read if the resistors were reversed.

jwbernin:
I'm going to write the software such that readings are taken when d1 is high, and not when d2 is high.

I did something similar and found it was quite tricky to get meaningful readings out of the sensor. In my case, the best correlation with moisture seemed to occur when I took a reading about 5ms after applying power. Like you, I reversed the sensor polarity after taking the reading to counteract any ionization effects.

Check out this link for alternating current soil moisture measurement:
http://vanderleevineyard.com/1/category/vinduino/1.html

hello my friends. im a newbie on arduino but i've made a soil sensor work and now i need a better calibration, the sensor is a yl-69. I see that he have a p3362 digital potentiometer on it, u think is possible to program that ? So i can adjust its sensibility? if not by programming how then?
Much apreciatted.