Chat freely about anything...

User avatar
By jack3210
#40942 Hello!
I'm esp8266 newbie. And I know very little English. Read OK, but write poor :( sorry, I hope You undestand me.
Can someone help me?
Trying to save any parameter from esp8266 to an external raspberry pi server. If I inserting code in a separate window Esplorer and manualy run. The code executes and writes the number 25 (over php script) in a file on raspberry pi. But if inserting the same code to init.lua (and any other module or function) to automatic run - that does not work :(

The same problem I have with thingspeak. On separate window code work, data add to channel, as modul with any additional code - not work.

Code on separate Esplorer window:
Code: Select allparameter = 25
conn=net.createConnection(net.TCP, false)
conn:on("receive", function(conn, payload) print("Get done.", payload) end )
conn:connect(83,"37.128.xxx.xxx")
conn:send("GET /esp.php?temperatura="..parameter .. " HTTP/1.1\r\nHost: 37.128.xxx.xxx\r\n" .. "Connection: keep-alive\r\nAccept: */*\r\n\r\n")

This code with manual run - work Ok

and code on init.lua

Code: Select all--init.lua
print("Setting up WIFI...")
wifi.setmode(wifi.STATION)
--modify according your wireless router settings
wifi.sta.config("2G","xxxxxx")
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip()== nil then
print("IP unavaiable, Waiting...")
else
tmr.stop(1)
print("Config done, IP is "..wifi.sta.getip())
end
end)
parameter = 25
conn=net.createConnection(net.TCP, false)
conn:on("receive", function(conn, payload) print("Get done.", payload) end )
conn:connect(83,"37.128.xxx.xxx")
conn:send("GET /esp.php?temperatura="..parameter .. " HTTP/1.1\r\nHost: 37.128.xxx.xxx\r\n" .. "Connection: keep-alive\r\nAccept: */*\r\n\r\n")


this code not work :(

best regards
Jack