Loading... 跟大家分享一个冷知识,如果你发现生活百无聊赖,晚上不知道吃什么好,那就打开电脑; 看看这里面都写了什么内容。 电路板:ESP8266-NodeMCU Internet Of Things 将收集到数据上传到Clound Computing,然后进行analysis,从而得到Best command,当IOT设备接收到相应的云计算命令后,相应的控制单元就会开启相关的功能; **tcp/ip协议** 应用层:http ftp mdns websocket osc 传输层:tcp udp 网络层:ip 网络接口层:ethernet wi-fi.. tcp注重data的完整性,数据受损重新发送;udp注重ping,传输受损不会重发。 **HTTP协议** GET /HTTP/1.1 请求行 Host:www.qqclwy.com User-Agent: Mozila/5.0(Windows NT 10.0; WOW64) Accept:txt/html Accept-Language:zh-CN,zh;q=0.8 Accept-Encoding:gzip,deflate,sdch Connection:Keep-Alive HTTP/1.1 200 OK 状态行 Date: Frl,29 Jul 2023 13:58:44 GMT Content-Type: text/html;charset=UTF-8 Content-Type: image/jpeg Status: 100~199:Server successfuly received the request 需进一步请求 300~399: Server successfuly received the request 需细化请求 **Connect Iot** ESP8266: https://cn.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=overview Arduino:https://www.arduino.cc/en/software Arduino附加开发板管理网址 http://arduino.esp8266.com/stable/package_esp8266com_index.json **esp8266建立ap/wifi** #include<ESP8266WIFI.h> ②#include<ESP8266WIFIMulti.h> const char *ssid = "qqclwy-maker"; const char *password = "12345678"; ②ESP8266WIFIMulti wifiMulti; Serial.begin(9600); WIFI.softAP/begin(ssid, password); ②wifiMulti.addAP("qqclwy1-maker","123456"); ②wifiMulti.addAP("qqclwy2-maker","654321"); ②...... Serial.println(WiFi.softAPIP/localIP()); //重连 int i = 0; while(WIFI.status/②wifiMulti.run() != WL_CONNECTED){ delay(1000); Serial.println(i++);} **esp8266芯片构建web服务** ```cpp #include <ESP8266WiFi.h> #include <ESP8266WiFiMulti.h> #include <ESP8266WebServer.h> ESP8266WiFiMulti wifiMulti; ESP8266WebServer esp8266_server(80); //建立对象,port80 void setup(void){ Serial.begin(9600); //串口通讯 wifiMulti.addAp("qqclwy-maker","12345678"); int i = 0; while(wifiMulti.run() != WL_CONNECTED){ delay(1000); Serial.print(i++);Serial.print(' '); } Serial.println('\n'); Serial.print("Connected to "); Serial.println(WiFi.SSID()); Serial.print("IP address:\t"); Serial.println(WiFi.localIP()); esp8266_server.begin(); esp8266_server.on("\",handleRoot); /*200,不同page调用不同function*/ esp8266_server.onNotFound(handleNotFound); /*404*/ Serial.println("HTTP esp8266_server started"); void loop(void){ esp8266_server.handleClient(); } void handleRoot(){ esp8266_server.send(200,"text/plain","Hello from ESP8266"); } void handleNotFound(){ esp8266_server.send(404,"text/plain","404: Not found"); } } ``` 最后修改:2023 年 10 月 08 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏
1 条评论
学了,孩子很爱吃