WiFiMCU基于庆科最新WiFi模块EMW3165。直接运行Lua脚本,操作硬件资源,实现IOT快速开发。 EMW3165 是由上海庆科信息技术有限公司开发的一款低功耗嵌入式WIFI 模块。它集成了 一个无线射频芯片和一个型号为STM32F411CE 的Cortex-M4 微控制器,内置了独一无二的 “self-hosted” WIFI 网络函数库以及应用组件。此外,还提供2M 字节的片外flash、512K 字节的片内flash、128K 字节的RAM 以及丰富的外设资源。
WiFiMCU的设计和实现都借鉴了NodeMCU开源项目,在此感谢。
比Arduino更简单的交互:通过UART/Telnet交互,屏蔽MCU寄存器设置,脚本操作硬件,无需编译直接运行;
硬件可靠,接口丰富:STM32 MCU品质,可外接多种类型传感器、显示器和执行器;
用Lua编写IOT应用:30秒实现WiFi模块连接无线路由器,发送数据到远程服务器;提供丰富的WiFi和网络操作函数,实现复杂网络应用
硬件特点
封装标准Lua解释器、串口交互、WiFi和Net模块、文件系统、外设模块
串口工具(putty、Tera Term Pro等),串口参数:115200,n,8,1
_ _ _____ _ _ _ __ _ __
' ) / / '' ) ) ) / )' ) /
/ / / o ,-/-, o / / / / / /
(_(_/ <_(_/ <_/ ' (_(__/ (__/
@_@Design_by_doit_based_on_Lua_5.1.4
cannot open init.lua
>
案例
>cfg={ssid='Doit_3165',pwd=''}
>wifi.startap(cfg)
>cfg={ssid='Doit_3165',pwd=''} wifi.startap(cfg)
>function listen_cb(c,ip,port)
c:on("disconnect",function(c) end)
c:on("sent",function(con) end)
c:on("receive",function(c,pl)
c:send([[HTTP/1.1 200 OK
Server: WiFiMCU
Content-Type:text/html
Content-Length: 19
Connection: close]]..'\r\n\r\n'..[[
Welcome to WiFiMCU!]]) end)
end
>sk=net.new(net.TCP,net.SERVER) sk:listen(80,listen_cb)
>print(wifi.sta.getip())
0.0.0.0
>cfg={ssid="Doit",pwd="123456789"} wifi.startsta(cfg)
>print(wifi.sta.getip())
192.168.1.112
>sk2=net.new(net.TCP,net.CLIENT)
>sk2:on("connect",function(c) print("client connected") c:send("From WiFiMCU") end)
>sk2:on("receive",function(c,pl) print("receive data:"..pl) c:send("Hello WiFiMCU")end)
>sk2:connect(6579,"115.29.109.104")
>gpio.mode(6,gpio.INPUT)
>print(gpio.read(6))
0
>print(gpio.read(6))
1
>gpio.mode(6,gpio.OUTPUT)
>gpio.write(6,gpio.HIGH)
> function tmr_cb() print('tmr1 is called') end
> tmr.start(1,1000,tmr_cb)
> tmr1 is called
> file.open ("test.lua","w+")
> file.write("this is a test")
> file.close()
> file.open ("test.lua","r")
> data=file.read()
> print(data)
this is a test
> file.close()
>
>file.open ("init.lua","w+")
>file.write("print('Hello world!')")
>file.close()
>mcu.reboot()