This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
|
||||
OneWire oneWire(ONE_WIRE_BUS);
|
||||
|
||||
// Pass our oneWire reference to Dallas Temperature.
|
||||
// Pass our oneWire reference to Dallas Temperature.
|
||||
DallasTemperature sensors(&oneWire);
|
||||
|
||||
// arrays to hold device addresses
|
||||
@@ -16,7 +16,7 @@ DeviceAddress insideThermometer, outsideThermometer;
|
||||
// function that will be called when an alarm condition exists during DallasTemperatures::processAlarms();
|
||||
void newAlarmHandler(const uint8_t* deviceAddress)
|
||||
{
|
||||
Serial.println("Alarm Handler Start");
|
||||
Serial.println("Alarm Handler Start");
|
||||
printAlarmInfo(deviceAddress);
|
||||
printTemp(deviceAddress);
|
||||
Serial.println();
|
||||
@@ -76,35 +76,35 @@ void setup(void)
|
||||
|
||||
// Start up the library
|
||||
sensors.begin();
|
||||
|
||||
|
||||
// locate devices on the bus
|
||||
Serial.print("Found ");
|
||||
Serial.print(sensors.getDeviceCount(), DEC);
|
||||
Serial.println(" devices.");
|
||||
|
||||
// search for devices on the bus and assign based on an index
|
||||
if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
|
||||
if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");
|
||||
if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
|
||||
if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");
|
||||
|
||||
Serial.print("Device insideThermometer ");
|
||||
printAlarmInfo(insideThermometer);
|
||||
Serial.println();
|
||||
|
||||
|
||||
Serial.print("Device outsideThermometer ");
|
||||
printAlarmInfo(outsideThermometer);
|
||||
Serial.println();
|
||||
|
||||
|
||||
// set alarm ranges
|
||||
Serial.println("Setting alarm temps...");
|
||||
sensors.setHighAlarmTemp(insideThermometer, 26);
|
||||
sensors.setLowAlarmTemp(insideThermometer, 22);
|
||||
sensors.setHighAlarmTemp(outsideThermometer, 25);
|
||||
sensors.setLowAlarmTemp(outsideThermometer, 21);
|
||||
|
||||
|
||||
Serial.print("New insideThermometer ");
|
||||
printAlarmInfo(insideThermometer);
|
||||
Serial.println();
|
||||
|
||||
|
||||
Serial.print("New outsideThermometer ");
|
||||
printAlarmInfo(outsideThermometer);
|
||||
Serial.println();
|
||||
@@ -115,12 +115,12 @@ void setup(void)
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
{
|
||||
// ask the devices to measure the temperature
|
||||
sensors.requestTemperatures();
|
||||
|
||||
// if an alarm condition exists as a result of the most recent
|
||||
// requestTemperatures() request, it exists until the next time
|
||||
|
||||
// if an alarm condition exists as a result of the most recent
|
||||
// requestTemperatures() request, it exists until the next time
|
||||
// requestTemperatures() is called AND there isn't an alarm condition
|
||||
// on the device
|
||||
if (sensors.hasAlarm())
|
||||
@@ -138,7 +138,6 @@ void loop(void)
|
||||
printCurrentTemp(insideThermometer);
|
||||
printCurrentTemp(outsideThermometer);
|
||||
}
|
||||
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user