Skip to content

AvgTemperature()

Arnd edited this page Dec 3, 2016 · 1 revision

AvgTemperature([skipDeviceNumber])

This function reads all of the 1-Wire DS-Family devices and returns the average temperature reading. If the optional skipDeviceNumber is set to a deviceNumber then that specific thermometer is excluded from the computations. This allows for 1 device to be ignored, for instance if one is placed on the processor board or attached to a refrigeration evaporator plate and has a different value from all the others.


Example:

const uint8_t ONE_WIRE_PIN = 8;             // 1-Wire microLAN pin
DSFamily_Class ds(ONE_WIRE_PIN);            // Instantiate
uint8_t thermometers = ds.ScanForDevices(); // find all devices
Serial.print("Found ");
Serial.println(thermometers);
Serial.print("Average temperature is ");
int16_t temp = ds.AvgTemperature();
Serial.print(temp);
Serial.print(" units, or ");
Serial.print(temp*0.0625,3);
Serial.println("C.");