Circuit lab 02 · Intermediate
Voltage dividers and sensors
Most simple sensors are resistors whose value changes with the world around them. Put one in a voltage divider and the change becomes a voltage a microcontroller can measure. Swap sensors, connect a load, and watch what the ADC actually reads.
The bench
How the numbers were worked out
Response curve
How Vout changes across the sensor’s whole range with the current R1. The dot is where the bench is now. A steep curve over the range you care about means a sensitive measurement.
Design it: choose R1
For the biggest change in Vout between two sensor readings, choose R1 = √(Rmin × Rmax), the geometric mean of the sensor’s resistance at each end of the range you care about.
The model behind this lab
Vout = Vin × R2 ÷ (R1 + R2). With a load, R2 is replaced by R2 ∥ RL = 1 ÷ (1/R2 + 1/RL). The ADC is ideal: code = floor(Vout ÷ Vref × 2ⁿ), clamped to its range.
The LDR model is illustrative: its resistance falls smoothly on a logarithmic scale from 1 MΩ in the dark to 1 kΩ in bright light. Real LDRs vary a lot between parts and respond slowly. The thermistor uses the B-parameter equation, R = R25 × eB(1/T − 1/T25) with T in kelvin, which is accurate to roughly a degree or so over a limited range; the Steinhart–Hart equation is more accurate.
Never let a divider output exceed your microcontroller’s supply voltage. A divider powered from 5 V can destroy the input of a 3.3 V board; power the divider from the board’s own 3.3 V pin instead.
Practical challenge
Use the bench above to check each answer.
Next: put this sensor to work in the automatic night light project.