PyRaspBeta

← All practice problems

Raspberry Pi practice problem · Sensors

Fahrenheit, please

EasyBudget $9Python · gpiozero

A DHT22 with its data pin on GPIO4 (and a 10 kΩ pull-up from data to 3.3 V, or the DHT22 module). Every 2 s, print the temperature in degrees Fahrenheit with one decimal:

72.5 F

°F = °C × 9 / 5 + 32. The room starts at 22.5 °C and cools to 18 °C at 5 s.

Tip: adafruit_dht.DHT22(board.D4).temperature is in °C.

More in Sensors