Raspberry Pi practice problem · Sensors
Rolling average
MediumBudget $8Python · gpiozero
A DHT22 on GPIO4 (with its 10 kΩ pull-up). Read the temperature every 2 s and print the average of the last three readings with one decimal (while you have fewer than three, average the ones you have):
avg 20.0
The test room is at 20 °C and jumps to 23 °C at 5 s, so the average should step through 21.0 and 22.0 before reaching 23.0.