PyRaspBeta

← All practice problems

Raspberry Pi practice problem · Sensors

Damp alert

EasyBudget $9Python · gpiozero

A DHT22 on GPIO4 (with its 10 kΩ pull-up) and a blue LED on GPIO17. Read the humidity every 2 s and keep the LED lit while it is above 65 %, dark otherwise.

The test room is at 50 % RH, gets steamy (80 %) at 3 s and dries out (55 %) at 9 s. A DHT22 can only be read every 2 s, so the LED may follow up to 2 s late — that is fine.

More in Sensors