Last active
November 30, 2015 16:35
-
-
Save jeanfbrito/74419c39fb526bc2cede to your computer and use it in GitHub Desktop.
NodeMCU DHT22 test
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
pin = 4 | |
status,temp,humi,temp_decimial,humi_decimial = dht.read(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 | |
) | |
) | |
Using the schematic from this page: | |
http://www.seeedstudio.com/recipe/232-primary-iot-make-with-nodemcu-gt-esp8266-lt.html | |
-- 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 | |
-- http://www.seeedstudio.com/recipe/232-primary-iot-make-with-nodemcu-gt-esp8266-lt.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment