參考連結: NodeMCU API指令
node module
node.led --deprecated
node.key --deprecated
node.readvdd33 --deprecated
node.input
node.output
node.compile
node.info
node.chipid
node.flashid
node.heap
node.restart
> print(node.info())
0 9 6 10492404 1458415 4096 2 40000000
==>SDK Version : 0.9.6
==>chipid : 10492494
==>flashid:1458415 (0x1640EF) 0xEF代表Winbond , 0x4016對應32Mbits
==>flashsize=4096 KBytes
==>flashmode=2 (DIO)
==>flashspeed=40000000 (40MHz)
http://code.coreboot.org/svn/flashrom/trunk/flashchips.h
> print(node.heap())
34288
>
==>剩餘可用memory : 34288 Bytes
wifi module
wifi.getmode
wifi.setmode
wifi.startsmart
wifi.stopsmart
wifi.sleeptype
wifi.sta module
node.output
node.compile
node.info
node.chipid
node.flashid
node.heap
node.restart
> print(node.info())
0 9 6 10492404 1458415 4096 2 40000000
==>SDK Version : 0.9.6
==>chipid : 10492494
==>flashid:1458415 (0x1640EF) 0xEF代表Winbond , 0x4016對應32Mbits
==>flashsize=4096 KBytes
==>flashmode=2 (DIO)
==>flashspeed=40000000 (40MHz)
http://code.coreboot.org/svn/flashrom/trunk/flashchips.h
::1458400 (0x1640E0) => 32Mbits
::1458415 (0x1640EF) => 32Mbits
#define WINBOND_NEX_ID 0xEF /* Winbond (ex Nexcom) serial flashes */
#define WINBOND_NEX_W25Q32_V 0x4016 /* W25Q32BV; W25Q32FV in SPI mode (default) */
::1327343 (0x1440EF) => 8Mbits
#define WINBOND_NEX_W25Q80_V 0x4014 /* W25Q80BV */
::1261768 (0x1340C8) => 4Mbits
#define GIGADEVICE_ID 0xC8 /* GigaDevice */
#define GIGADEVICE_GD25Q40 0x4013 /* Same as GD25QB */
> print(node.heap())
34288
>
==>剩餘可用memory : 34288 Bytes
wifi module
wifi.getmode
wifi.setmode
wifi.startsmart
wifi.stopsmart
wifi.sleeptype
wifi.sta module
wifi.sta.config
wifi.sta.connect
wifi.sta.disconnect
wifi.sta.autoconnect
wifi.sta.getip
wifi.sta.getmac
wifi.sta.setip
wifi.sta.getap : scan and get AP list
wifi.sta.status
wifi.stat.getbroadcast
wif.iap module
wifi.ap.config
wifi.ap.getip
wifi.ap.setip
wifi.ap.getmac
wifi.ap.setmac
wifi.ap.getbroadcast
uart module
baud = 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400, 460800, 921600, 1843200, 2686400.
心得: Baud Rate可以儘量設高點,太低有時Lua command出錯"
> print("Heap=".. node.heap())
tmr.delay(1000)
print(no>> de.info())
stdin:2: ')' expected (to close '(' at line 1) near 'de'
由上看出,若輸出不夠快則輸入值會影響輸輸入,此應該是Lua的Bug吧!!!!!????(待查證)
註: 各廠USB-Serial不見得支援所有Baud Rate, 例如PL2303 在Ubuntu12.04下不支援 1843200 及2686400,不知是硬體還是軟體限制?
補充: 同樣Ubuntu環境用FT232RL可設達2686400, 貴一點還是值得的......
補充: 同樣Ubuntu環境用CH341不支援 1843200 及2686400
setup uart in init.lua
>print(uart.setup(0,921600,8,0,1,1))
921600
wifi.sta.connect
wifi.sta.disconnect
wifi.sta.autoconnect
wifi.sta.getip
wifi.sta.getmac
wifi.sta.setip
wifi.sta.getap : scan and get AP list
wifi.sta.status
wifi.stat.getbroadcast
wif.iap module
wifi.ap.config
wifi.ap.getip
wifi.ap.setip
wifi.ap.getmac
wifi.ap.setmac
wifi.ap.getbroadcast
uart module
baud = 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400, 460800, 921600, 1843200, 2686400.
註: 各廠USB-Serial不見得支援所有Baud Rate, 例如PL2303 在Ubuntu12.04下不支援 1843200 及2686400,不知是硬體
補充: 同樣Ubuntu環境用FT232RL可設達2686400, 貴一點還是值得的......
補充: 同樣Ubuntu環境用CH341不支援 1843200 及2686400
setup uart in init.lua
>print(uart.setup(0,921600,8,0,1,1))
921600
uart.setup
uart.on
uart.write
uart.on
uart.write
https://github.com/nodemcu/nodemcu-firmware/issues/15
https://github.com/nodemcu/nodemcu-firmware/issues/57
等待資料接收,最大可設255 Bytes, 下面範例為接收4個bytes
uart.on("data", 4, function(data) print("receive from uart:", data) if data=="quit" then uart.on("data") end end, 0) -- when '\r' is received. uart.on("data", "\r", function(data) print("receive from uart:", data) if data=="quit\r" then uart.on("data") end end, 0)
net module
net.createServer
net.createConnection
net.server module
net.server:listen
net.server.stop
net.socket module
net.socket:connect
net.socket.send
net.socket.on
net.socket.close
net.socket.dns
----------------------------------------------------------------------------------------------------------------
>wifi.setmode(wifi.SOFTAP)
>print(wifi.getmode())
2
>print(node.chipid())
10393897
>print("ESP_"..string.format("%X",node.chipid()))
ESP_9E9929
>print(wifi.ap.getip())
192.168.4.1 255.255.255.0 192.168.4.1
>print(wifi.ap.getbroadcast())
192.168.4.255
NodeMCU 的SoftAp Name= ESP_XXXXXX 聯入(XXXXXX表示ChipID) , 預設:不需密碼
>print(wifi.getmode())
2
>print(node.chipid())
10393897
>print("ESP_"..string.format("%X",node.chipid()))
ESP_9E9929
>print(wifi.ap.getip())
192.168.4.1 255.255.255.0 192.168.4.1
>print(wifi.ap.getbroadcast())
192.168.4.255
NodeMCU 的SoftAp Name= ESP_XXXXXX 聯入(XXXXXX表示ChipID) , 預設:不需密碼
沒有留言:
張貼留言