http - nodeMCU DeepSleep Configuration -


i working on configuring wemos d1 mini running nodemcu makes http post once every minute , go deepsleep, repeat. have pin32 & pin8 connected jumper cable specified nodemcu documentation. when run following code (omitting deepsleep), works fine not when include deepsleep code, fails make http post together, appreciated.

init.lua -- configure network  dofile("credentials.lua")  -- dht22 sensor humidity&temperature  dht22 = 5 status, temp, humi, temp_dec, humi_dec = dht.read(dht22)      if status == dht.ok         -- debugging, print console          print("dht temperature: "..temp)         print("dht humidity: "..humi)     elseif status == dht.error_checksum         print( "dht checksum error." )     elseif status == dht.error_timeout         print( "dht timed out." )     end  -- post request  http.post('url',   'content-type: application/json\r\n',   '{"humidity":'..humi..', "temperature":'..temp..', "moisture":'..adc.read(0)..', "sunlight":0}',   function(code, data)     if (code < 0)       print("http request failed")     else       print(code, data)     end   end)  -- small delay allow device make http post before going deep-sleep mode  tmr.delay(5000000) print("enterning deep sleep mode 60 seconds...goodbye") node.dsleep(60000000)   credentials.lua  wifi.setmode(wifi.station) wifi.sta.config("ssid","pwd")  tmr.alarm(1, 10000, 1, function()     if wifi.sta.getip()== nil         print("awaiting ip...")     else         tmr.stop(1)         print("ip: "..wifi.sta.getip())         print("proceeding...")         dofile("init.lua")     end end) 

when run following code (omitting deepsleep), works fine not when include deepsleep code, fails make http post together

i don't understand...you not omit deep sleep in code sample, do?

anyway, tmr.delay no-go beyond 50us. why don't enter deep sleep when http request returns? this:

http.post('url',   'content-type: application/json\r\n',   '{"humidity":'..humi..', "temperature":'..temp..', "moisture":'..adc.read(0)..', "sunlight":0}',   function(code, data)     if (code < 0)       print("http request failed")     else       print(code, data)       print("enterning deep sleep mode 60 seconds...goodbye")       node.dsleep(60000000)     end   end) 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -