Skip to content

Instantly share code, notes, and snippets.

@lamlion
Created March 1, 2019 23:27
Show Gist options
  • Save lamlion/7c09affbf51ce9a3fd844f7d613d3bf6 to your computer and use it in GitHub Desktop.
Save lamlion/7c09affbf51ce9a3fd844f7d613d3bf6 to your computer and use it in GitHub Desktop.
DHT22 Python Temperature script
# Raspberry Pi Tips & Tricks - https://raspberrytips.nl
import Adafruit_DHT
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT22, 4)
humidity = round(humidity, 2)
temperature = round(temperature, 2)
if humidity is not None and temperature is not None:
print 'Temperatuur: {0:0.1f}*C'.format(temperature)
print 'Luchtvochtigheid: {0:0.1f}%'.format(humidity)
else:
print 'Geen data ontvangen'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment