看示例代码,实现一个http服务器,至于交互什么,要看你的需求~
-- Support HTTP and HTTPS, For example
-- HTTP POST Example with JSON header and body
http.post("http://somewhere.acceptjson.com/",
"Content-Type: application/json\r\n",
"{\"hello\":\"world\"}",
function(code, data)
print(code)
print(data)
end)
-- HTTPS GET Example with NULL header
http.get("https://www.vowstar.com/nodemcu/","",
function(code, data)
print(code)
print(data)
end)
-- You will get
-- >200
-- hello nodemcu
-- HTTPS DELETE Example with NULL header and body
http.delete("https://10.0.0.2:443","","",
function(code, data)
print(code)
print(data)
end)
-- HTTPS PUT Example with NULL header and body
http.put("https://testput.somewhere/somewhereyouput.php","","",
function(code, data)
print(code)
print(data)
end)
-- HTTP RAW Request Example, use more HTTP/HTTPS request method
http.request("http://www.apple.com:80/library/test/success.html","GET","","",
function(code, data)
print(code)
print(data)
end)
在使用前要确保电压为3.3V 接线为3v3- 3.3V电源 RX和TX分别接USB转串口线的TX和RX,即要交叉着接。最后还有一个EN引脚接到3.3V置高。 串口初始波特率为115200(可修改)。最后上电连接电脑串口终端如下图串口设置如上图,看到乱码不要慌,属正常现象,这里重点说一下一定要把(发送新行)勾上,不然指令不起作用。如果其他串口软件没有这个选项,那么在每个指令后面都要按一下回车键,如果是使用单片机发指令则要跟上"\r\n"。最终上电后出现ready,可以直接输入测试指令AT,返回OK字样表示模块正常。
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)