analog sensor questions (especially why use voltage dividers ?)

pretty much a newbie at hardware, been doing software all my life, so the little things can be a bit frustrating, specially when i cant find an answer!

I have tried to find an answer myself to this, but why use a voltage divider to read in an analog value from a sensor, ie LDR or thermistor? wouldnt it work simply to go from 5v to analog in, and the variable resistance could be measured with analogRead, why does everything say to go with a voltage divider and to read the value from there. Is it simply to get a better scaling of voltages that you are reading? The thermistor changes appropriately over the range when hooked to a multimeter, so it doesnt seem that unreasonable to me?

I've got a few different thermistors that I was trying to turn into temperature based pwm fan control. Wired up the thermistors completely wrong to start with, the arduino shut off not long after starting, think i shorted something somewhere :blush: but all appears ok now. I've now set them up with 47uf capacitors and voltage dividers (as per attached image), but the calibration isnt the best (a range of about 25-38 values), any tips on the best way to choose the fixed value resistor to use in the divider? even if i was only able to get a resolution of 100 or so values, i think that would be sufficient for what i am trying to do.

Also I am not trying to read actual temperatures just relative values, to provide a variable pwm signal from a fixed high temp to a fixed low temp, would i really need to worry about the capacitors? One variation of my code provided smoothing of the signal, i'm not after a quick accurate signal, just something that will give me a reasonable range from a min to max temp. My understanding is the capacitors are to smooth the signal?

O'K, lets sort it out:

but why use a voltage divider to read in an analog value from a sensor, ie LDR or thermistor?

because, physical value to be measured is resistance, but device you have (analog in) is a voltmeter. So to transform resistance to voltage you have to pass a known current, than based on Ohms law and measured voltage resistance could be calculated. Additional resistor is current source (cheapest).

any tips on the best way to choose the fixed value resistor to use in the divider?

Sensitivity is the best when additional R and thermistor R are equal. AnalogRead will provide around 500.

even if i was only able to get a resolution of 100 or so values,

My guess, you mean not resolution, rather "dynamic range". Look above, to increase sensitivity.

Also I am not trying to read actual temperatures just relative values, to provide a variable pwm signal from a fixed high temp to a fixed low temp, would i really need to worry about the capacitors? One variation of my code provided smoothing of the signal, i'm not after a quick accurate signal, just something that will give me a reasonable range from a min to max temp. My understanding is the capacitors are to smooth the signal?

No, cap is noise suppressor, not related to absolute or relative type of measurements.
Smoothing the gradient you can do in software, preferable. Small cap helps also fight interference, RF - AC - etc., when wiring to sensors is long 10 cm and more.

thanks :slight_smile: was thinking about it more and realised about measuring resistance versus voltage. sorry for mixup re resolution and dynamic range, but you definitely answered that one for me also

So, going off of the information about sensitivity and the resistor, is there an "optimum" resistance where your sensor is most accurate?

I'm using a water level sensor, which is basically a linear resistor. With no water, it is 1500 ohm resistance, filled 8 inches and it's down to 300 ohm. I'm using it for a fish pond and am not expecting fluctuations more than a few inches. If I want to get the most accurate possible results, could I anticipate better measurements if I pick a resistor based on my height meter's mean resistance?

The problem with simplest resistive current source, is non-linearity. When one point could be set to "optimal" sensitivity, other end is always goes away.
Better method to measure sensor resistance is applying constant current, which will guarantee linear R-to-V transform, and equal sensitivity for all specified range of R to be measured.
http://octopart.com/lm334m%2Fnopb-national+semiconductor-998011