Current firmware: http://nodemcu-build.com/ default settings + DHT
It all results in the same. Humidity is either 1 or nill. When I breath at the sensor, I get some results between 30 en 99. Time between measurement is at least 3 seconds since it can become a problem.
Can someone take a look at the connections / code below. Anything I can try to make it work?
Connections:
ESP8266-12:
VCC ----> 3.3V of power supply
GND ----> Ground of power supply
CH_PD ----> HIGH (3.3V)
GPIO2 ----> HIGH (3.3V)
GPIO15 ----> LOW (GND)
GPIO0 ----> HIGH (3.3V)
GPIO16 ----> RST
DHT22
PIN1: --> 3.3V of power supply
PIN2: --> GPIO12 of ESP8266-12
PIN4: --> Ground of power supply
Code:
init.lua
function startup()
if abort == true then
print('startup aborted...')
return
end
print('starting user.lua...')
dofile('user.lua')
end
abort = false
print("1 seconds to abort user.lua...")
tmr.alarm(0,1000,0,startup)
user.lua
--- WiFi Connect
wifi.setmode(wifi.STATION)
wifi.sta.config("ssid","password")
tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip()== nil then
print("IP unavaiable, Waiting...")
else
tmr.stop(1)
print("ESP8266 mode is: " .. wifi.getmode())
print("Connected...")
print("MAC: " .. wifi.ap.getmac())
print("IP :".. wifi.sta.getip())
-- Read sensor and post data
-- Read DHT22 Sensor on GPIO12 (pin 6)
status, temp, humi, temp_dec, humi_dec = dht.read(6)
--todo: add some errorchecking for dht.read
-- Post data
print("Sending data:"..temp.." "..humi..".")
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end )
conn:on("connection", function(c)
conn:send("GET /update?api_key=notsosupersecretkey="..temp.."&field2="..humi..""
.. " HTTP/1.1\r\n"
.. "Host: api.thingspeak.com\r\n"
.. "Connection: close\r\n"
.. "Accept: */*\r\n"
.. "User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n"
.. "\r\n")
end)
conn:connect(80,"54.88.155.198")
tmr.alarm(2, 1000, 1, function()
if conn == nil then -- is this the right way to make the program wait before deepsleep?
print("Still sending data, please wait...")
else
tmr.stop(2)
print("Going to sleep for 55secs...")
node.dsleep(55000000)
end
end)
end
end)