Skip to content

Instantly share code, notes, and snippets.

@jeanfbrito
Last active November 30, 2015 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanfbrito/74419c39fb526bc2cede to your computer and use it in GitHub Desktop.
Save jeanfbrito/74419c39fb526bc2cede to your computer and use it in GitHub Desktop.
NodeMCU DHT22 test
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