<!doctypehtml><html class=no-js lang=en><meta charset=utf-8><meta content=IE=edge http-equiv=X-UA-Compatible><meta content=width=device-width,initial-scale=1.0 name=viewport><meta content="Description of the NodeMCU documentation"name=description><link rel="shortcut icon"href=./img/favicon.ico><title>
   Overview - NodeMCU Documentation
  </title><link href=https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700 rel=stylesheet><link href=./css/theme.css rel=stylesheet><link href=./css/theme_extra.css rel=stylesheet><link href=./css/highlight.css rel=stylesheet><link href=./css/extra.css rel=stylesheet><link href=https://assets.readthedocs.org/static/css/badge_only.css rel=stylesheet><link href=https://assets.readthedocs.org/static/css/readthedocs-doc-embed.css rel=stylesheet><script>// Current page data
    var mkdocs_page_name = "Overview";
    var mkdocs_page_input_path = "index.md";
    var mkdocs_page_url = "/";</script><script src=./js/jquery-2.1.1.min.js></script><script src=./js/modernizr-2.8.3.min.js></script><script src=./js/highlight.pack.js></script><body class=wy-body-for-nav role=document><div class=wy-grid-for-nav><nav class="wy-nav-side stickynav"data-toggle=wy-nav-shift><div class=wy-side-nav-search><a class="icon icon-home"href=.> NodeMCU Documentation </a><div role=search><form action=./search.html class=wy-form id=rtd-search-form><input placeholder="Search docs"name=q></form></div></div><div aria-label="main navigation"class="wy-menu wy-menu-vertical"data-spy=affix role=navigation><ul class=current><li class="toctree-l1 current"><a class=current href=.> Overview </a> <ul class=subnav><li class=toctree-l2><a href=#nodemcu-documentation> NodeMCU Documentation </a></li><ul><li><a class=toctree-l3 href=#programming-model> Programming Model </a><li><a class=toctree-l3 href=#lua-flash-store-lfs> Lua Flash Store (LFS) </a><li><a class=toctree-l3 href=#releases> Releases </a><li><a class=toctree-l3 href=#up-to-date-documentation> Up-To-Date Documentation </a></ul></ul><li class=toctree-l1><span class=caption-text> Basics </span> <ul class=subnav><li><a href=getting-started/> Getting started </a><li><a href=build/> Building the firmware </a><li><a href=flash/> Flashing the firmware </a><li><a href=upload/> Uploading code </a><li><a href=compiling/> Compiling code </a><li><a href=support/> Support </a></ul><li class=toctree-l1><span class=caption-text> Reference </span> <ul class=subnav><li><a href=nodemcu-lrm/> NodeMCU Language Reference Manual </a><li><a href=nodemcu-pil/> Programming in NodeMCU </a></ul><li class=toctree-l1><span class=caption-text> FAQs </span> <ul class=subnav><li><a href=lua-developer-faq/> Lua Developer FAQ </a><li><a href=extn-developer-faq/> Extension Developer FAQ </a><li><a href=hardware-faq/> Hardware FAQ </a></ul><li class=toctree-l1><span class=caption-text> Whitepapers </span> <ul class=subnav><li><a href=lua53/> Lua 5.3 Support </a><li><a href=lfs/> Lua Flash Store (LFS) </a><li><a href=lcd/> Lua Compact Debug (LCD) </a><li><a href=sdcard/> Filesystem on SD card </a><li><a href=spiffs/> Internal filesystem </a></ul><li class=toctree-l1><span class=caption-text> Lua Modules </span> <ul class=subnav><li><a href=lua-modules/README/> Lua modules directory </a><li><a href=lua-modules/bh1750/> bh1750 </a><li><a href=lua-modules/bme280/> bme280 </a><li><a href=lua-modules/cohelper/> cohelper </a><li><a href=lua-modules/ds18b20/> ds18b20 </a><li><a href=lua-modules/ds3231/> ds3231 </a><li><a href=lua-modules/fifo/> fifo </a><li><a href=lua-modules/fifosock/> fifosock </a><li><a href=lua-modules/ftpserver/> ftpserver </a><li><a href=lua-modules/gossip/> gossip </a><li><a href=lua-modules/hdc1000/> hdc1000 </a><li><a href=lua-modules/httpserver/> httpserver </a><li><a href=lua-modules/imap/> imap </a><li><a href=lua-modules/liquidcrystal/> liquidcrystal </a><li><a href=lua-modules/lm92/> lm92 </a><li><a href=lua-modules/mcp23008/> mcp23008 </a><li><a href=lua-modules/mcp23017/> mcp23017 </a><li><a href=lua-modules/redis/> redis </a><li><a href=lua-modules/telnet/> telnet </a><li><a href=lua-modules/yeelink/> yeelink </a></ul><li class=toctree-l1><span class=caption-text> C Modules </span> <ul class=subnav><li><a href=modules/adc/> adc </a><li><a href=modules/ads1115/> ads1115 </a><li><a href=modules/adxl345/> adxl345 </a><li><a href=modules/am2320/> am2320 </a><li><a href=modules/apa102/> apa102 </a><li><a href=modules/bit/> bit </a><li><a href=modules/bloom/> bloom </a><li><a href=modules/bme280/> bme280 </a><li><a href=modules/bme280_math/> bme280_math </a><li><a href=modules/bme680/> bme680 </a><li><a href=modules/bmp085/> bmp085 </a><li><a href=modules/cjson/> cjson </a><li><a href=modules/coap/> coap </a><li><a href=modules/color-utils/> color-utils </a><li><a href=modules/cron/> cron </a><li><a href=modules/crypto/> crypto </a><li><a href=modules/dcc/> dcc </a><li><a href=modules/dht/> dht </a><li><a href=modules/encoder/> encoder </a><li><a href=modules/enduser-setup/> enduser setup / captive portal / WiFi manager </a><li><a href=modules/file/> file </a><li><a href=modules/gdbstub/> gdbstub </a><li><a href=modules/gpio/> gpio </a><li><a href=modules/hdc1080/> hdc1080 </a><li><a href=modules/hmc5883l/> hmc5883l </a><li><a href=modules/http/> http </a><li><a href=modules/hx711/> hx711 </a><li><a href=modules/i2c/> i2c </a><li><a href=modules/l3g4200d/> l3g4200d </a><li><a href=modules/mcp4725/> mcp4725 </a><li><a href=modules/mdns/> mdns </a><li><a href=modules/mqtt/> mqtt </a><li><a href=modules/net/> net </a><li><a href=modules/node/> node </a><li><a href=modules/ow/> ow (1-Wire) </a><li><a href=modules/pcm/> pcm </a><li><a href=modules/perf/> perf </a><li><a href=modules/pipe/> pipe </a><li><a href=modules/pixbuf/> pixbuf </a><li><a href=modules/pwm/> pwm </a><li><a href=modules/pwm2/> pwm2 </a><li><a href=modules/rfswitch/> rfswitch </a><li><a href=modules/rotary/> rotary </a><li><a href=modules/rtcfifo/> rtcfifo </a><li><a href=modules/rtcmem/> rtcmem </a><li><a href=modules/rtctime/> rtctime </a><li><a href=modules/si7021/> si7021 </a><li><a href=modules/sigma-delta/> sigma delta </a><li><a href=modules/sjson/> sjson </a><li><a href=modules/sntp/> sntp </a><li><a href=modules/softuart/> softuart </a><li><a href=modules/somfy/> somfy </a><li><a href=modules/spi/> spi </a><li><a href=modules/struct/> struct </a><li><a href=modules/switec/> switec </a><li><a href=modules/tcs34725/> tcs34725 </a><li><a href=modules/tls/> tls </a><li><a href=modules/tm1829/> tm1829 </a><li><a href=modules/tmr/> tmr </a><li><a href=modules/tsl2561/> tsl2561 </a><li><a href=modules/u8g2/> u8g2 </a><li><a href=modules/uart/> uart </a><li><a href=modules/ucg/> ucg </a><li><a href=modules/websocket/> websocket </a><li><a href=modules/wiegand/> wiegand </a><li><a href=modules/wifi/> wifi </a><li><a href=modules/wifi_monitor/> wifi.monitor </a><li><a href=modules/wps/> wps </a><li><a href=modules/ws2801/> ws2801 </a><li><a href=modules/ws2812/> ws2812 </a><li><a href=modules/ws2812-effects/> ws2812-effects </a><li><a href=modules/xpt2046/> xpt2046 </a></ul></ul></div>  </nav><section class=wy-nav-content-wrap data-toggle=wy-nav-shift><nav aria-label="top navigation"class=wy-nav-top role=navigation><i class="fa fa-bars"data-toggle=wy-nav-top> </i><a href=.> NodeMCU Documentation </a></nav><div class=wy-nav-content><div class=rst-content><div aria-label="breadcrumbs navigation"role=navigation><ul class=wy-breadcrumbs><li><a href=.> Docs </a> »<li>Overview<li class=wy-breadcrumbs-aside><a class="icon icon-github"href=https://github.com/nodemcu/nodemcu-firmware/edit/master/docs/index.md> Edit on GitHub </a></ul><hr></div><div role=main><div class=section><h1 id=nodemcu-documentation>NodeMCU Documentation <a title="Permanent link"class=headerlink href=#nodemcu-documentation> ¶ </a></h1><p>NodeMCU is an open source <a href=https://www.lua.org/> Lua </a> based firmware for the <a href=http://espressif.com/products/esp8266/> ESP8266 WiFi SOC from Espressif </a> and uses an on-module flash-based <a href=https://github.com/pellepl/spiffs> SPIFFS </a> file system. NodeMCU is implemented in C and is layered on the <a href=https://github.com/espressif/ESP8266_NONOS_SDK> Espressif NON-OS SDK </a> .<p>The firmware was initially developed as is a companion project to the popular ESP8266-based <a href=https://github.com/nodemcu/nodemcu-devkit-v1.0> NodeMCU development modules </a> , but the project is now community-supported, and the firmware can now be run on <em> any </em> ESP module.<p>â <a href=getting-started/> Getting Started </a><h2 id=programming-model>Programming Model <a title="Permanent link"class=headerlink href=#programming-model> ¶ </a></h2><p>The NodeMCU programming model is similar to that of <a href=https://en.wikipedia.org/wiki/Node.js> Node.js </a> , only in Lua. It is asynchronous and event-driven. Many functions, therefore, have parameters for callback functions. To give you an idea what a NodeMCU program looks like study the short snippets below. For more extensive examples have a look at the <a href=https://github.com/nodemcu/nodemcu-firmware/tree/release/lua_examples> <code>
           /lua_examples
          </code> </a> folder in the repository on GitHub.<pre><code class=lua>-- a simple HTTP server
srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
  conn:on("receive", function(sck, payload)
    print(payload)
    sck:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n&LTh1> Hello, NodeMCU. &LT/h1>")
  end)
  conn:on("sent", function(sck) sck:close() end)
end)
</code></pre><pre><code class=lua>-- connect to WiFi access point (DO NOT save config to flash)
wifi.setmode(wifi.STATION)
station_cfg={}
station_cfg.ssid = "SSID"
station_cfg.pwd = "password"
station_cfg.save = false
wifi.sta.config(station_cfg)
</code></pre><pre><code class=lua>-- register event callbacks for WiFi events
wifi.eventmon.register(wifi.eventmon.STA_CONNECTED, function(T)
  print("\n\tSTA - CONNECTED".."\n\tSSID: "..T.SSID.."\n\tBSSID: "..
  T.BSSID.."\n\tChannel: "..T.channel)
end)
</code></pre><pre><code class=lua>-- manipulate hardware like with Arduino
pin = 1
gpio.mode(pin, gpio.OUTPUT)
gpio.write(pin, gpio.HIGH)
print(gpio.read(pin))
</code></pre><p>â <a href=getting-started/> Getting Started </a><h2 id=lua-flash-store-lfs>Lua Flash Store (LFS) <a title="Permanent link"class=headerlink href=#lua-flash-store-lfs> ¶ </a></h2><p>In September 2018 support for a <a href=lfs/> Lua Flash Store (LFS) </a> was introduced. LFS allows Lua code and its associated constant data to be executed directly out of flash-memory; just as the firmware itself is executed. This now enables NodeMCU developers to create Lua applications with up to 256Kb Lua code and read-only constants executing out of flash. All of the RAM is available for read-write data!<h2 id=releases>Releases <a title="Permanent link"class=headerlink href=#releases> ¶ </a></h2><p>This project uses two main branches, <code>
          release
         </code> and <code>
          dev
         </code> . <code>
          dev
         </code> is actively worked on and it's also where PRs should be created against. <code>
          release
         </code> thus can be considered "stable" even though there are no automated regression tests. The goal is to merge back to <code>
          release
         </code> roughly every 2 months. Depending on the current "heat" (issues, PRs) we accept changes to <code>
          dev
         </code> for 5-6 weeks and then hold back for 2-3 weeks before the next snap is completed.<p>A new tag is created every time <code>
          dev
         </code> is merged back to <code>
          release
         </code> branch. They are listed in the <a href=https://github.com/nodemcu/nodemcu-firmware/releases> releases section on GitHub </a> . Tag names follow the <code>
          &LTSDK-version>-release_yyyymmdd
         </code> pattern.<h2 id=up-to-date-documentation>Up-To-Date Documentation <a title="Permanent link"class=headerlink href=#up-to-date-documentation> ¶ </a></h2><p>At the moment the only up-to-date documentation maintained by the current NodeMCU team is in English. It is part of the source code repository ( <code>
          /docs
         </code> subfolder) and kept in sync with the code.</div></div><footer><div aria-label="footer navigation"class=rst-footer-buttons role=navigation><a class="btn btn-neutral float-right"title="Getting started"href=getting-started/> Next <span class="icon icon-circle-arrow-right"> </span> </a></div><hr><div role=contentinfo></div> Built with <a href=http://www.mkdocs.org> MkDocs </a> using a <a href=https://github.com/snide/sphinx_rtd_theme> theme </a> provided by <a href=https://readthedocs.org> Read the Docs </a> .</footer></div></div></section></div><div style="cursor: pointer"class=rst-versions role=note><span class=rst-current-version data-toggle=rst-current-version> <a class="fa fa-github"style="float: left; color: #fcfcfc"href=https://github.com/nodemcu/nodemcu-firmware/> GitHub </a> <span style="margin-left: 15px"> <a style="color: #fcfcfc"href=getting-started/> Next » </a> </span> </span></div><script>var base_url = '.';</script><script src=./js/theme.js></script><script src=./js/extra.js></script><script src=./readthedocs-data.js></script><script src=https://assets.readthedocs.org/static/core/js/readthedocs-doc-embed.js></script><script src=https://assets.readthedocs.org/static/javascript/readthedocs-analytics.js></script><script src=./search/require.js></script><script src=./search/search.js></script>