Reading DHT22 and Light sensor data using NodeMCU dev board

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 = 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


tmr.alarm not working on ESP12E 0.9.5 firmware

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.


How to use Arduino IDE to program NodeMCU

1. Install the Arduino IDE from download section of website 2. Run Arduino IDE's arduino.exe3. Arduino IDE >> File >> Preferences (Shourtcut is CTRL + COMMA)>> Settings tab >> on Additional Board Manager URL side type this >> and click ok. json object will bring necessary drivers for NodeMCU from the website to our Arduino IDE.4. Arduino IDE >> Tools >> Board >> Boards Manager... >> Type = Contributed >> click on install (Or, search ESP8266 from the search bar)5. Arduino IDE >> Tools >> Board >> NodeMCU 1.0 (ESP-12E MODULE)


End of content

No more pages to load