diff --git a/Dorm-Air-Conditioner-Smart-Controller.ino b/Dorm-Air-Conditioner-Smart-Controller.ino index ba0db56..3d5da4f 100644 --- a/Dorm-Air-Conditioner-Smart-Controller.ino +++ b/Dorm-Air-Conditioner-Smart-Controller.ino @@ -1,29 +1,36 @@ -#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); +#include "DHT11control.h" + +void setup() { + // 初始化串口通信 + Serial.begin(115200); + // 启动DHT传感器 + dht.begin(); +} + +void loop() { + + //接下来都只是为了让串口监视器能输出温度和湿度,判断dht11是否正常工作,后续会删除 + + + // 获取温湿度数据指针 + 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