Go Down

Topic: How to read resistance of sensor with AC? (Read 9347 times) previous topic - next topic


I have a Watermark soil moisture sensor (basically a couple of electrodes embedded in a gypsum block) that I need to read. To stop electrolysis eating away the electrodes, the unit requires an AC voltage and varies its resistance according to the moisture of the soil that it is buried in.

According to the datasheet, it has the following electrical characteristics

? Electrical resistance type sensor, 500 - 30 000 ohms resistance.
? Sensor excitation current is 5 vac, 100 - 120 Hz (square wave).

(The datasheet for the unit can be found here: http://www.hrproducts.com.au/uploads/resources/Watermark%20Sensor.pdf)

Can I connect the the two electrodes to two ADC pins of the Arduino and by switching one pin high and the other low (and then vica versa)at 100 Hz and read the current flow in between switchings?

Has someone got a better idea for simple hardware to read these sensors?



You need to connect one pin to any pin you choose, I'm not sure you can make a 100Hz wave with PWM, but if you can this is the time. So, you connect one pin to one probe, and pulse it with 5V at 100 Hz.

The other probe connects to the ADC pin. That's the main idea...
You'll need to check if the minimum resistance of the setup is low enough for the Arduino to take it. Get a multimeter, dip them in water and measure the resistance. I'm assuming you have a spacer between them to guarantee that the distance is always the same.

Then, you'll need to make a voltage divider with a resistor between ADC and ground. When you turn on the pin, start AD convertions and check the highest value recorded during that interval (pin on).

You can also place a capacitor to filter out the 100 HZ PWM and that should give you a stable value since it averages the PWM. But I think that it won't be a linear relation... you'll have to check it.
This... is a hobby.


I think lemming has a better idea than bubulindo. With the method bubulindo suggests there will be a pulsed DC voltage across the sensor and this will slowly be destroyed by electrolysis. The alternating of the polarity at each end will provide the protection this probe needs. However that leaves the problem of measuring the current. In order to measure current you have to turn it into a voltage, this is done simply by putting a resistor in series and measuring the voltage across that. You need to synchronise the measurements so that you always measure when the resistor is grounded. There is no need to use any capacitors to isolate anything.


I'm gonna giver you a THIRD opinion, youre really getting your money's worth.  Of course its worth what you paid ;-)

I'm gonna go with capacitor coupling.  It absolutely guarantees no DC galvanic current.  In fact I'd use capacitors in BOTH leads, to prevent galvanic current from Arduino power returning thru the sensor.  If youre strictly battery powered you only need capacitor in one leg.

This method drives a square wave from a DIO thru a resistor and your sensor.  A lot depends on Rs of your sensor.  If Rs is low, make Re 10 times that, and if Re ends up being less than 1k the math stays simple and resolution is not far from linear.  Use internal 1v reference.  The sensor current will be 5v / (Re+Rs) and sensor voltage will be 5v * (Rs / (Re+Rs)) and you can measure the voltage when DIO is HIGH.  

Datasheet Table 28-7. ADC Characteristics RAIN Analog Input Resistance 100 M[ch937] is in series with 10 k resistor, so we can neglect that branch in the math.

The 10 k resistor has an important function, when DIO is LOW, C will try to deliver a negative voltage to the ADC pin.  This would be a Bad Thing.  The ATmega328 has protection diodes built in, but they are not rated for much current so we protect the protection diodes with a resistor to limit the current to 5V / 10k = 0.5 mA.  

ATmega328 datasheet
23.6.1 Analog Input Circuitry
The ADC is optimized for analog signals with an output impedance of approximately 10 k[ch937] or
less. If such a source is used, the sampling time will be negligible. If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely. The user is recommended to only use low impedance sources with slowly varying signals, since this minimizes the required charge transfer to the S/H capacitor.
Without knowing how extra sample time affects the Arduino performance, lets stick with 10k maximum.  

BTW dont worry too much about the frequency being exact.

Go Up