Go Down

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

#### lemming

##### Jan 11, 2011, 01:53 pm
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?

#### bubulindo

#1
##### Jan 11, 2011, 02:57 pm
No.

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.

#### Grumpy_Mike

#2
##### Jan 11, 2011, 03:18 pm
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.

#### AltairLabs

#3
##### Jan 11, 2011, 07:19 pm
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
Quote