Table of Contents

NodeMCU

After flashing NodeMCU firmware it is recommended to erase filesystem:

file.format()

This firmware gives LUA command line on serial console. There is no direct way to upload files with lua script into module. Instead of this, file is created using lua command: open file, write some strings, close file.

file.open("init.lua","w")
file.writeline([[print("WIFI control")]])
file.writeline([[wifi.setmode(wifi.SOFTAP)]])
file.close()

This method is not comfortable, better is to use tool like http://esp8266.ru/esplorer/ (source on github) or https://github.com/GeoNomad/LuaLoader python script

Online page to make online custom builds: custom builds: http://frightanic.com/nodemcu-custom-build/

Programming

Saving memory

Scan WiFi

function listap(t)
  for k,v in pairs(t) do
    print(k.." : "..v)
  end
end
wifi.sta.getap(listap)

Connect to WiFi

wifi.setmode(wifi.STATION)
wifi.sta.config("HOMENET","mysecret")
print(wifi.sta.getip())

Scan 1 wire bus

ow.setup(1)
print (ow.reset(1)) -- print 1 if device found

Resolving DNS

It is not so easy. It need socket instance which will be used only for one DNS request, then socket will be destroyed. Response is performed by callback. There is sth about easier API: https://github.com/nodemcu/nodemcu-firmware/issues/189

Compile to byte code

You can compile everytihn except init.lua.

node.compile("myprog.lua")

Will produce myprog.lc.

Other Projects

Free Cloud/Server services

todo