NodeMCU (LUA)

NodeMCU (LUA)

This page is to Setup and Config NodeMCU

Hardware and Software

Hardware

NodeMCU

Software

Arduino IDE

Notes

  • Good For MAC

  • Manual Install and Flash : https://nodemcu.readthedocs.io/en/dev/en/flash/

    • Install Python

  • Full DOC : https://github.com/themadinventor/esptool#flash-modes

    • E.g.

      • esptool.py --port /dev/cu.SLAB_USBtoUART write_flash -fm qio -fs 32m 0x00000 nodemcuflash.bin

  • --------------------------------------------------------------------------------

    • Firmware : https://github.com/nodemcu/nodemcu-firmware/tree/master

      • https://github.com/nodemcu/nodemcu-firmware

    • Build a Firware : http://nodemcu-build.com/

    • Doc : https://nodemcu.readthedocs.io/en/dev/en

      • https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_cn#wifistartsmart

    • Flash : https://github.com/nodemcu

      • https://github.com/nodemcu/nodemcu-flasher

    • Offical Site : http://www.nodemcu.com/index_en.html

    • Steps :

      • Create your own Firmware : http://nodemcu-build.com/index.php

      • Use flasher to download to ESP8266 (ESP01 or NODEMCU)

      • THIS IS ONLY FOR LUA

    • After Boot

      • NodeMCU custom build by frightanic.com

      • branch: master

      • commit: c8037568571edb5c568c2f8231e4f8ce0683b883

      • SSL: false

      • modules: bit,coap,crypto,file,gpio,i2c,net,node,ow,pwm,spi,tmr,u8g,uart,wifi,ws2801,ws2812

      • build built on: 2016-05-30 07:22

      • powered by Lua 5.1.4 on SDK 1.4.0

Examples

This example is lua file for esp01 or nodemcu lua flasher formated

Module - Description

            1. wifi.setmode(wifi.STATION)

            2. wifi.sta.config("SweetHome","parc362a")

            3. print(wifi.sta.getip())

            4. led1 = 3

            5. led2 = 4

            6. gpio.mode(led1, gpio.OUTPUT)

            7. gpio.mode(led2, gpio.OUTPUT)

            8. srv=net.createServer(net.TCP)

            9. srv:listen(80,function(conn)

            10. conn:on("receive", function(client,request)

            11. local buf = "";

            12. local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");

            13. if(method == nil)then

            14. _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");

            15. end

            16. local _GET = {}

            17. if (vars ~= nil)then

            18. for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do

            19. _GET[k] = v

            20. end

            21. end

            22. buf = buf.."<h1> ESP8266 Web Server</h1>";

            23. buf = buf.."<p>GPIO0 <a href=\"?pin=ON1\"><button>ON</button></a>&nbsp;<a href=\"?pin=OFF1\"><button>OFF</button></a></p>";

            24. buf = buf.."<p>GPIO2 <a href=\"?pin=ON2\"><button>ON</button></a>&nbsp;<a href=\"?pin=OFF2\"><button>OFF</button></a></p>";

            25. local _on,_off = "",""

            26. if(_GET.pin == "ON1")then

            27. gpio.write(led1, gpio.HIGH);

            28. elseif(_GET.pin == "OFF1")then

            29. gpio.write(led1, gpio.LOW);

            30. elseif(_GET.pin == "ON2")then

            31. gpio.write(led2, gpio.HIGH);

            32. elseif(_GET.pin == "OFF2")then

            33. gpio.write(led2, gpio.LOW);

            34. end

            35. client:send(buf);

            36. client:close();

            37. collectgarbage();

            38. end)

            39. end)

Update Fameware on 2016 08 18