Making wearables with NodeMCU - FOSDEM 2017

33
Making wearables with NodeMCU Etiene Dalcol @etiene_d

Transcript of Making wearables with NodeMCU - FOSDEM 2017

Making wearables with NodeMCU

Etiene Dalcol @etiene_d

@etiene_dFOSDEM 2017

@etiene_d

@etiene_dFOSDEM 2017

red-badger.com

@etiene_dFOSDEM 2017

A Lua MVC web framework sailorproject.org

@etiene_dFOSDEM 2017

@etiene_dFOSDEM 2017

luaconf.com/en

@etiene_dFOSDEM 2017

Lua SpaceThe Lua community blog

lua.space

@etiene_dFOSDEM 2017

What’s NodeMCU

Demo*

Resources

* subjected to randomness and despair

@etiene_dFOSDEM 2017

?

?

@etiene_dFOSDEM 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

ESP8266 module

Dev board

+ AI-Thinker

@etiene_dFOSDEM 2017

@etiene_dFOSDEM 2017

ESP8266 module(ESP-12)

Dev board

+ AI-Thinker

@etiene_dFOSDEM 2017

@etiene_dFOSDEM 2017

@etiene_dFOSDEM 2017

ESP8285

@etiene_dFOSDEM 2017

ESP32

@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

Demo time!

@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

Show-off

@etiene_dFOSDEM 2017

@etiene_dFOSDEM 2017

Show-off

@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

Going further

@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/

[email protected]

@etiene_d