Merge pull request #167 from javieryanez/patch-4

Add support for NodeMCU with float point in the example
This commit is contained in:
Vowstar 2015-02-03 12:52:33 +08:00
commit a30ff88dc3
1 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,7 @@
# DHT22 module
This module is compatible with DHT22 and DHT21.
Supports nodemcu with or without floating point.
No need to use a resistor to connect the pin data of DHT22 to ESP8266.
## Example
@ -12,15 +13,20 @@ dht22.read(PIN)
t = dht22.getTemperature()
h = dht22.getHumidity()
if h == -1 then
if h == nil then
print("Error reading from DHT22")
else
-- temperature in degrees Celsius and Farenheit
print("Temperature: "..(t / 10).."."..(t % 10).." deg C")
-- floating point and integer version:
print("Temperature: "..((t-(t % 10)) / 10).."."..(t % 10).." deg C")
-- only integer version:
print("Temperature: "..(9 * t / 50 + 32).."."..(9 * t / 5 % 10).." deg F")
-- only float point version:
print("Temperature: "..(9 * t / 50 + 32).." deg F")
-- humidity
print("Humidity: "..(h/10).."."..(h%10).."%")
-- floating point and integer version
print("Humidity: "..((h - (h % 10)) / 10).."."..(h % 10).."%")
end
-- release module
@ -29,7 +35,7 @@ package.loaded["dht22"]=nil
```
## Functions
### read
read(pin)
read(pin)
Read humidity and temperature from DHT22.
**Parameters:**