User Tools

Site Tools


info:one_wire_temp_conversion

This is an old revision of the document!


Temperature conversions

Fahrenheit to Celsius

C = (F - 32.0) / 1.8

Celsius to Fahrenheit

F = (C * 1.8) + 32.0

C source

float C_to_F_degrees( float temp )
{
return( (temp * 1.8) + 32.0 );
}

Converting C to F for One Wire

unsigned int temperature;
float tempf;
tempf = 32.0 + (9.0*(float)temperature)/10.0;
temperature = tempf + 0.5; integer Fahrenheit
One Wire PH Anderson LowByte = OneWireInByte(_1W_Pin);
HighByte = OneWireInByte(_1W_Pin);
TReading = (HighByte « 8) + LowByte; SignBit = TReading & 0x8000;
test most sig bit if (SignBit) negative { TReading = (TReading ^ 0xffff) + 1; 2's comp } Tc_100 = (6 * TReading) + TReading / 4; multiply by (100 * 0.0625) or 6.25 Whole = Tc_100 / 100; separate off the whole and fractional portions Fract = Tc_100 % 100;

if (n==0) if its the first time, clear the LCD { Serial.print(“?f”); delay(100); } if (SignBit) If its negative { Serial.print(“-”); } Serial.print(Whole); Serial.print(“.”); if (Fract < 10) { Serial.print(“0”); } Serial.print(Fract); Serial.print(“?n”); } delay(5000); 5 second delay. Adjust as necessary }

info/one_wire_temp_conversion.1214266457.txt.gz · Last modified: 2008/06/23 20:14 by tomgee