Interfacing any resistive sensor on GPIO
Resistive sensors are devices whose resistance changes when the sensor's input is altered. A photoresistor will change based on the amount of light, and a thermistor's resistance changes with temperature. With a simple circuit, you can configure your GPIO to read changes in a resistive sensor's values.
Getting ready
For this recipe, I used a photoresistor as they are the easiest ones to change values on. Any two-lead resistive sensor will work for this recipe. You'll also need a 1uF electrolytic capacitor.
How to do it...
- Configure the following circuit and wire it to the Raspberry Pi:
- Using
RPi.GPIO
again, we can put together a simple program that tracks our sensor. Createphotoresitor.py
in thech9
directory with the following code:    #!/usr/bin/env python     # Raspberry Pi Zero Cookbook     # Chapter 9 - Analog Sensors     import RPi.GPIO as...