PyRaspBeta

← All practice problems

Raspberry Pi practice problem · Sensors

Lux meter

HardBudget $8Python · gpiozero

An LDR on top of a 10 kΩ resistor into channel 0 of an MCP3008 on the SPI pins (VREF on 3.3 V), or the light sensor + ADC board. Turn the reading into lux, and every 0.5 s print it as a whole number: Lux: 50.

  • The divider: reading = 10 000 / (R + 10 000), where R is the LDR's resistance.
  • This LDR follows R = 12 650 × (lux / 10) ^ −0.7 ohms.

The test lights the cell at 50 lux, then 300 lux at 3 s, then 5 lux at 6 s. Answers within 10 % pass.

More in Sensors