Reading analog sensors without an ADC

The best way to read analog voltages from the Pi is an Analog-to-Digital Converter (ADC) chip. However, there’s a way to read sensors without an ADC. By using the sensor as a resistor to ‘fill up’ a capacitor, one can measure the time it takes to charging the capacitor. Since it depends on the Pi timing itself, it’s not nearly as precise as an ADC, because timing can vary based on how ‘busy’ the CPU is.

This technique takes advantage of a basic electronic property of resistors and capacitors. If you take a capacitor that is initially storing no voltage and then connect it to power (like 3.3 V) through a resistor, it will slowly charge up to the power voltage. The bigger the resistor is, the longer it takes .

This technique only works with sensors that act like resistors. However, there are quite a few fun sensors acting this way: photocells, thermistors (temperature sensors), flex sensors, force-sensitive resistors, and many more. However, it cannot be used with sensors that have an analog output like IR distance sensors or analog accelerometers.

Here I used a basic photocell (LDR). This is a resistor that changes resistance based on how bright the light is. Note that photocells are not precision measurement devices, and this technique is also not very precise, so its only good for basic measurements.