Experimented with reading DHT22 amd Light sensor modules using NodeMCU ESP12E development board. Main problem I had that timer did not work on old firmware, had to update it ( read previous post ). Other that that all went fine and could read data.One strange thing is that I am getting temperature a little bit higher than actual. Not sure why is that, maybe because board is powered by 3.3v and not 5v. Will have to find out that later.Code:if not tmr.alarm(0, 5000, tmr.ALARM_AUTO , function() print("Starting to read data:") light = adc.read(0) or "" print("Light:"..light) pin = 4 status, temp, humi, temp_dec, humi_dec = dht.readxx(pin) if status == dht.OK then -- 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 timed out." ) end end) then print("whoopsie") end
Tested that this sample was not working on dev board:if not tmr.alarm(0, 5000, tmr.ALARM_SINGLE, function() print("hey there") end) then print("whoopsie") endChecked firmware version (connected to ESPlorer and pressed reset):ESP12E default NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.4Decided to update firmware. Found here that only 9.6 is available precompiled, later ones have to be costum built. Downloaded 9.6 files and uploaded them using ESP8266Flasher.exeChecked firmware version then:NodeMCU 0.9.6 build 20150704 powered by Lua 5.1.4And tested this code sample:if not tmr.alarm(0, 5000, tmr.ALARM_SINGLE, function() print("hey there") end) then print("whoopsie") endIt worked.