From 4435e08342be36a2caf736c2d66c59da7421ab95 Mon Sep 17 00:00:00 2001 From: spdis Date: Fri, 9 May 2025 00:35:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dorm-Air-Conditioner-Smart-Controller.ino | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Dorm-Air-Conditioner-Smart-Controller.ino diff --git a/Dorm-Air-Conditioner-Smart-Controller.ino b/Dorm-Air-Conditioner-Smart-Controller.ino new file mode 100644 index 0000000..ba0db56 --- /dev/null +++ b/Dorm-Air-Conditioner-Smart-Controller.ino @@ -0,0 +1,29 @@ +#include "DHT11control.h" + +void setup() { + // 初始化串口通信 + Serial.begin(115200); + // 启动DHT传感器 + dht.begin(); +} + +void loop() { + // 获取温湿度数据指针 + float* results = getTempAndHumidity(); + + // 数据有效性校验 + if(results[0] != -999 && results[1] != -999) { + // 格式化输出温度数据 + Serial.print("Temperature: "); + Serial.print(results[0]); + Serial.print(" °C, "); + + // 格式化输出湿度数据 + Serial.print("Humidity: "); + Serial.print(results[1]); + Serial.println(" %"); + } + + // 维持2秒采样间隔 + delay(2000); +} \ No newline at end of file