Arduino I2C DS1621 commands
Arduino I2C DS1621 commands
我有一个关于DS1621 (arduino)的问题:
必须将哪些命令和参数发送到引脚3 (TOut),以便在HIGH上显示大于25摄氏度的温度?
我想使用Wire库。这样对吗,还是我还需要什么?
#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);
}
输出为"温控器输出"。温度超过TH时起作用;将在温度降到摄氏零度以下。"
所以必须设置TL和TH。值为send
时必须发送控制字节。[A1h] [value for TH][A2h] [value for 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();
你必须添加/保留剩下的代码,但看看这是否奏效。
这是数据表http://pdfserv.maximintegrated.com/en/ds/DS1621.pdf