Skip to content

Commit

Permalink
Add DHT sensor lib description in ReadMe
Browse files Browse the repository at this point in the history
A lot of people don't know DHT sensor lib.
  • Loading branch information
vowstar committed Dec 5, 2015
1 parent d34ac77 commit 50dcea3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,31 @@ The HX711 is an inexpensive 24bit ADC with programmable 128x, 64x, and 32x gain.
-- Read ch A with 128 gain.
raw_data = hx711.read(0)
```

####Universal DHT Sensor support
Support DHT11, DHT21, DHT22, DHT33, DHT44, etc.
Use all-in-one function to read DHT sensor.
```lua

pin = 5
status,temp,humi,temp_decimial,humi_decimial = dht.readxx(pin)
if( status == dht.OK ) then
-- Integer firmware using this example
print(
string.format(
"DHT Temperature:%d.%03d;Humidity:%d.%03d\r\n",
math.floor(temp),
temp_decimial,
math.floor(humi),
humi_decimial
)
)
-- Float firmware using this example
print("DHT Temperature:"..temp..";".."Humidity:"..humi)
elseif( status == dht.ERROR_CHECKSUM ) then
print( "DHT Checksum error." );
elseif( status == dht.ERROR_TIMEOUT ) then
print( "DHT Time out." );
end

```

0 comments on commit 50dcea3

Please sign in to comment.