Lesson 20 Photoresistor Module

Share for us

Introduction

A photoresistor is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity.

Required Components

 1 * Raspberry Pi

– 1 * Breadboard

– 1 * PCF8591

– 1 * Photoresistor module

– 1 * 3-Pin anti-reverse cable

– Several Jumper wires

Experimental Principle

With light intensity increasing, the resistance of a photoresistor will decrease. Thus the output voltage changes. Analog signals collected by the photoresistor are converted to digital signals through PCF8591. Then these digital signals are transmitted to Raspberry Pi and printed on the screen. The schematic diagram:

Experimental Procedures

Step 1: Build the circuit. 

Raspberry PiGPIO Extension BoardPCF8591 Module
SDASDA1SDA
SCLSCL1SCL
3.3V3V3VCC
GNDGNDGND
PhotoresistorGPIO Extension BoardPCF8591 Module
SIG*AIN0
VCC3V3VCC
GNDGNDGND

For C Users:

Step 2: Change directory. 

    cd /home/pi/SunFounder_SensorKit_for_RPi2/C/20_photoresistor/

Step 3: Compile.

    gcc photoresistor.c -lwiringPi 

Step 4: Run.

    sudo ./a.out

For Python Users:

Step 2: Change directory. 

    cd /home/pi/SunFounder_SensorKit_for_RPi2/Python/

Step 3: Run.

    sudo python3 20_photoresistor.py

Now, change light intensity (e.g. cover the module with a pad), and the value printed on the screen will change accordingly.