-->
Page 1 of 53

[NodeMcu] A LUA based firmware for ESP8266 (build 20141120)

PostPosted: Wed Nov 12, 2014 11:33 am
by zeroday
Hi, all
Glad to release a firmware that is powered by lua.
https://github.com/nodemcu/nodemcu-firmware

Change log:
https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#change_log

This firmware act like a lua interpreter inside esp8266,
you can type lua chunk from serial port, and do what ever you like.
here are some examples:

Config wifi
Code: Select all    print(wifi.sta.getip())
    --0.0.0.0
    wifi.setmode(wifi.STATION)
    wifi.sta.config("SSID","password")
    print(wifi.sta.getip())
    --192.168.18.110


Manipulate hardware like a arduino
Code: Select all    pin = 1
    gpio.mode(pin,gpio.OUTPUT)
    gpio.write(pin,gpio.HIGH)
    print(gpio.read(pin))


Write network application in nodejs style
Code: Select all    -- A simple http client
    conn=net.createConnection(net.TCP, 0)
    conn:on("receive", function(conn, payload) print(c) end )
    conn:connect(80,"115.239.210.27")
    conn:send("GET / HTTP/1.1\r\nHost: www.baidu.com\r\n"
        .."Connection: keep-alive\r\nAccept: */*\r\n\r\n")


Or a simple http server
Code: Select all   
    -- A simple http server
    srv=net.createServer(net.TCP)
    srv:listen(80,function(conn)
      conn:on("receive",function(conn,payload)
        print(payload)
        conn:send("<h1> Hello, NodeMcu.</h1>")
      end)
    end)


Play with LED
Code: Select all  function led(r,g,b)
    pwm.setduty(0,r)
    pwm.setduty(1,g)
    pwm.setduty(2,b)
  end
  pwm.setup(0,500,50)
  pwm.setup(1,500,50)
  pwm.setup(2,500,50)
  pwm.start(0)
  pwm.start(1)
  pwm.start(2)
  led(50,0,0) -- red
  led(0,0,50) -- blue


Hope you guys like it.

NodeMcu - A LUA based firmware for ESP8266 (build 20141120)

PostPosted: Wed Nov 12, 2014 11:54 am
by RichardS
So you had to write all sorts of behind the scenes code to make this all happen right?

Very nice!

Richard.

Re: NodeMcu - A lua based firmware for esp8266

PostPosted: Wed Nov 12, 2014 3:57 pm
by mcsa
Can I write lua script, save it in file and then run it at startup?
Can command accept via tcp, like telnet? Or only via uart?

Re: NodeMcu - A lua based firmware for esp8266

PostPosted: Wed Nov 12, 2014 4:18 pm
by cendev
init.lua is running at the startup and you can edit that :) so yes, you can i guess :)

looks nice :) just gave it a small try and all looks fine :) looks like a piece of art since now :) haven't try the gpio :) timer also perfect :)

edit : Yes, you can create your own scripts and call them via dofile or use init.lua :)