Post on 16-Feb-2017
@etiene_dFOSDEM 2017
Specs
• CPU @ 80 MHz (default) or 160 MHz
• Memory 64 KB instruction, 96 KB data
• Input 16 GPIO pins
• Power 3.3 VDC
• Price: 3$-10$
@etiene_dFOSDEM 2017
Specs
2 Kb (Arduino Uno)
16 MHz (Arduino Uno)
• CPU @ 80 MHz (default) or 160 MHz
• Memory 64 KB instruction, 96 KB data
• Input 16 GPIO pins
• Power 3.3 VDC
• Price: 3$-10$
@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 esptoolls /dev/cu.*esptool.py --helpesptool.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
@etiene_dFOSDEM 2017
ws2812.init() ws2812.write(string.char(0,0,255),string.char(255,0,0)) ws2812.write(string.char(0,255,255):rep(6)) ws2812.write(string.char(0,0,0):rep(6))
Blinking a LED
@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
@etiene_dFOSDEM 2017
-- github.com/Etiene npx.fill_buffer(c.violet) npx.color_pixel({3,3},c.yellow) animate.fade()
Custom libraries
@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()
@etiene_dFOSDEM 2017
• http://hackaday.com/tag/esp8266/
• http://hackaday.com/2017/01/17/led-strip-display-gives-you-two-ways-to-see-the-music/
• http://hackaday.com/2016/11/19/jenkins-and-slack-report-build-failure-light-the-beacons/
• cutecircuit on instagram
• http://github.com/Etiene/silverhaze
Cool projects for inspiration
@etiene_dFOSDEM 2017
• http://nodemcu.com
• https://nodemcu.readthedocs.io/en/master/
• http://esp8266.com
• http://www.esp8266.com/wiki/doku.php
Resources
@etiene_dFOSDEM 2017
• Community • Lua mail list: http://www.lua.org/lua-l.html • #LuaLang on Twitter • Lua community blog: http://lua.space • Lua’s subreddit: http://reddit.com/r/lua • Lua’s IRC channel: irc.freenode.net #lua
• Books • Programming in Lua: http://www.lua.org/pil/ • Lua Programming Gems: http://www.lua.org/gems/
• Misc • CodeCombat: https://codecombat.com
Lua Resources
Thank you!
etiene.net github.com/Etiene/
dalcol@etiene.net
@etiene_d