PyRasp

Light sensor + ADC board

The light sensor + ADC board puts a light-dependent resistor and a 10 kΩ resistor in a divider, with the midpoint on channel 0 of an MCP3008. It costs $9 and is for anything that reacts to light: night lights, blinds, "is the lamp on?" checks. Wire the SPI pins plus power and ground, then read channel 0 — brighter light gives a higher reading.

What's inside

PartQtyPrice each
Light sensor (LDR)1$0.75
Resistor1$0.25
MCP3008 ADC (SPI)1$4
Total3$5
  • The LDR is the top half of the divider; its resistance falls as light rises.
  • The 10 kΩ resistor is the bottom half, so the midpoint voltage rises with light.
  • The MCP3008 digitises the midpoint to 10 bits over SPI.
Exposed pinInside the kit
vddadc.VDD
gndadc.DGND
clkadc.CLK
doutadc.DOUT
dinadc.DIN
csadc.CS

vdd powers the LDR's end of the divider and must be 3.3 V; gnd is the shared ground. The kit has no chain ends; the SPI pins are clk, dout, din and cs.

Wiring it in circuit.py

circuit.py
from wiring import *

pi = Pi()
light = kits.LightADC()

pi.V3_3 >> light.vdd
light.gnd >> pi.GND
pi.SCLK >> light.clk
pi.MISO >> light.dout
pi.MOSI >> light.din
pi.CE0 >> light.cs

Driving it in main.py

main.py
from gpiozero import MCP3008
from time import sleep

light = MCP3008(channel=0)

while True:
    print(f"light {light.value * 100:.0f}%")
    sleep(0.5)

Why buy the kit

Loose parts come to $0.75 + $0.25 + $4 = $5.00, against $9 — $4.00 for a divider and an ADC wired for you. That premium buys the fix for the divider's usual failure mode: an LDR and resistor swapped, which inverts every reading, or a floating VREF that makes all readings meaningless.

Simulator vs real hardware

  • The LDR follows a power law from its simulated illuminance, refreshed every 50 ms, so covering it with a hand or switching on a lamp in its zone moves the reading.
  • Each LDR draws its own 10-lux resistance from a 2:1 band, so two boards can differ by a factor of two — calibrate before using absolute thresholds.
  • The MCP3008 runs at 3.3 V with VREF tied to VDD, so value is the midpoint voltage over 3.3 V; the same program works on a real Pi.

Further reading

  • gpiozero: MCP3008 — reading the ADC channel, and feeding its value into an LED or threshold.