AbyssalSwamp  ActivaUser
» Guest:  Register | Login | 会员列表

RSS subscription to this AbyssalSwamp  

Previous thread Next thread
     
Title: sht30.ino  
 
minicoco





UID 305210
Digest 0
Points 0
Posts
码币MB 0 Code
黄金 0 Catty
钻石 0 Pellet
Permissions 10
Register 2019-5-30
Status offline
sht30.ino

#include #include #include #include #include #include const char *ssid = "CAFFZTS3"; //WIFI名称(输入需要连接的WIFI名称) const char *password = "13826867328"; //连接WIFI的密码 const char *host = "192.168.1.209"; //电脑PC端的IP(接收数据端) WiFiClient client; const int tcpPort = 8181; //接收端的 端口 #include #include SHTSensor SHTSENSE; void setup() { Serial.begin(9600); Wire.begin(); SHTSENSE.init(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(800); Serial.print("."); } Serial.println(WiFi.localIP()); } void loop() { while (!client.connected()) { if (!client.connect(host, tcpPort)) { Serial.println("wifi......."); delay(800); } } if (SHTSENSE.readSample()) { Serial.print(" RH: "); Serial.print(SHTSENSE.getHumidity(), 0); Serial.print("\n"); Serial.print(" T: "); Serial.print(SHTSENSE.getTemperature(), 1); Serial.print("\n"); Send(); delay(5000); } } //发送数据 void Send() { String str, str2, str1; str1 = SHTSENSE.getTemperature(); str2 = SHTSENSE.getHumidity(); str = "th," + (String)7 + "," + str1 + "," + str2 + "\n"; Serial.println(str); client.print(str); } [attach]21667[/attach]

Att: sht30.ino (2019-7-16 16:02, 1.44 K)
Number of times this attachment has been downloaded 0
2019-7-16 16:02#1
View profile  Blog  Send a short message  Top
     


  Printable version | Recommend to a friend | Subscribe to topic | Favorite topic  


 


All times are GMT+8, and the current time is 2026-1-12 04:39 Clear informations ->sessions/cookies - Contact Us - CAFFZ - ZAKE