This is an old revision of the document!


Dokumentace k NodeMCU firmware skriptovacího prostředí na adrese NodeMCU LUA Scripting Documentation.

Souborová struktura

Po rebootu NodeMCU spustí inicializační soubor init.lua. Nelze vytvářet složky.

Příklad použití init.lua a wifi.lua:

Soubor init.lua

-- init.lua --

-- Global Variables (most of the time keep it empty)

-- Run the wifi file
dofile("wifi.lua")

Soubor wifi.lua

-- Fill up correct setup
local ssid = "WiFiNET"
local pass = "bubabbaba"

-- Configure Wireless Internet
print('\nProcesing wifi.lua\n')
wifi.setmode(wifi.STATION)
print('set mode=STATION (mode='..wifi.getmode()..')\n')
print('MAC Address: ',wifi.sta.getmac())
print('Chip ID: ',node.chipid())
print('Heap Size: ',node.heap(),'\n')
-- Wifi Config Start
wifi.sta.config(ssid,pass)
-- Wifi Config End

-- WiFi Connection Verification
tmr.alarm(0, 1000, 1, function()
    if wifi.sta.getip() == nil then
        print("Connecting to AP...\n")
    else
        ip, nm, gw=wifi.sta.getip()
        print("IP Info: \nIP Address: ",ip)
        print("Netmask: ",nm)
        print("Gateway Addr: ",gw,'\n')
        tmr.stop(0)
    end
end)
  • project/nodemcu_le.1479497542.txt.gz
  • Last modified: 2016/11/18 20:32
  • by licho