| Project owner: | lichnak, PeterBay |
| Interested: | |
| Related: | |
| Reference: | https://Espressif.com |
| License: | Uveďte původ-Zachovejte licenci; CC BY-SA |
Dokumentace k NodeMCU firmware skriptovacího prostředí na adrese NodeMCU LUA Scripting Documentation.
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)