Skip to content

Instantly share code, notes, and snippets.

/gist:dd5d16e3dc105ef21ebf Secret
Created May 7, 2014

Embed
What would you like to do?
#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]
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.