Created
March 1, 2019 23:27
-
-
Save lamlion/7c09affbf51ce9a3fd844f7d613d3bf6 to your computer and use it in GitHub Desktop.
DHT22 Python Temperature script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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