[英]Arduino I2C DS1621 commands
我對DS1621(arduino)有疑問:
哪些命令和參數必須發送到引腳3(TOut),以便在HIGH上顯示高於25攝氏度的溫度?
我想使用Wire lib。 這是對的還是我還需要什么?
#define DEV_ID 0x90 >> 1
int tempC = 25; //for 25 Celsius
void setup() {
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(DEV_ID); // connect to DS1621
Wire.send(0xAC);
Wire.send(0x02);
Wire.beginTransmission(DEV_ID);
Wire.send(0xEE);
Wire.endTransmission();
}
void loop() {
tempC = Wire.receive();
Serial.print(tempC);
}
Tout是“溫控器輸出。當溫度超過TH時有效;當溫度低於TL時將復位。”
因此,您必須設置TL和TH。 必須發送控制字節才能發送值
[A1h] [TH的值] [A2h] [TL的值]
幸運的是,25度是他們給出的值為0x19或00011001,所以我的代碼看起來像這樣
Wire.begin();
Wire.beginTransmission(DEV_ID); //I am talking to you
Wire.send(0xA1); //I want to change TH
Wire.send(0x19); //Value of 25
Wire.endTransmission();
Wire.beginTransmission(DEV_ID); //I am talking to you
wire.send(0xA2); //I want to change TL
Wire.send(0x19); //value of 25
Wire.endTransmission();
您已經添加/保留了其余的代碼,但是看看是否能解決問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.