NodeMCU
![]() NodeMCU DEVKIT 1.0 NodeMCU DEVKIT 1.0 BOTTOM | |
Developer | ESP8266 Opensource Community |
---|---|
Type | Single-board microcontroller |
Operating system | XTOS |
CPU | ESP8266[1](LX106[2]) |
Memory | 20kBytes |
Storage | 4MBytes[3] |
Power | USB |
Website | http://www.nodemcu.com |
NodeMCU is an opensource IoT platform.[4][5] It uses the Lua scripting language. It is based on the eLua project, and builded on ESP8266 sdk 0.9.5. It uses many open source projects, such as lua-cjson,[6] and spiffs.[7] It includes firmware which runs on esp8266 Wi-Fi SoC, and hardware[8] which is based on ESP-12 module.
History
NodeMCU was created shortly after the ESP8266 came out. In December 30, 2013, Espressif systems began production of the ESP8266.[9] The ESP8266 is a Wi-Fi SoC integrated with an LX106 core, widely used in IoT applications (See related projects[10][11][12]). In 13 Oct 2014, Hong committed the first file of nodemcu-firmware to github,[13] and the NodeMCU project started. From then on more and more developers from ESP8266 opensource community joined the NodeMCU developer team. On 1 Dec 2014, Huang R committed the gerber file of an ESP8266 board, then the NodeMCU project have the first open-hardware which named devkit 1.0,[14] thus NodeMCU was not only a firmware anymore, but also a platform. In 31 Dec 2014, Tuan PM ported MQTT client library from Contiki to the ESP8266 SoC platform,[15] and committed to NodeMCU project, then NodeMCU was able to support the MQTT IoT protocol, using Lua to access the MQTT broker, it is an important update of firmware. Another important update was on 30 Jan 2015, when Devsaurus ported the u8glib[16] to NodeMCU project,[17] enabling NodeMCU to easily drive LCD, Screen, OLED, even VGA displays.
Related projects
The Button
The Button is a Wi-Fi connected push button designed by Peter Jennings.[10] The button is one of those project that is easy to make and useful in more ways than we can count. The idea is simple. Press the button and a connection is made to a web server which will perform the desired task, such as panic Button, doorbell, Booty Call, etc.
NodeUSB
NodeUSB is an open IoT platform for coders, hackers, makers, programmers and everyone else. Kit is based on (ESP8266), size is similar to USB driver. Easy to code(Lua), easy to develop(Web IDE), easy to expand by USB. Plug-n-Play, Production ready, prototype very close to end product, using NodeMCU firmware.[11] It have a development kit and Web IDE, and Lua script package completed .
ijWatch
ijWatch is an open-hardware and open-source Wi-Fi smartwatch, using OLED screen and running NodeMCU firmware.[12] As far as we can tell the first real smartwatch, the first without Bluetooth and also the first opensource smartwatch without an Arduino.
Before using
Flash the firmware
nodemcu_latest.bin: 0x00000
for most esp8266 modules, just pull GPIO0 down and restart.
You can use the nodemcu-flasher to burn the firmware.
Or, if you build your own bin from source code.
0x00000.bin: 0x00000
0x10000.bin: 0x10000
Better run file.format() after flash
Connect the hardware in serial
If using NodeMCU devkit, just install CH340G driver, and plug it in your PC using a micro-usb cable. Then set baudrate to 9600, open the serial port. If using normal esp8266 module, a usb-ttl bridge required.
Start play
Connect to an AP
ip = wifi.sta.getip() print(ip) --nil wifi.setmode(wifi.STATION) wifi.sta.config("SSID","password") ip = wifi.sta.getip() print(ip) --192.168.18.110
Control GPIO
pin = 1 gpio.mode(pin,gpio.OUTPUT) gpio.write(pin,gpio.HIGH) print(gpio.read(pin))
HTTP request
-- A simple http client conn=net.createConnection(net.TCP, 0) conn:on("receive", function(conn, payload) print(payload) 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")
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) conn:on("sent",function(conn) conn:close() end) end)
Connect to MQTT Broker
-- init mqtt client with keepalive timer 120sec m = mqtt.Client("clientid", 120, "user", "password") -- setup Last Will and Testament (optional) -- Broker will publish a message with qos = 0, retain = 0, data = "offline" -- to topic "/lwt" if client don't send keepalive packet m:lwt("/lwt", "offline", 0, 0) m:on("connect", function(con) print ("connected") end) m:on("offline", function(con) print ("offline") end) -- on publish message receive event m:on("message", function(conn, topic, data) print(topic .. ":" ) if data ~= nil then print(data) end end) -- for secure: m:connect("192.168.11.118", 1880, 1) m:connect("192.168.11.118", 1880, 0, function(conn) print("connected") end) -- subscribe topic with qos = 0 m:subscribe("/topic",0, function(conn) print("subscribe success") end) -- or subscribe multiple topic (topic/0, qos = 0; topic/1, qos = 1; topic2 , qos = 2) -- m:subscribe({["topic/0"]=0,["topic/1"]=1,topic2=2}, function(conn) print("subscribe success") end) -- publish a message with data = hello, QoS = 0, retain = 0 m:publish("/topic","hello",0,0, function(conn) print("sent") end) m:close(); -- you can call m:connect again
UDP client and server
-- a udp server s=net.createServer(net.UDP) s:on("receive",function(s,c) print(c) end) s:listen(5683) -- a udp client cu=net.createConnection(net.UDP) cu:on("receive",function(cu,c) print(c) end) cu:connect(5683,"192.168.18.101") cu:send("hello")
References
- ↑ Kumar, Abhijeet, and Apoorva Sharma. "Internet of Life (IOL)." (2015). ISBN 978-93-5156-328-0
- ↑ Brian Benchoff. "An SDK for the ESP8266 Wi-Fi chip". Hackaday.
- ↑ Vowstar. "NodeMCU Devkit". Github. NodeMCU Team. Retrieved 2 April 2015.
- ↑ Zeroday. "A lua based firmware for wifi-soc esp8266". Github. Retrieved 2 April 2015.
- ↑ Hari Wiguna. "NodeMCU LUA Firmware". Hackaday. Retrieved 2 April 2015.
- ↑ Mpx. "Lua CJSON is a fast JSON encoding/parsing module for Lua". Github. Retrieved 2 April 2015.
- ↑ Pellepl. "Wear-leveled SPI flash file system for embedded devices". GitHub. Retrieved 2 April 2015.
- ↑ Brian Benchoff. "A DEV BOARD FOR THE ESP LUA INTERPRETER". Hackaday. Retrieved 2 April 2015.
- ↑ Espressif system (December 30, 2013). "IoT Wi-Fi 802.11b/g/n integrated SoC implementation of volume production". 中国上海讯. Retrieved 2 April 2015.
- ↑ 11.0 11.1 NodeUSB. "An open IoT platform that simply works.". NodeUSB. Retrieved 2 April 2015.
- ↑ 12.0 12.1 Anne Jan Brouwer. "ijWatch-Part of IJhack project ijWare". ijWare. Retrieved 2 April 2015.
- ↑ Hong. "First commit of NodeMCU Firmware". Github. Retrieved 2 April 2015.
- ↑ Huang R. "Initial design of NodeMCU devkit". Github. Retrieved 2 April 2015.
- ↑ Tuan PM. "MQTT client library for ESP8266". Github. Retrieved 2 April 2015.
- ↑ Olikraus; Daniel Sittig. "Universal Graphics Library for 8 Bit Embedded Systems". Google code. Retrieved 2 April 2015.
- ↑ Devsaurus. "U8glib for esp8266". Github. Retrieved 2 April 2015.
External links
|