NodeMCU is an open hardware IoT platform based on eLua for the ESP8266 microcontroller. It allows creating low-cost projects using Wi-Fi and easy scripting in Lua, which makes it great for making wearables, for example. In this talk I'll give an introduction to the platform, show how I built an audio reactive graduation dress and share the materials to get you started on your own wearable project. This talk is ideal for beginners to hardware hacking or Lua enthusiasts looking for project inspiration.
20. @etiene_dFOSDEM 2017
0 - Get the drivers if necessary:
http://www.wch.cn/download/CH341SER_MAC_ZIP.html
1 - Build the firmware: http://nodemcu-build.com
2 - Flash the firmware:
https://github.com/espressif/esptool
pip install esptool
ls /dev/cu.*
esptool.py --help
esptool.py --port <serial-port-of-ESP8266>
write_flash -fm dio 0x00000 <nodemcu-
firmware>.bin
3 - Get an editor / uploader: http://esp8266.ru/esplorer/
Getting started
23. @etiene_dFOSDEM 2017
wifi.setmode(wifi.SOFTAP)
local IP = “192.168.0.10” -- optional
wifi.ap.setip({ip=IP,netmask=“255.255.255.0"}) -- same
wifi.ap.config{ssid="My_network_id",pwd="my_password"}
print(wifi.ap.getip())
local srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,request)
local buf = “<h1>Welcome to our NodeMCU demo</h1>
client:send(buf);
client:close();
collectgarbage();
end)
end)
Serving a web page
28. @etiene_dFOSDEM 2017
Tips and tricks
1 - You can combine Lua’s coroutines with tmr.alarm to
create complex animations
2 - Add a timer delay on your init.lua
3 - Performance tricks:
- Get the scope of the project right
- Get the scope of your variables right
- Precompile your files using node.compile()