The factory default resolution the DS18B20 is 12-bit. If you're just testing for
over 4.4 deg C, then after reading the temp, try this;
TEMP = TEMP >> 4 ' Middle 8-bits into low byte. (see data sheet)
IF TEMP.LowByte >= 4 THEN HIGH Whatever_PIN
The lower 4-bits of TEMP is the remainder in 0.0625 deg C increments. By
shifting TEMP >> 4 you're just shifting out the lower 4-bits, and using the
whole temp result which is the middle 8-bits of 16-bit word TEMP.
If you need better resolution, then test the lower 4-bits of TEMP first, then
shift >> 4 to get the whole number.
Remainder VAR BYTE
Whole VAR BYTE
Remainder = (TEMP.LowByte & $0F) ' Mask & keep lower 4-bits in TEMP
TEMP = TEMP >> 4 ' Shift middle 8-bits into low byte
Whole = TEMP.LowByte ' Middle 8-bits of TEMP in Whole
IF (Whole > 4) AND (Remainder = 7) THEN HIGH PIN ' IF > 4.4 deg C THEN
7 * 0.0625 = 0.4375 deg C.




Bookmarks