-->
Page 1 of 4

Example of a webclient with DNS lookup

PostPosted: Tue Dec 02, 2014 6:55 am
by Erni
This is my example of using a lua client to update a databse on my webserver.
It calls a .php page that update a MySql database every 30 seconds.

You can see the result here (showing only the last 25 entrys):

http://www.ernstc.dk/sensor.php

One thing that I can't figure out is why we have to use the IP number.
Wouldn't it be posibble to let the esp do the DNS lookup

Code: Select alltmr.alarm(30000, 1, function()
conn=net.createConnection(net.TCP, 0)
    conn:on("receive", function(conn, payload) print(payload) end )
    conn:connect(80,"46.30.212.238")
    conn:send("GET /esp.php?tekst="..adc.read(0) .."&heap="..node.heap().." HTTP/1.1\r\nHost: www.ernstc.dk\r\n"
        .."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
end)

Re: Show sensorreading on external webserver

PostPosted: Tue Dec 02, 2014 7:22 am
by gerardwr
On Lua and DNS have a look here, maybe it helps.http://www.esp8266.com/viewtopic.php?f=24&t=667&hilit=dns

Re: Show sensorreading on external webserver

PostPosted: Tue Dec 02, 2014 7:33 am
by Erni
Thanks gerardwr

Yes I found scargill's solution here

viewtopic.php?f=18&t=668

And with the new lua firmware from today, the heap issue seems to be solved.
I have tried your webserver with the new firmware, and I can't kill it even if I update as fast as I can, the heap recovers really fast

Re: Show sensorreading on external webserver

PostPosted: Tue Dec 02, 2014 11:13 am
by gerardwr
Erni wrote:And with the new lua firmware from today, the heap issue seems to be solved.
I have tried your webserver with the new firmware, and I can't kill it even if I update as fast as I can, the heap recovers really fast


Had no idea that the new firmware was already available, thanks for the tip. Nice that my webserver is behaving robustly now.