Any examples code are welcomed.
Any examples code are welcomed.
Explore... Chat... Share...
gorec2005 wrote:Hi!
one imho - if you use windows for download lua to the esp8266 - try YAT(from sf.net) it can insert delay between send string (500ms enought for me)
and second - this work for me:Code: Select alls=net.createServer(net.TCP)
s:listen(80,function(c)
c:on("receive",function(c,pl)
for v,i in pairs{2,8,9} do
gpio.mode(i,gpio.OUTPUT)
c:send("\ngpio("..i.."):"..gpio.read(i))
if string.find(pl,"gpio"..i.."=0") then gpio.write(i,0) end
if string.find(pl,"gpio"..i.."=1") then gpio.write(i,1) end
c:send("\nnew_gpio("..i.."):"..gpio.read(i))
end
c:send("\nTMR:"..tmr.now().." MEM:"..node.heap())
c:on("sent",function(c) c:close() end)
end)
end)
with this you can post GET query like this:
http://192.168.x.x/gpio8=1
or
http://192.168.x.x/gpio2=1&gpio8=0
or
http://192.168.x.x/gpio9=1&gpio2=1
or
http://192.168.x.x/gpio9=1&gpio2=1&gpio8=1
Erni wrote:First a thank to zeroday for this lua implementation
I have the webserver running without problems.
I am planning to put some sensor reading ,and I found this easy way
to interface with an Arduino, or actually a ATtiny85.
The t85 simply serially prints the value of t, which update the value on the webpage:
Maybe others will find it useful, or there is a better way to do thisCode: Select allif(t==nil) then
t=12
end
srv=net.createServer(net.TCP) srv:listen(80,function(conn)
conn:on("receive",function(conn,payload) print(payload)
conn:send("HTTP/1.1 200 OK\n\n")
conn:send("<html><body>")
conn:send("<h1>Erni's ESP8266</h1><BR>")
conn:send("TEMP : " .. t .. "<BR>")
conn:send("NODE.HEAP : " .. node.heap() .. "<BR>")
conn:send("TMR.NOW : " .. tmr.now() .. "<BR>")
conn:send("</html></body>")
conn:on("sent",function(conn) conn:close() end)
end)
end)
scargill wrote:Here is the revised code with the heap display coming up on the remote browser... the recovery makes this unusable - typical application might be for a mobile phone to poll the status of something - would not last a minute..... I hope you can fix because this is SO NEAR to being useful.Code: Select allmycounter=0
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
if string.find(payload,"?myarg=") then
mycounter=mycounter+1
m="<br/>Value= " .. string.sub(payload,string.find(payload,"?myarg=")+7,string.find(payload,"HTTP")-2)
else
m=""
end
conn:send("<h1> Hello, this is Pete's web page.</h1>How are you today.<br/> Count=" .. mycounter .. m .. "Heap=".. node.heap())
end)
conn:on("sent",function(conn) conn:close() end)
end)
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]