更新 Dorm-Air-Conditioner-Smart-Controller.ino
This commit is contained in:
parent
3a4bb831be
commit
8728684d67
@ -1,36 +1,23 @@
|
||||
#include "DHT11control.h"
|
||||
|
||||
#include "RTC_Module.h"
|
||||
#include <RtcDS1302.h>
|
||||
|
||||
ThreeWire myWire(4,5,2);
|
||||
RtcDS1302<ThreeWire> Rtc(myWire);
|
||||
|
||||
void setup() {
|
||||
// 初始化串口通信
|
||||
Serial.begin(115200);
|
||||
|
||||
// 启动DHT传感器
|
||||
dht.begin();
|
||||
// 启动ds1302
|
||||
setupRTC();
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
//到此为止
|
||||
//暂时留空备用,函数调用方法已转移至文档
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user