arduino驱动dbs820温度
https://blog.csdn.net/Naisu_kun/article/details/88420357
超过温度报警
// #include <OneWire.h> //可以不引入,因为DallasTemperature.h中已经引入了OneWire.h #include <DallasTemperature.h> int relayPin = 5; //继电器引脚 float tem_alram=30; #define ONE_WIRE_BUS 4 //1-wire数据总线连接在IO4 OneWire oneWire(ONE_WIRE_BUS); //声明 DallasTemperature sensors(&oneWire); //声明 void setup(void) { Serial.begin(115200); Serial.println(""); pinMode(relayPin, OUTPUT); sensors.begin(); //初始化总线 } void loop(void) { // Serial.println("发起温度转换"); sensors.requestTemperatures(); //向总线上所有设备发送温度转换请求,默认情况下该方法会阻塞 // Serial.println("温度转换完成"); float tempC = sensors.getTempCByIndex(0); //获取索引号0的传感器摄氏温度数据 if (tempC != DEVICE_DISCONNECTED_C) //如果获取到的温度正常 { Serial.print("当前温度是: "); Serial.print(tempC); Serial.println(" ℃\n"); if(tempC>tem_alram) { Serial.println("继电器打开"); digitalWrite(relayPin, HIGH); } else { Serial.println("继电器关闭"); digitalWrite(relayPin, LOW); } } // delay(2000); }
相关推荐
yuancr 2020-05-20
erqw 2020-05-19
浅梦墨汐 2020-05-12
yuancr 2020-05-10
erqw 2020-03-23
yuancr 2020-03-04
internetofthings 2020-01-29
FIllMood 2020-01-28
FIllMood 2020-01-11
FIllMood 2020-01-11
YingCloud 2020-01-11
internetofthings 2020-01-08
第三步:通过 arduino 软件选择对应的网络端口就可以进行固件更新了,不过更新的时候要注意不能将 Arduino.begin() 和 ArduinoOTA.handle() 这两个关键函数给更新掉
erqw 2020-01-06
internetofthings 2020-01-04
internetofthings 2019-12-30
internetofthings 2019-12-28
yuancr 2019-12-28
YingCloud 2019-12-27
internetofthings 2019-12-26