https://www.cnblogs.com/gooutlook/p/16061136.html
1 | http: / / 192.168 . 1.103 / Control_SensorPin?sensor = sensor_all&action = GetData |
python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | # -*- coding:utf-8 -*- import requests import urllib.parse #pip install requests import time from multiprocessing import Process,Manager import json class Class_sensor_http: def __init__( self ): pass def SendHttp( self ,ip,dowhat): try : #http://192.168.1.103/Control_SensorPin?sensor=sensor_all&action=GetData #ip="192.168.1.103" values = { 'sensor' : 'sensor_all' , 'action' : 'GetData' } #将POST值URL编码 data = urllib.parse.urlencode(values) #dowhat="Control_SensorPin" url = "http://" + ip + "/" + dowhat + "?" + data response = requests.get(url) # 返回网页内容 #print(response.text) rec_msg = "" if response.content = = b '\x00' : rec_msg = "error" else : rec_msg = response.content.decode() return rec_msg except : print ( "read time out" ,ip) return "error" #print(response.status_code) # 获取响应状态码 200 #print(response.headers) # 获取响应头 {'Content-Type': 'text/html', 'Content-Length': '1', 'Connection': 'close'} #print(response.content) # 获取响应内容 b'\x00' #print(rec_msg) # 返回字节形式 def GetData( self ,ip_,data_addr,share_data,lock): while True : if share_data[ 9 ] = = 1 : print ( "http thread break." ) break time.sleep( 2 ) rec_msg1 = self .SendHttp(ip_, "Control_SensorPin" ) #print("rec======",rec_msg1) if rec_msg1 = = "error" : print ( "请检查设备链接" ,ip_) else : if rec_msg1 is not None : fengefu = '-' a = rec_msg1.strip().split(fengefu) # x.strip()#除去每行的换行符 按照:分割 #print(a) id_ = "".join(a[ 5 : 6 ]).strip() # 去除空格 pin_jiu_Value = "".join(a[ 0 : 1 ]).strip() # 去除空格 pin_mq135_Value = "".join(a[ 1 : 2 ]).strip() # 去除空格 pin_mq2_Value = "".join(a[ 2 : 3 ]).strip() # 去除空格 Humidity = "".join(a[ 3 : 4 ]).strip() # 去除空格 Temperature = "".join(a[ 4 : 5 ]).strip() # 去除空格 if id_ is not None \ and pin_jiu_Value is not None \ and pin_mq135_Value is not None \ and pin_mq2_Value is not None \ and Humidity is not None \ and Temperature is not None : #print(data) data_list = [] data_list.append(id_) data_list.append(pin_jiu_Value) data_list.append(pin_mq135_Value) data_list.append(pin_mq2_Value) data_list.append(Humidity) data_list.append(Temperature) with lock: share_data[data_addr] = data_list ''' if __name__ == '__main__': #1初始化共享内存 manager=Manager() share_data=manager.dict()#存str类型数据 #用几个必须预先初始化 否则后面无法访问 share_data[1]='0'# share_data[2]=['0','0','0','0','0','0']# data share_data[3]=['0','0','0','0','0','0']# data share_data[9]=0#是否有语音解析结果 #2线程锁 保护多个线成对数据控制 lock=manager.Lock() p_sensor = Class_sensor_http()#类的初始化 #线程 p1 = Process(target=p_sensor.GetData, args=("192.168.137.9:8080",2,share_data,lock)) p1.deamon=True #伴随主进程关闭而关闭 p1.start() p2 = Process(target=p_sensor.GetData, args=("192.168.137.49:8080",3,share_data,lock)) p2.deamon=True #伴随主进程关闭而关闭 p2.start() while 1: time.sleep(3) print("sensor1",share_data[2]) print("sensor2",share_data[3]) ''' |
esp解析
转发原始数据还是打包数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | #include <SoftwareSerial.h> SoftwareSerial portOne(D2, D1); / / rx tx / / SoftwareSerial portTwo(D8, D7); / / rx tx #include <ESP8266WiFi.h> #include <ESP8266WebServer.h> #include <FS.h> ESP8266WebServer server ( 80 ); / / 连接或者要辐射的wifi信息 / / String wifiName = ( "ESPWIFI_" + (String)ESP.getChipId()); / / 2 设置WIFI名称 String wifiName = "yaoyao" ; / / 2 设置WIFI名称 String password = "love123456" ; / / 需要连接的wifi热点密码 / / 登录账号密码 String LoginName = "admin" ; String LoginPwd = "admin" ; / / 工作模式 String work_mode = "STA" ; / / AP自己辐射wifi STA 链接wifi / / 本机ip 会自动修改 String LocaIP = "192.168.1.1" ; / / 跳转使用 int CanPost = 1 ; / / 记录本次请求是否处理完毕 / / 分割结果 #define sleng 12 //数组大小 比实际多一个 String split_result[sleng]; / / 手动动态调整数组大小,保证数组可以满足容量 / * 字符串分割 输入参数 String zifuchuan, 输入字符串 String fengefu, 分隔符号 - 可以是多个 String result[] 输出结果 * / void Split(String zifuchuan,String fengefu,String result[]) { int weizhi; / / 找查的位置 String temps; / / 临时字符串 int i = 0 ; do { weizhi = zifuchuan.indexOf(fengefu); / / 找到位置 if (weizhi ! = - 1 ) / / 如果位置不为空 { temps = zifuchuan.substring( 0 ,weizhi); / / 打印取第一个字符 zifuchuan = zifuchuan.substring(weizhi + fengefu.length(), zifuchuan.length()); / / 分隔后只取后面一段内容 以方便后面找查 } else { / / 上面实在找不到了就把最后的 一个分割值赋值出来以免遗漏 if (zifuchuan.length() > 0 ) temps = zifuchuan; } result[i + + ] = temps; / / Serial.println(result[i - 1 ]); / / 在这里执行分割出来的字符下面不然又清空了 temps = ""; } while (weizhi > = 0 ); } / * * * 网页系统API * 根据文件后缀获取html协议的返回内容类型 * / String getContentType(String filename){ if (server.hasArg( "download" )) return "application/octet-stream" ; else if (filename.endsWith( ".htm" )) return "text/html" ; else if (filename.endsWith( ".html" )) return "text/html" ; else if (filename.endsWith( ".css" )) return "text/css" ; else if (filename.endsWith( ".js" )) return "application/javascript" ; else if (filename.endsWith( ".png" )) return "image/png" ; else if (filename.endsWith( ".gif" )) return "image/gif" ; else if (filename.endsWith( ".jpg" )) return "image/jpeg" ; else if (filename.endsWith( ".ico" )) return "image/x-icon" ; else if (filename.endsWith( ".xml" )) return "text/xml" ; else if (filename.endsWith( ".pdf" )) return "application/x-pdf" ; else if (filename.endsWith( ".zip" )) return "application/x-zip" ; else if (filename.endsWith( ".gz" )) return "application/x-gzip" ; return "text/plain" ; } / * NotFound处理 * 用于处理没有注册的请求地址 * / void handleNotFound() { String path = server.uri(); Serial. print ( "load url:" ); Serial.println(path); String contentType = getContentType(path); String pathWithGz = path + ".gz" ; if (SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)){ if (SPIFFS.exists(pathWithGz)) path + = ".gz" ; File file = SPIFFS. open (path, "r" ); size_t sent = server.streamFile( file , contentType); file .close(); return ; } String message = "File Not Found\n\n" ; message + = "URI: " ; message + = server.uri(); message + = "\nMethod: " ; message + = ( server.method() = = HTTP_GET ) ? "GET" : "POST" ; message + = "\nArguments: " ; message + = server.args(); message + = "\n" ; for ( uint8_t i = 0 ; i < server.args(); i + + ) { message + = " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n" ; } server.send ( 404 , "text/plain" , message ); } / * 引脚更改处理 * 访问地址为htp: / / 192.162 .xxx.xxx / 返回主页面 * / void handleMain() { / * 返回信息给浏览器(状态码,Content - type , 内容) * 这里是访问当前设备ip直接返回一个String * / Serial. print ( "handleMain" ); File file = SPIFFS. open ( "/index.html" , "r" ); size_t sent = server.streamFile( file , "text/html" ); file .close(); return ; } / / 控制页面 - 本机处理函数 void handle_PinControl_DoMySelf(String action_) { } / / http: / / 192.168 . 1.103 / Control_SensorPin?sensor = sensor_all&action = GetData String REC_comdata = "{\"Mq2\":0,\"red\":0,\"tem\":0,\"hum\":0,\"AlramMsg\":\"every is ok\"}" ; String SendJsonMsg = "{\"Mq2\":0,\"red\":0,\"tem\":0,\"hum\":0,\"AlramMsg\":\"every is ok\"}" ; / / 控制页面请求函数处理 ESP数据给单片机,由单片机处理后返回数据 / / / Get_SensorData?action = all &sensor = all void handle_PinControl() { if (CanPost = = 1 ) { CanPost = 0 ; } else { server.send ( 200 , "text/html" , REC_comdata); return ; } if (server.hasArg( "action" ) && server.hasArg( "sensor" )) { / / 请求中是否包含有a的参数 String action = server.arg( "action" ); / / 获得动作 String sensor = server.arg( "sensor" ); / / 获得传感器型号 String ShowMsg = String() + "sensor-" + sensor + "-action-" + action + ";" ; Serial.println (ShowMsg); / / 电脑串口打印 / / 根据传感器型号进行控制 / / 本机处理 if (sensor = = "sensor_ESP" ){ handle_PinControl_DoMySelf(action); / / 调用本机函数处理 server.send ( 200 , "text/html" , "消息本机处理:" + ShowMsg); / / 返回数据 CanPost = 1 ; return ; } / / 转发单片机处理 else { / / 其他设备控制 / / 消息打包生成 ShowMsg = String() + sensor + "-" + action + ";" ; / / 转发给单片机处理 portOne. print (ShowMsg); / / 等待单片机回应消息 / / String REC_comdata; if (portOne.available()){ / / 发送端是加了换行符发送的 不加 \n 会导致连续发送两行积累 所以解析段必须去除 \n 字符 REC_comdata = portOne.readStringUntil( ';' ); / / REC_comdata = REC_comdata.replace( "\n" ,""); Serial. print ( "收到原始数据:" );Serial.println(REC_comdata); Split(REC_comdata, "-" ,split_result); / / 分割调用 String pin_jiu_Value = split_result[ 0 ]; String pin_mq135_Value = split_result[ 1 ]; String pin_mq2_Value = split_result[ 2 ]; String Humidity = split_result[ 3 ]; String Temperature = split_result[ 4 ]; String id_ = split_result[ 5 ]; SendJsonMsg = String( "{" ) + "\"pin_jiu_Value\":" + String(pin_jiu_Value) + "," + "\"pin_mq135_Value\":" + String(pin_mq135_Value) + "," + "\"pin_mq2_Value\":" + String(pin_mq2_Value) + "," + "\"Humidity\":" + String(Humidity) + "," + "\"Temperature\":" + String(Temperature) + "," + "\"id_\":" + "\"" + String(id_) + "\"" + "};" ; Serial. print ( "发送打包数据:" );Serial.println(SendJsonMsg); } / / server.send ( 200 , "text/html" , REC_comdata); / / 原始数据 server.send ( 200 , "text/html" , SendJsonMsg); / / EPS打包数据 CanPost = 1 ; return ; } } else { server.send ( 200 , "text/html" , "action no found" ); } } / / 用来跳转页面 String GoUrl(String urlName){ String ALLHtml = String("") + "<HTML>" + "<HEAD>" + "<meta HTTP-EQUIV=\'REFRESH\' content=\'0; url=" + urlName + "\'/>" + "<TITLE>Success</TITLE>" + "</HEAD>" + "<BODY>" + "Success" + "</BODY>" + "</HTML>" ; return ALLHtml; } void handle_Login(){ if (server.hasArg( "config" )) { / / 请求中是否包含有a的参数 String config = server.arg( "config" ); / / 获得a参数的值 String RecLoginName; String RecLoginPwd; if (config = = "on" ) { / / a = on if (server.hasArg( "name" )) { / / 请求中是否包含有a的参数 RecLoginName = server.arg( "name" ); / / 获得a参数的值 } else { String backtxt = "请输入用户名" ; server.send ( 200 , "text/html" , backtxt); return ; } if (server.hasArg( "pwd" )) { / / 请求中是否包含有a的参数 RecLoginPwd = server.arg( "pwd" ); / / 获得a参数的值 } if (RecLoginName = = LoginName && RecLoginPwd = = LoginPwd){ String backtxt = "成功登录! 名称:" + RecLoginName + " 密码:" + RecLoginPwd ; Serial. print ( "handleMain" ); backtxt = GoUrl( "http://" + LocaIP + "/index1_control.html" ); server.send ( 200 , "text/html" , backtxt); return ; } else { String backtxt = "失败登录,账号和密码错误!\n 名称:" + RecLoginName + " 密码:" + RecLoginPwd ; server.send ( 200 , "text/html" , backtxt); return ; } } server.send ( 200 , "text/html" , "unknown action" ); return ; } server.send ( 200 , "text/html" , "action no found" ); } / / 工作模式 1 自身建立wifi等待连接 void Int_SetWIfi(String wifiName_,String password_){ / / LocaIP = "192.168.1.1" ; IPAddress softLocal( 192 , 168 , 1 , 1 ); / / 1 设置内网WIFI IP地址 IPAddress softGateway( 192 , 168 , 1 , 1 ); IPAddress softSubnet( 255 , 255 , 255 , 0 ); WiFi.softAPConfig(softLocal, softGateway, softSubnet); / / String wifiName = ( "ESPWIFI_" + (String)ESP.getChipId()); / / 2 设置WIFI名称 const char * softAPName = wifiName_.c_str(); WiFi.softAP(softAPName, password_); / / 3 创建wifi 名称 + 密码 adminadmin IPAddress myIP = WiFi.softAPIP(); / / 4 输出创建的WIFI IP地址 Serial. print ( "AP IP address: " ); LocaIP = myIP.toString().c_str(); Serial.println(LocaIP); Serial. print ( "softAPName: " ); / / 5 输出WIFI 名称 Serial.println(wifiName_); } / / 工作模式 2 连接到wifi 获取ip访问 void Int_wificonnect(String wifiName,String password){ int connectCount = 0 ; WiFi.begin ( wifiName.c_str(), password.c_str() ); while ( WiFi.status() ! = WL_CONNECTED ) { delay ( 1000 ); Serial. print ( "." ); if (connectCount > 30 ) { Serial.println( "Connect fail!" ); break ; } connectCount + = 1 ; } if (WiFi.status() = = WL_CONNECTED) { Serial.println ( "" ); Serial. print ( "Connected to " ); Serial.println ( wifiName ); Serial. print ( "IP address: " ); / / Serial.println ( WiFi.localIP() ); LocaIP = WiFi.localIP().toString().c_str(); Serial.println ( LocaIP ); connectCount = 0 ; } } void setup() { / / 日常初始化网络 pinMode( 2 , OUTPUT); Serial.begin ( 9600 ); portOne.begin( 9600 ); / / 软串口 1 单片机之间过高导致解析出错 / / portTwo.begin( 9600 ); / / 软串口 2 红外模块串口通信默认 115200 SPIFFS.begin(); if (work_mode = = "STA" ){ Int_wificonnect(wifiName,password); } else { Int_SetWIfi(wifiName,password); } server.on ( "/" , handleMain); / / 绑定‘ / ’地址到handleMain方法处理 默认返回登陆网页 server.on ( "/login" , HTTP_GET, handle_Login); / / 处理登陆请求是否正确,然后跳转控制页面 / / http: / / 192.168 . 1.103 / Control_SensorPin?sensor = sensor_all&action = GetData server.on ( "/Control_SensorPin" , HTTP_GET, handle_PinControl); / / 处理控制页面的按键和滑动条请求 server.onNotFound ( handleNotFound ); / / NotFound处理 默认会返回登陆页面 server.begin(); Serial.println ( "HTTP server started" ); } void loop() { / * 循环处理,因为ESP8266的自带的中断已经被系统占用, * 只能用过循环的方式来处理网络请求 * / server.handleClient(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | #include <SPI.h> #include <Wire.h> #include <SoftwareSerial.h> SoftwareSerial mySerial( 4 , 5 ); / / RX, TX / / 温湿度 #include "DHT.h" #define DHTPIN 6 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); / / 气体 int pin_jiu = A0; int pin_mq135 = A1; int pin_mq2 = A2; float Humidity = 0 ; float Temperature = 0 ; int pin_jiu_Value = 0 ; int pin_mq135_Value = 0 ; int pin_mq2_Value = 0 ; / / = = = = = = = = = = = = 解析函数 = = = = = = = = = = = = = = = = = / / 分割结果 #define sleng 3 //数组大小 比实际多一个 String split_result[sleng]; / / 手动动态调整数组大小,保证数组可以满足容量 / * 字符串分割 输入参数 String zifuchuan, 输入字符串 String fengefu, 分隔符号 - 可以是多个 String result[] 输出结果 * / void Split(String zifuchuan,String fengefu,String result[]) { int weizhi; / / 找查的位置 String temps; / / 临时字符串 int i = 0 ; do { weizhi = zifuchuan.indexOf(fengefu); / / 找到位置 if (weizhi ! = - 1 ) / / 如果位置不为空 { temps = zifuchuan.substring( 0 ,weizhi); / / 打印取第一个字符 zifuchuan = zifuchuan.substring(weizhi + fengefu.length(), zifuchuan.length()); / / 分隔后只取后面一段内容 以方便后面找查 } else { / / 上面实在找不到了就把最后的 一个分割值赋值出来以免遗漏 if (zifuchuan.length() > 0 ) temps = zifuchuan; } result[i + + ] = temps; / / Serial.println(result[i - 1 ]); / / 在这里执行分割出来的字符下面不然又清空了 temps = ""; } while (weizhi > = 0 ); } / / 根据消息解析,并生成指令返回 String DoWork_Response(String SensorName,String SensorAction){ / / 根据命令做控制 / / 解析 1 - 传感器sensor_all 命令GetData 返回所有的数据 if (SensorName = = "sensor_all" && SensorAction = = "GetData" ){ / / / / 湿度 / / float Humidity = dht.readHumidity(); / / / / 温度 / / float Temperature = dht.readTemperature(); / / / / if (isnan(Humidity) || isnan(Temperature) ){ / / Humidity = 27 ; / / Temperature = 23 ; / / } / / / / / / / / 空气烟雾 / / int pin_jiu_Value = 1023 - analogRead(pin_jiu); / / int pin_mq135_Value = 1023 - analogRead(pin_mq135); / / int pin_mq2_Value = 1023 - analogRead(pin_mq2); String SendMsg = String("") + String( int (pin_jiu_Value)) + "-" + String( int (pin_mq135_Value)) + "-" + String( int (pin_mq2_Value)) + "-" + String( int (Humidity)) + "-" + String( int (Temperature)) + "-" + ";" ; return SendMsg; } else { String SendMsg = String("") + String( int ( 0 )) + "-" + String( int ( 0 )) + "-" + String( int ( 0 )) + "-" + String( int ( 0 )) + "-" + String( int ( 0 )) + "-" + ";" ; return SendMsg; } } void setup() { Serial.begin( 9600 ); mySerial.begin( 9600 ); pinMode(pin_jiu, INPUT ); / / 数字引脚初始化 pinMode(pin_mq135, INPUT ); / / 数字引脚初始化 pinMode(pin_mq2, INPUT ); / / 数字引脚初始化 dht.begin(); Serial.println( "go go go!" ); } void loop() { / / 收到串口命令 if (mySerial.available()){ / / 1 = = = = = = = = = 从串口获取命令 ;结尾 例子: sensor - on; String split_input = mySerial.readStringUntil( ';' ); Serial. print ( "Recive_esp: " );Serial.println(split_input); / / 2 = = = = = = = = 解析命令 / / 2 - 0 解析数据 sensor - on Split(split_input, "-" ,split_result); / / 分割调用 / / 2 - 1 打印消息 0 - sensor 1 - on for ( int i = 0 ;i<sleng;i + + ) { if (split_result[i]! = "") { / / Serial.println(String(i) + "-" + split_result[i]); } } String SensorName = split_result[ 0 ]; / / 传感器类型 / 命令类型 String SensorAction = split_result[ 1 ]; / / 具体指令 / 要干什么 / / Serial. print (SensorName);Serial. print ( " " ); Serial.println(SensorAction); / / 3 = = = = = = = = = = = 修改对象,根据命令做动作 生成返回报文 String ResMsg = DoWork_Response(SensorName,SensorAction); / / 4 串口返回消息 mySerial. print (ResMsg); / / 换行符号影响下一次解析 / / 不加 \n 会导致连续发送两行积累 所以解析段必须去除 \n 字符 Serial.println(ResMsg); } / / 湿度 Humidity = dht.readHumidity(); / / 温度 Temperature = dht.readTemperature(); if (isnan(Humidity) || isnan(Temperature) ){ Humidity = 27 ; Temperature = 23 ; } / / 空气烟雾 pin_jiu_Value = 1023 - analogRead(pin_jiu); pin_mq135_Value = 1023 - analogRead(pin_mq135); pin_mq2_Value = 1023 - analogRead(pin_mq2); / / String SendMsg = String("") / / + String( int (pin_jiu_Value)) + "-" / / + String( int (pin_mq135_Value)) + "-" / / + String( int (pin_mq2_Value)) + "-" / / + String( int (Humidity)) + "-" / / + String( int (Temperature)) + "-" / / + ";" ; / / / / Serial.println(SendMsg); } |
分类:
ESP网页控制经典项目
, 4_2Stm32-arduino
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
2022-04-11 (经典)python操作数据库(1)代码样例
2021-04-11 树莓派编译c++读取opencv
2020-04-11 树莓派 安装TensorFlow2.0
2020-04-11 树莓派10 界面
2019-04-11 ESP8266-07选型
2019-04-11 ESP8266天线问题
2019-04-11 使用 ESP8266 制作 WiFi 干扰器 - 无需密码即可使用任何 WiFi