As the title says... Chat on...

User avatar
By jankop
#9234 I wanted to use your module http.lua, because it is nice. But someone I makes a mistake, because it falls me. Could you look at it , please?
http://esp8266.fancon.cz/common/TS_fpdht.zip
Thanks

NodeMCU 0.9.5 build 20150127 powered by Lua 5.1.4
lua: cannot open init.lua
>
dofile(TS_fpdht.lua) 8. únor 2015 12:41:26
dofile("TS_fpdht.lua")
Humidity: 43.7%
Temperature: 19.3 deg C
Temperature: 66.74 deg F
> PANIC: unprotected error in call to Lua API (http.lua:22: attempt to perform arithmetic on a nil value)
PANIC: unprotected error in call to Lua API (attempt to call a nil value)
User avatar
By manawyrm
#9239 The first thing I see is your argument transmission.

Thats what the array is for:
Instead of
Code: Select all"/update?key='..WRITEKEY..'&field1='..humi..'&field2='..temp..",{foo = "bar"},

better do:
Code: Select all 
  http.get('184.106.153.149', 80, "update",{key = WRITEKEY, field1 = humi, field2 = temp}, function (payload)

Also: Connecting to the wifi with tmr.delay(1000000) is not a good idea. My init.lua looks like this: https://gist.github.com/Manawyrm/ead702a90667593f7f76

The issue also could've something to do with the response from your server. I only tested that with Apache2.4. Could be doing strange things with other hardware.
User avatar
By jankop
#9243
Also: Connecting to the wifi with tmr.delay(1000000) is not a good idea.

This delay is not for connecting. I had problems with that application started before completing the startup Lua. So I tried this delay. Thanks for the answer.