-
-
Save anonymous/dd5d16e3dc105ef21ebf to your computer and use it in GitHub Desktop.
This file contains 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
#Initialize DHT22 Sensor and read data. | |
#to access, run python as root. (sudo) (shouldn’t be a problem if script is run as system service) | |
import dhtreader | |
type = 22 # we are using the DHT22 | |
pin = 18 # and it is on GPIO 18 in this example. | |
dhtreader.init() | |
print dhtreader.read(type, pin) | |
# will print Temperature [0], and Humidity[1] as (Temperature, Humidity). | |
x = dhtreader.read(type, pin) | |
while x is None | |
x = dhtreader.read(type, pin) | |
# x[0] will be temp. x[1] will be Hum. Lets set those to their own variables to keep from confusing. | |
dhtemp = x[0] | |
dhhum = x[1] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment