-->
Page 1 of 1

DHT11 sensor data(coding with LUA)

PostPosted: Tue Apr 06, 2021 3:03 am
by darsh_t
I tried to retrieve humidity and temperature using the DHT11 sensor with ESP8266. However, I have been getting a compiling error such as "lua:4: unexpected symbol near ',' ". If possible, could anyone also point out the other potential errors in this code? My code looks as follows: :)

Code: Select all 

pin = 1

status, temp, humi, temp_dec, humi_dec = dht.read(pin)--read dht11 from pin

if status == dht.OK then    --check status is ok and print temperature and humidity
print(string.format( "DHT Temperature:%d.%03d;Humidity:%d.%03d" )
math.floor(temp),
temp_dec,
math.floor(humi),
humi_dec
    )
elseif status == dht.ERROR_CHECKSUM then    --else print either status
print( "DHT Checksum error." )
elseif status == dht.ERROR_TIMEOUT then
print( "DHT timed out." )
end