Skip to content

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jan 28, 2021
1 parent fa13e56 commit ce480b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dht22-adafruit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/python3
import Adafruit_DHT

gpiopin=17

humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, gpiopin)
print("Temperature: {:.1f} °C Humidity: {:.1f} %".format(temperature, humidity))
19 changes: 19 additions & 0 deletions dht22.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/python3
import time, adafruit_dht

gpiopin=4

# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT22(gpiopin)

try:
# Print the values to the serial port
temperature, humidity = dhtDevice.temperature, dhtDevice.humidity
print("Temperature: {:.1f} °C Humidity: {:.1f} %".format(temperature, humidity))

except RuntimeError as error:
# Errors happen fairly often, DHT's are hard to read, just keep going
time.sleep(2.0)
# Print the values to the serial port
temperature, humidity = dhtDevice.temperature, dhtDevice.humidity
print("Temperature: {:.1f} °C Humidity: {:.1f} %".format(temperature, humidity))

0 comments on commit ce480b8

Please sign in to comment.