nodemcu-firmware/lua_modules/dht22
Vowstar 8660c32dbc Merge pull request #120 from javieryanez/patch-2
Add README.md for DHT22 module by javieryanez
2015-01-21 16:00:26 +08:00
..
README.md README.md for DHT22 module 2015-01-21 08:23:06 +01:00
dht22.lua DHT22 module 2015-01-21 08:21:08 +01:00

README.md

DHT22 module

Example

PIN = 4 --  data pin, GPIO2

dht22 = require("dht22")
dht22.read(PIN)
t = dht22.getTemperature()
h = dht22.getHumidity()

-- temperature in degrees Celsius  and Farenheit
print("Temperature: "..(t/10).."."..(t%10).." deg C")
print("Temperature: "..(9 * t / 50 + 32).."."..(9 * t / 5 % 10).." deg F")

-- humidity
print("Humidity: "..(h/10).."."..(h%10).."%")

-- release module
dht22 = nil
package.loaded["dht22"]=nil