-
Notifications
You must be signed in to change notification settings - Fork 0
setAlarmTemperature()
Arnd edited this page Dec 12, 2020
·
3 revisions
This function sets either the low or the high alarm temperature alarm. When the alarm's threshold is reached the alarm state is set and can be read using getAlarm and the alarm will also set the alarm pin on the DS1631 chip, the polarity of which is user-definable and can be set or changed using setPolarity.
alarmType 0 sets the low temperature alarm, any other alarmType will set the high temperature alarm. The "alarmTemperature" is specified in internal units of 0.0625°C. So setting an alarm temperature of 28.5°C would be 28.5/0.0625 = 456.
DS1631_Class DS1631; // Create an instance of the DS1631
...
void setup() {
Serial.begin(SERIAL_SPEED);
while (!DS1631.begin()) { // Initialize I2C communications
Serial.println("Unable to find DS1631. Checking again in 3 seconds.");
delay(3000);
} // of loop until device is located
for (uint8_t i=0;i<DS1631.thermometers;i++) {
DS1631.setAlarmTemperature(i,0,DS1631.readTemp(i)-32); // low alarm to ambient minus 2°C
DS1631.setAlarmTemperature(i,0,DS1631.readTemp(i)+32); // high alarm to ambient plus 2°C
}
...
} // of setup