Best way for ADC of an unknown resistance

Discussion in 'General Electronics Chat' started by Litch, Apr 7, 2013.

  1. Litch

    Thread Starter Member

    Jan 25, 2013
    Since none of my other questions seemed to get answered about my project, perhaps I'll ask the questions a different way.

    My project used ADC to measure water content in soil.

    These rules/aims apply to the problem:
    * 3.3v supply, max.
    * Resistance of soil, is a range that falls between zero to several MOhm.
    * The ADC pins must be grounded (Somehow) to stabilise the reading.
    * Maximum accuracy within the desired range (unknown)

    My first attempt based on the little I know about electronics was flawed (not so unexpectedly) - the readings from the ADC are all over the place because the ADC input pins are just floating, and the reference supply perhaps has some ripple as well, but that's another story.

    Never the less, my current schematic (R6) looks something like the first image. With some browsing on the net, and the consequent discovery that the pins needed a path to ground to stabilise, comes the next revision (R7 - voltage divider), and finally third (R8) is one that's driving some model of NPN, with a source directly from the Vref.

  2. patricktoday


    Feb 12, 2013

    Let me preface this with saying I have no idea how soil sensors work :eek:. But you say it's simply a variable resistor... so one way to measure an unknown resistance is to put an exact current into it and see how much voltage is generated. Your configuration doesn't look right to me, though I don't know what's connected to the other side of the 330Ω resistor. Perhaps it would make things more clear if you post a schematic of a single sensor and its measurement circuitry.

    Attached is a very basic circuit to measure multiple unknown resistors: Q1 is a current source and then Q2, Q3, etc., are current mirrors that will emit the same current as you put into Q1. There are some problems with this: the impedances may be too high for your ADC, you'll get pretty terrible ADC resolution since you're trying to measure such a large range (etc. :)) but I thought I'd post it. The 1.5Meg resistor sets the desired current.

    The range problem is interesting too. I'm thinking there's a way to generate multiple distinct values of current and switch between them one by one with a uC (to get the best resolution for the given current state of resistance), but I don't have a circuit for that.
    absf likes this.
  3. YokoTsuno


    Jan 1, 2013
    I don't think this is as easy as it looks. You should consider methods which electricians use to measure grounding resistance. Google "Ground Measuring Techniques" or "Earth Measuring Techniques" and you get numerous documents on how this is done.

    - Connect a current source across two earth electrodes (A current source supplies a constant current, instead of a constant voltage.)
    - Measure the voltage across the electrodes or even a third/forth electrode
    - Ratio is resistance

    Schematic drawings of Earth Resistance Testers may also be helpful for ideas.

    Some thoughts:
    From 10Ω - 10MΩ is called the dynamic range which is very large in your case . I don't know how much of this range you really need, but if for instance you scale the current in such a way that you get 20V@10MΩ it would only be 20μV at 10Ω !!!!.
    A 12-Bit ADC can’t cover this range (2^12 = 4096), you need at least a 24-bit ADC. Even with 24 bits, processing such small analog signals requires a considerable amount of know-how (Keywords: CCMR, shielding, noise...) to get stable readings. You probably need a differential amplifier to resolve this. Better is to have a programmable current source just like multi-meters, which can be adjusted according to soil conductivity.

    Also remember that to generate a sizable current through a large resistance you need a considerable voltage. Earth resistance testers that electricians use produce up to 100 Volts for this purpose. A BC548 is not going to do that for you.

    I am not a chemist but I also don't think there isn't a linear relationship between conductivity and humidity. I assume soil minerals play a large part in this equation.
    absf likes this.
  4. Litch

    Thread Starter Member

    Jan 25, 2013
    Thanks for that patrick.

    Note that I'm not trying to get the resistance value in ohms as such; rather I purely need to establish a scale of "fully saturated" to "very dry".

    The other side of the 330R is a Digital IO pin of a Raspberry Pi. This engages the BC548 to supply a current to the soil sensors, and then the ADC would take a measurement. This method was taken to reduce ionisation of the soil and the electrolysis of the electrodes if I was to supply a constant current to the soil probes.

    Which brings up another point - variability. Each pot is going to be different, different mineral levels, different soil composition, free ions in the water used to water the plants are going to affect things - as well as time factors - this unit will need to be calibrated every now and then...

    Moving forward

    With those things clarified, let's ignore that the soil will vary and just accept that the range of resistance it offers can and will differ.

    So one day, fully saturated may be 10KΩ, very dry may be 500KΩ.
    But next month, fully saturated may be 1KΩ, very dry may be 100KΩ

    As a reference, I took my multimeter and a couple of screwdrivers and stuck them in a few pots, all the way down, roughly an inch apart, reading was 1.9MΩ.

    Took them out, put them in the dog's water (40L plastic bucket) - 2KΩ

    So it looks like my range is going to have to be somewhere around that mark 1KΩ to 10MΩ, depending on the size of the probe and it's proximity between the prongs. That's 10,000 units of scale - and not that I need that resolution, 10,000 / 4096 is sufficient for my purpose but upwards of 1MΩ, wouldn't noise become a factor?
  5. WBahn


    Mar 31, 2012
    I suspect you have a bigger problem that is going to dominate your "accuracy".

    Take twenty readings in your pot and see how much your min and max reading vary by.
  6. Litch

    Thread Starter Member

    Jan 25, 2013
    I did a few (6) across a couple of pots; range was around 1.9M to 2.2M in one pot, and around 8.0M +/- 1M in the other - surprisingly consistent, with the fact it was me stabbing around with screwdrivers and not a probe with fixed electrodes.

    I guess that's the next step - I'll need to make my probes and make them well. I was going to use old cutlery and weld them to position - I'll make a few protos and take some more measurements - perhaps I can reduce this range with some larger/closer electrodes...