Exemple #1
0
uint8_t DS18B20::hasAlarm() {
    uint8_t oldResolution = selectedResolution;
    setResolution(9);
    float temp = getTempC();
    setResolution(oldResolution);
    return ((temp <= selectedScratchpad[ALARM_LOW]) || (temp >= selectedScratchpad[ALARM_HIGH]));
}
// Fetch temperature for device index
float DallasTemperature::getTempCByIndex(uint8_t deviceIndex)
{
    DeviceAddress deviceAddress;
    if (!getAddress(deviceAddress, deviceIndex))
        return DEVICE_DISCONNECTED_C;
    return getTempC((uint8_t*)deviceAddress);
}
float Thermistor::getTempF(bool smooth) {
	_temp_c = getTempC(smooth);
	
	_temp_f = (_temp_c * 9.0)/ 5.0 + 32.0;

	Serial.print("Temp F: ");
	Serial.println(_temp_f);
	
	return _temp_f;
}
Exemple #4
0
void LM95172::resetSensor()
{
    unsigned int v = 0;
        
    digitalWrite(PIN_CS, LOW);
    getTempC();
    sendCmd(REG_CTL, READ, v);
    digitalWrite(PIN_CS, HIGH);
    
    v = v | (1 << CTRL_SHUT_DOWN); //set shutdown bit;
    digitalWrite(PIN_CS, LOW);
    getTempC();
    sendCmd(REG_CTL, WRITE, v);
    delay(100);
    digitalWrite(PIN_CS, HIGH);
    
    v = ~(1 << CTRL_SHUT_DOWN) & v; //clear shutdown bit;
    digitalWrite(PIN_CS, LOW);
    getTempC();
    sendCmd(REG_CTL, WRITE, v);
    delay(100);
    digitalWrite(PIN_CS, HIGH);
}
Exemple #5
0
void LM95172::changeResolution(byte res)
{
    unsigned int v = 0;
     
    digitalWrite(PIN_CS, LOW);
    getTempC();
    sendCmd(REG_CTL, READ, v);
    digitalWrite(PIN_CS, HIGH);
    
    v = v & 0xFFC0; //clear the lower 5 bits;
    
    currentResolution = res;
    
    if (res == 13) v = v | RES_13;
    else if (res == 14) v = v | RES_14;
    else if (res == 15) v = v | RES_15;
    else v = v | RES_16;
    
    digitalWrite(PIN_CS, LOW);
    getTempC();
    sendCmd(REG_CTL, WRITE, v);
    digitalWrite(PIN_CS, HIGH);
}
// returns temperature in degrees F
// TODO: - when getTempC returns DEVICE_DISCONNECTED 
//        -127 gets converted to -196.6 F
float DallasTemperature::getTempF(uint8_t* deviceAddress)
{
  return toFahrenheit(getTempC(deviceAddress));
}
// Fetch temperature for device index
float DallasTemperature::getTempCByIndex(uint8_t deviceIndex)
{
  DeviceAddress deviceAddress;
  getAddress(deviceAddress, deviceIndex);
  return getTempC((uint8_t*)deviceAddress);
}
float Thermistor::getTemp(bool smooth) {
	return getTempC(smooth);
}
Exemple #9
0
float DS18B20::getTempF() {
    return getTempC() * 1.8 + 32;
}