Current Lua downloadable firmware will be posted here

User avatar
By zeroday
#3070
scargill wrote:I was getting SO excited...

So I took the new webserver example, added a counter - and checked for an argument like http://www.mysite.com/?myarg=HELLO

Looked up the LUA docs - found the way to do it and


> mycounter=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)
>> end)
>> conn:on("sent",function(conn) conn:close() end)
>> end)
>



Absolutely GREAT... but ran it a dozen times, the counter worked, the argument came back and then.... I have NO idea why it crashed.



> c_GORSvfJSz.Szfn
Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4
>
Loading functions
Connecting
Connected to.loft-east.IP:.0.0.0.0
OK


Try run it 5 times, take a break, another 5 times, take a break...
the lua in this firmware isn't fast enough to collect memory back.

or, can you also
Code: Select allprint(node.heap())
every time when a client connected? to see how much ram left when it crash.
User avatar
By gerardwr
#3071
dnhkng wrote:Seeing as this topic has more replies than the next 3 pages of topics on the General Discussion board, maybe the Mods could create a new subsection? Maybe a NodeMcu board under Projects or Platforms?

That would lets us discuss separate bugs/features/requests in separate threads. People could also post example code in new threads, making them easier to find.

-David


Agree!!
User avatar
By gerardwr
#3074
Erni wrote: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 this


I'm glad my little web server example is of use to you.

Connecting an Attiny for some sensors for the ESP is a good idea, I really like these little devices.

Personally, I would like to work WITHOUT an At85, and connect the sensors directly tot the ESP. GPIO lines can be used for digital HI/LOW levels, the ADC channel could be used for reading a analog sensor. PWM can be used for analog output.

Ofcourse it depends on the kind of sensors you need, if you have an application for 1 sensor, maybe an ESP is enough.