1 Overview
Table of Contents
[Complete Listing of Documentation Released]
Environment
进行软件二次开发,请先下载并安装编译环境。
注:密码是 qudl
2. Firmwares
[[RTOS SDK Release] ESP8266_RTOS_SDK_V1.3.0_15_11_02]
[]
esp_iot_sdk 软件是最基本的
IOT_Demo 和 AT 的编译都基于它。
2、IOT_Demo 位于软件包中 "examples" 文件夹,给出三种物联网设备“智能开关”,“灯”,“传感器”的简单demo,三种设备在user_config.h 中定义,请每次只使能一种设备调试~
3、AT 是另一个应用demo,示范 ESP8266 作为 slave 外接一个 Host,Host 通过 AT 指令控制 ESP8266 联网传数据等操作。
4、AT 是与 IOT_Demo 同一级别的应用demo,请勿同时拷贝到文件夹“app” 编译。未改动代码的情况下,要么作为独立运行的 IOT_Demo,要么作为附属 wifi 功能的 AT
3. Subsystem
MAC
Power Saving
[Features:light-sleep and deep-sleep under sdkV0.9.5]
4. Application based on Lua
[http://bbs.nodemcu.com/t/nodemcu/104]
connect usb cable to dev broad.
turn off the wifi card power switch
take off flash firmware cap
open "ESP8266烧录工具/frame_test.exe"
choose the firmware to be flash
click start flash
turn on the wifi card power switch
- Example 1:
try hello world example
> print("hello,world!")
stdin:1: unexpected symbol near 'char(27)'
> print("a")
a
> print("hello,world!")
hello,world!
Example 2:
try wifi connection
> print(wifi.sta.getip())
stdin: bad header in precompiled chunk
> print(wifi.sta.getip())
stdin: bad header in precompiled chunk
> print(wifi.sta.getip())
nil
> wifi.setmode(wifi.STATION)
> wifi.sta.config("AP name","password")
> print(wifi.sta.getip())
nil
> print(wifi.sta.getip())
nil
> wifi.setmode(wifi.STATION)
stdin:1: unexpected symbol near 'char(3)'
> wifi.setmode(wifi.STATION)
> wifi.sta.config("AP name","password")
> print(wifi.sta.getip())
stdin:1: unexpected symbol near 'char(3)'
> print(wifi.sta.getip())
192.168.18.246 255.255.255.0 192.168.18.1
C:\>ping 192.168.18.246 -t
Pinging 192.168.18.246 with 32 bytes of data:
Reply from 192.168.18.246: bytes=32 time=173ms TTL=255
Reply from 192.168.18.246: bytes=32 time=176ms TTL=255
Ping statistics for 192.168.18.246:
Packets: Sent = 2, Received = 2, Lost = 0 (0% loss)
Approximate round trip times in milli-seconds:
Minimum = 173ms, Maximum = 176ms, Average = 174ms
Example 3:
lua code:
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
print(payload)
conn:send("
Hello, NodeMCU.
")
end)
end)
Upload Lua code via Nodemcu studio
[Nodemcu Studio 2015 build20150111.rar]
visit [http://192.168.18.246/] in browser
you can see text in browser
"
Hello, NodeMCU.
"and in console, you will see:
> dofile("simplehttpserver.lua")
> GET / HTTP/1.1
Host: 192.168.18.246
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
visit [http://192.168.18.246/addressCode] in browser
GET /addressCode HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: 192.168.18.246
DNT: 1
Connection: Keep-Alive
Example 4
Use http request in browser to control gpio (light)
pin=0
gpio.mode(pin,gpio.OUTPUT)
lightOn=0
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
print(payload)
if lightOn==0 then
lightOn=1
gpio.write(pin,gpio.HIGH)
else
lightOn=0
gpio.write(pin,gpio.LOW)
end
conn:send("
Hello, NodeMCU.
")end)
end)