Go to file
funshine 26de60cb4f add change log link to readme, nodemcu.com is on-line 2014-11-18 01:27:46 +08:00
0.9.2/512k-flash bug fix for net.socket.close(), add node.input node.output api 2014-11-18 01:24:49 +08:00
API.html bug fix for net.socket.close(), add node.input node.output api 2014-11-18 01:24:49 +08:00
API.md bug fix for net.socket.close(), add node.input node.output api 2014-11-18 01:24:49 +08:00
LICENSE add a MIT license 2014-11-14 13:29:14 +08:00
README.md add change log link to readme, nodemcu.com is on-line 2014-11-18 01:27:46 +08:00
README_cn.md update readme and the firmware 2014-11-10 19:52:02 +08:00
blank512k.bin add blank512k.bin 2014-10-21 18:59:28 +08:00

README.md

NodeMcu

###A lua based firmware for wifi-soc esp8266 version 0.9.2 build 2014-11-18

Change log

change log

Summary

  • Easy to access wireless router
  • Based on Lua 5.1.4
  • Event-Drive programming preferred.
  • Build-in file, timer, pwm, i2c, net, gpio, wifi, and system api.
  • GPIO pin re-mapped, use the index to access gpio, i2c, pwm.
  • GPIO Map Table:
IO indexESP8266 pinIO indexESP8266 pin
0GPIO128GPIO0
1GPIO139GPIO2
2GPIO1410GPIO4
3GPIO1511GPIO5
4GPIO3
5GPIO1
6GPIO9
7GPIO10

#Flash the firmware nodemcu_512k.bin: 0x00000
for most esp8266 modules, just pull GPIO0 down and restart.

#Connect the hardware in serial braudrate:9600

#Start play

####Connect to your ap

    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

    pin = 1
    gpio.mode(pin,gpio.OUTPUT)
    gpio.write(pin,gpio.HIGH)
    print(gpio.read(pin))

####Write network application in nodejs style

    -- A simple http client
    conn=net.createConnection(net.TCP, false) 
    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

    -- 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)

####Do something shining

  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

####And blink it

  lighton=0
  tmr.alarm(1000,1,function()
    if lighton==0 then 
      lighton=1 
      led(50,50,50) 
    else 
      lighton=0 
      led(0,0,0) 
    end 
  end)

####If you want to run something when system started

  --init.lua will be excuted
  file.open("init.lua","w")
  file.writeline([[print("Hello, do this at the beginning.")]])
  file.close()
  node.restart()  -- this will restart the module.

#Check this out Tencent QQ group: 309957875
nodemcu wiki
nodemcu.com