Tuesday, January 17, 2012

DIY DC soil moisture sensor - early test successful

Laptop connected to Arduino connected to flowerpot

On the the progressive difficulty scale of home built soil moisture sensors the bottom of the ladder is a DC soil conductivity sensor that uses simple resistivity measurement.

It took a couple of hours build one of those last night, most of which was spent incompetently attempting to produce a decent solder joint on steel wire and on the cleaned heads of galvanized nails. Anyone who can use a soldering iron without being a hazard to themselves and those around them should be able to whip something like this up in a few minutes.

First step: Simplest of the simple DC resistive sensor

After looking at the GardenBot design by Andrew Frueh, I landed up using something between his newer voltage-flipping design and his basic capacitor-based design - something that probably shares the faults of both, but was good enough for a quick and dirty experiment.

It's a simple circuit and it works, producing analog input values across a wide range that correlated well with soil moisture in my test flowerpot. It's also a stupid circuit that's really just a simple first-try toy, and isn't something I'd ever consider deploying in practice.

The 10k resistor is there for current limiting in case of a short; the 300kΩ to 3MΩ resistor is for you to tune the voltage range to fit your sensor probe length, spacing, etc so you get a good range of values. I landed up using a 630kΩ resistor for a pair of ~1mm steel wire probes about 10cm long. Your needs will vary.

If you don't want this simple circuit always-on (and always electrolysing - ouch!) you can use a digital pin in OUTPUT mode instead of the +3.3V rail, keeping it LOW except when you want to take a reading. Note that pin 13 has an LED and resistor inline, so you may want to use a different pin.

Next step: AC resistive sensor

I'm determined to avoid using two digital pins like Andrew has done for his bidirectional current sensor, so I need to produce low voltage AC. For the next version I'll be experimenting with generating a low voltage ultra-low-current AC square wave, probably using an astable multivibrator (also on Wikipedia) so I can synchronize my sensor reads to the oscillator easily.

Bizarrely it might be cheaper to do this with an IC containing an array of Schmitt triggers or with a 555 IC like the NE555 or TLC555CP (used like this) than with discrete transistor logic!

Either way, the oscillator will have to be embedded as local electronics near the sensor to avoid RF on the long cables out to the sensors, but that shouldn't be a big problem with simple circuitry like this.

Keep an eye out for the next post with work on AC/oscillator based resistive sensors.

https://github.com/ringerc/scrapcode/blob/master/arduino_avr/Arduino_Resistive_Soil_Moisture_Sensor_1.ino

1 comment:

  1. Good job my buddy. Do you by chance have results from your experiments. I am planning to use this configuration for a system I am building. Any data will be appreciated.

    ReplyDelete