meta data for this page
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
esp8266:nodemcu [2015/09/20 22:00] – created niziak | home_automation:esp8266:nodemcu [2017/01/19 07:55] (current) – [Other Projects] niziak | ||
---|---|---|---|
Line 2: | Line 2: | ||
After flashing NodeMCU firmware it is recommended to erase filesystem: <code lua> | After flashing NodeMCU firmware it is recommended to erase filesystem: <code lua> | ||
+ | |||
+ | 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. | ||
+ | <code lua> | ||
+ | file.open(" | ||
+ | file.writeline([[print(" | ||
+ | file.writeline([[wifi.setmode(wifi.SOFTAP)]]) | ||
+ | file.close() | ||
+ | </ | ||
+ | This method is not comfortable, | ||
+ | or [[https:// | ||
Online page to make online custom builds: | Online page to make online custom builds: | ||
custom builds: http:// | custom builds: http:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
- | https:// | + | ====== Programming ====== |
- | https:// | + | * Devel API (latest): [[https:// |
- | https:// | + | * GPIO MAP: [[https:// |
- | http:// | + | |
- | ===== Programming ===== | + | * Current API: [[https:// |
- | Devel API (latest): [[https:// | + | |
- | Current API: [[https:// | + | |
- | ==== Connect to WiFi ==== | + | ===== Saving memory ===== |
+ | * Avoid upvalues for context passed between event callbacks, as its very difficulat to get a handle on memory leaks created by these. Only use globals for this usecase. | ||
+ | * Nil globals once they are no longer needed so that they can be properly GCed. | ||
+ | * Allocate resources and create closures on a just-in-time basis. | ||
+ | * The cost of require or dofile is relatively small, so break your program into overlays one per event and use a small stub function as a callback to load each. | ||
+ | * Use compiled .lc files and load using dofile(). | ||
+ | |||
+ | ===== Scan WiFi ===== | ||
+ | <code lua> | ||
+ | function listap(t) | ||
+ | for k,v in pairs(t) do | ||
+ | print(k.." | ||
+ | end | ||
+ | end | ||
+ | wifi.sta.getap(listap) | ||
+ | </ | ||
+ | |||
+ | ===== Connect to WiFi ===== | ||
<code lua> | <code lua> | ||
wifi.setmode(wifi.STATION) | wifi.setmode(wifi.STATION) | ||
Line 24: | Line 53: | ||
</ | </ | ||
- | ==== Scan 1 wire bus ==== | + | ===== Scan 1 wire bus ===== |
<code lua> | <code lua> | ||
ow.setup(1) | ow.setup(1) | ||
- | print (ow.reset(1)) | + | print (ow.reset(1)) |
</ | </ | ||
- | ===== Projects | + | ===== Resolving DNS ===== |
- | ==== 1-wire | + | 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. |
- | [[http:// | + | There is sth about easier API: [[https:// |
+ | |||
+ | ===== Compile to byte code ===== | ||
+ | You can compile everytihn except init.lua. | ||
+ | < | ||
+ | Will produce myprog.lc. | ||
+ | |||
+ | ====== Other Projects ====== | ||
+ | * 1-wire temp sensor reporting to [[http:// | ||
+ | * 1-wire temp sensor reporting to [[http:// | ||
+ | * [[http:// | ||
+ | * 1-wire temp sensor [[https:// | ||
+ | * Control 2 GPIO from Web [[http:// | ||
+ | * Http server [[https:// | ||
+ | * Remote update [[http:// | ||
+ | |||
+ | ===== Free Cloud/ | ||
+ | * Thingspeak: [[http:// | ||
+ | * Telit: [[http:// | ||
+ | * Google: [[https:// | ||
+ | * IBM: [[https:// | ||
+ | |||
+ | todo | ||
+ | * https:// | ||