NodeMCU quick start, nodemcuquickstart

Source: Internet
Author: User
Tags mqtt broker

NodeMCU quick start, nodemcuquickstart
What is NodeMCU?

NodeMCUIs an open-source Iot platform. It is programmed in Lua scripting language. This platform is based on eLua] Open-Source Project. ESP8266 sdk 0.9.5 is used at the underlying layer. The platform uses many open-source projects, such as lua-cjson, spiffs. NodeMCU contains firmware that can run on the esp8266 Wi-Fi SoC chip, and hardware based on the ESP-12 module.

It is based on the lua language and provides advanced APIs for encapsulating esp8266 hardware operations. This allows developers to deal with underlying hardware in a way similar to arduino, so that software developers can easily operate hardware devices; at the same time, NodeMcu also provides event-driven network APIs, and Nodejs-style programming methods make Internet developers alike.

NodeMcu Dev Kit, the first-generation Development Board launched by NodeMcu, expands the esp8266 encapsulation module ESP12 launched by Anxin technology, including:

  • D1 ~ D10: can be reused as GPIO, PWM, I2C, 1-Wire
  • A0: 1-way ADC
  • USB Power Supply
  • USB to serial port debugging Interface

The available RAM is 20 Kbyte. Currently, the 512 K FLash is used, and the user's available storage space is 150 Kbyte.. At the same time, use NodeMcu Flash Programmer to automatically burn the firmware (For details, refer to subsequent articles ).

The low-cost ESP8266 hardware and highly abstract NodeMcu API will boost the creative ideas of many developers and facilitate your prototype development!

Open-source software and hardware, lua advanced language programming, support for wifi, TCP/IP, UDP, HTTP, MQTT and other protocols, Development Board 39 yuan


History

NodeMCU is started after ESP8266 come out. In December 30,201 3, Espressif systems begin production of ESP8266.[9] ESP8266 is an Wi-Fi SoC and integrated with LX106 core, widely used in IoT applications (See related projects[10][11][12]). In 13 Oct 2014, Hong committed first file of nodemcu-firmware to github,[13] NodeMCU project started. and then more and more developers from ESP8266 opensource community join in NodeMCU developer team. on 1 Dec 2014, Huang R commit thegerber file of an ESP8266 board, then NodeMCU project have the first open-hardware which named devkit 1.0,[14] thus NodeMCU is not only a firmware, it becomes a platform. In 31 Dec 2014, Tuan PM port MQTT client library fromContiki to ESP8266 SoC platform,[15] and commit to NodeMCU project, then NodeMCU can support MQTT IoT protocol, using Lua access MQTT broker, it is an important update of firmware. another important update is in 30 Jan 2015, Devsaurus port u8glib[16] to NodeMCU project,[17] and NodeMCU can drive LCD, Screen, OLED, even VGA display module easily.

Related Websites

Hardware Purchase: http://item.taobao.com/item.htm? Spm = a230r. 1.14.1.ogDtJv & id = 43189493943 & ns = 1 & abbucket = 9 # detail

Wikipedia-http://en.wikipedia.org/wiki/NodeMCU

Official Website: http://nodemcu.com/index_cn.html

Forum: http://bbs.nodemcu.com/

Source code: https://github.com/nodemcu

Firmware download: http://bbs.nodemcu.com/t/nodemcu-firmware-download-build-20150318-new-location/27

CHM format: http://bbs.nodemcu.com/t/nodemcu-de-apisu-cha-shou-ce/74

NodeMCU hardware introduction:

Schematic diagram, hardware interface definition

Http://bbs.nodemcu.com/t/nodemcu-devkit-v0-dot-9-ying-jian-shuo-ming-shu-yin-jiao-shuo-ming-yu-zhu-yi-shi-xiang/49/1

Get started with NodeMCU

NodeMcu Introduction: (1) Overview

Http://bbs.nodemcu.com/t/nodemcujie-shao-gai-shu/25

NodeMcu Introduction: (2) firmware burning

Http://bbs.nodemcu.com/t/nodemcu/22/8

NodeMcu Introduction: (3) Startup File init. lua

Http://bbs.nodemcu.com/t/nodemcujie-shao-san-qi-dong-wen-jian-init-dot-lua/24

NodeMcu Introduction: (4) download the *. lua File

Http://bbs.nodemcu.com/t/nodemcu-lua/26

Three-hour introduction to NodeMcu (how to connect to yeelink)

Http://bbs.nodemcu.com/t/nodemcusan-xiao-shi-ru-men/104

Sample Code 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("Connect to MQTT Broker
-- init mqtt client with keepalive timer 120secm = 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 packetm: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 eventm:on("message", function(conn, topic, data)  print(topic .. ":" )  if data ~= nil then    print(data)  endend) -- 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 = 0m: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 = 0m:publish("/topic","hello",0,0, function(conn) print("sent") end) m:close();-- you can call m:connect again
UDP client and server
-- a udp servers=net.createServer(net.UDP)s:on("receive",function(s,c) print(c) end)s:listen(5683) -- a udp clientcu=net.createConnection(net.UDP)cu:on("receive",function(cu,c) print(c) end)cu:connect(5683,"192.168.18.101")cu:send("hello")

NodeMCU advanced

NodeMCU hardware is based on ESP8266 and the software is based on elua. To improve the NodeMCU firmware, you must master ESP8266 and elua.

ESP8266 related resources

ESP8266 Quick Start

Http://www.benlo.com/esp8266/esp8266QuickStart.html

Forum

Http://www.esp8266.com/

Getting Started with ESP8266 on seeedstudio

Http://www.seeedstudio.com/blog/2014/09/11/getting-started-with-esp8266/

Elua related resources

Http://www.eluaproject.net/

There is a problem with the description of cross-compilation on quickstart on the official website. I wrote a description after my own experiment. Please refer to my blog:

Learning elua (1) -- Introduction
Http://blog.csdn.net/coolwaterld/article/details/39007115

Learning elua (II) -- compiling and writing

Http://blog.csdn.net/coolwaterld/article/details/39007587

Learning elua (iii) -- customize elua compilation options

Http://blog.csdn.net/coolwaterld/article/details/39049239

Learning elua (4) -- using elua

Http://blog.csdn.net/coolwaterld/article/details/39050387

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.