Skip to main content

Subsection 14.1.3 The Voltage Divider as the Interface

The ADC measures a voltage, and a photocell is a resistance. The circuit that turns one into the other is a voltage divider: the sensor is placed in series with a fixed resistor between the supply and ground, with the node between them going to an ADC pin (Figure 14.1.2). Call the sensor’s resistance \(R_\text{sens}\) and the fixed resistor \(R_M\text{.}\) The voltage at the node is
\begin{gather*} V_M = V_{cc} \cdot \frac{R_M}{R_\text{sens} + R_M} \end{gather*}
which resembles the potentiometer’s formula from the ADC chapter (Figure 6.1.3), with \(R_\text{sens}\) in place of \(R_1\) and \(R_M\) in place of \(R_2\text{.}\) \(V_{cc}\) is the Nucleo’s 3.3 V, because the ADC’s reference is 3.3 V (Subsection 6.1.2): a node fed from 3.3 V can use the ADC’s whole range and never exceeds it, and a voltage above the ADC’s reference is outside the pin’s operating conditions. As the light changes, \(R_\text{sens}\) changes and \(V_M\) changes with it.
Figure 14.1.2. The voltage divider as the interface between a resistive sensor and the ADC. The sensor, \(R_\text{sens}\text{,}\) drawn as a variable resistor, is connected from \(V_{cc}\) to the node, and the fixed resistor \(R_M\) from the node to ground. The node’s voltage \(V_M\) goes to an ADC pin, and the formula gives it in terms of the two resistances.