# Why is a voltage divider used when reading analog sensors?

So when reading sensors (ping sensors/light/pressure/etc...) I notice they always use a voltage divider with resistors before running the input into the ADC input of a microcontroller.

Why can't we just run the sensor straight into the ADC? I understand that if the "device/sensor/whatever" went to a really high voltage the MCU wouldn't be able to understand it, but what about smaller ones that don't really go past 5v?

Also what's the best way to calculate what resistor value I should use? I guess whatever gets it between 0 and 5v?

edit: Apologies, I wasn't very clear. I guess I meant both types of sensors but I think I was more-so thinking of resistive type sensors (LDR's/etc...), but I guess it makes sense because an MCU can't actually measure resistance (Which I now feel stupid for not making the connection lol)

• Links to examples? Who are "they"? Usually I end up with some careful signal conditioning between a sensor and an ADC input, and the last thing before the ADC is an op-amp. Jan 15, 2019 at 5:08
• Sensors to gnd are unbalanced and a diff. amp is used to balance the cable better for EMI reasons. Twisted pairs are also used. Jan 15, 2019 at 5:11
• The best way to avoid confusion is to show us the circuits that you are having difficulty figuring out. Otherwise, it looks like we are making wrong assumptions. Jan 15, 2019 at 18:47
• Flagging to close, because question is not clear. Jan 15, 2019 at 18:51

A resistive sensor generates a signal by modifying an externally applied voltage. Adding a suitable resistor to make a voltage divider allows one to get the signal. Without the voltage divider, the only voltages available would be Vcc and ground.

simulate this circuit – Schematic created using CircuitLab

The reason why simply connecting the resistive sensor across Vcc will not work is this: The Vcc is designed not to change, at least not unless it hits a current limit. So ignoring any constant current situation, the voltage across the sensor will always be same as Vcc. And, if you feed that to the ADC, you are feeding in Vcc (which is kind of meaningless).

In the schematic above, the signal is at 2.5 V. When the resistance of the sensor increases or decreases, the signal voltage also increases or decreases... from a maximum possible value of close to Vcc down to a minimum possible of close to 0V.

A case could probably be made for a completely separate current limited 5V supply just for the sensor, and you could plug that into the ADC. That would probably work perfectly. However, most sensors do not tolerate high current. Or, even if they do, the power dissipation would heat up the sensor and alter any linearity of the sensor readings due to the changing temperature. This would make obtaining accurate readings rather difficult. (It also does not help that the sensor resistance usually falls with light/pressure/temperature, thus leading to greater current flow through the sensor.) Hence, some sort of current limiter in series with the sensor is required anyway. The simplest current limiter is a resistor, and thus we end up with a voltage divider.

Remember that you are not measuring resistance or current, you are measuring voltage with the ADC. So the voltage has to be able to change, you can't fix it to Vcc and feed that into the ADC. To vary voltage, by V=IR, you have to vary either current or resistance (or both). The resistor already varies. Depending on range and linearity, one may additionally opt to provide a constant current if required, instead of a simple resistor.

• What? The analog sensor already provides a varying voltage - you already have "more voltages" than Vcc and ground.
– JRE
Jan 15, 2019 at 6:36
• @JRE The OP is not very clear on the type of sensor. I'm assuming that resistive sensors were meant. These are not voltage/current sources, so are only modifying the voltage at the junction. Jan 15, 2019 at 6:56
• The question is clearly about using a voltage divider to reduce the range of the sensor output voltage to the range of the ADC.
– JRE
Jan 15, 2019 at 7:54
• If the sensor is a "resistor" itself, then why can't you just hook it between vcc and gnd and then into the mcu? since won't it naturally lower the voltage/current by itself (Which you can then measure)? Jan 15, 2019 at 20:15
• @msmith1114 You have to see the sensor datasheet (typical current or temperature coefficient data) to figure out how much current to let in through the sensor. And also figure out the maximum and minimum signal voltage you are likely to get. If the range is too low, an opamp might be required to scale the voltage before feeding it to the ADC. Jan 16, 2019 at 20:45

Well, you've already mentioned the reason: getting the signal level down to the input range of your analog to digital converter.

If your ADC has an input range of 0 to 5V, but your sensor puts out a signal that ranges from 0 to 10V, then there's a large part of your signal that you can't measure. Anything over 5V is digitized as 5V. Anything in your signal that lies between 5V and 10V is lost.

Another thing about exceeding the input limits is that ADCs are sensitive devices (as are most digital circuits like microprocessors.)

If you put a signal into them with a voltage that is higher than the operating voltage of the chip, then you can damage it - it won't work right any more, and may not work at all.

This applies regardless of the operating voltage.

If my ADC operates on 3.3V, then a 5V signal would damage it.

So, really it is all about staying in the allowed input range for your ADC, and there's a couple of reasons why you need to respect that range.

The datasheet of the ADC will usually tell you what voltage range is allowed.

Check the datasheet rather than just depending on an assumption made on the operating voltage.

There's also the lower side of things to consider.

Most ICs don't like it if the input goes below the ground level.

You get the same problems here that you would on the high side - loss of information and possible damage to the chip.

You will often see circuits that not only scale the signal with a voltage divider (or an attenuating amplifier,) but also shift it up (or down) to make best use of the ADC input range.

Say you have a signal that ranges from -5V to +5V.

That's a 10V difference.