- Name:
-
readtemp
- Syntax:
-
READTEMP pin,variable
Pin - is the input pin.
Variable - receives the data byte read.
- Description:
-
Read temperature from a DS18B20 digital temperature sensor and store in variable.
The conversion takes up to 750ms. Readtemp carries out a full 12 bit conversion and then rounds the result to the nearest full degree Celsius (byte value). For the full 12 bit value use the readtemp12 command. The temperature is read back in whole degree steps, and the sensor operates from -55 to +125 degrees Celsius. Note that bit 7 is 0 for positive temperature values and 1 for negative values (ie negative values will appear as 128 + numeric value).
Note the readtemp command does not work with the older DS1820 or DS18S20 as they have a different internal resolution. This command is not designed to be used with parasitically powered DS18B20 sensors, the 5V pin of the sensor must always be connected.
This command cannot be used on the following pins due to silicon restrictions:
| 08M, 08M2 |
C.3 = fixed input, C.0 = fixed output
|
| 14M, 14M2 |
C.3 = fixed input, B.0 = fixed output
|
| 18M2 |
C.3 = fixed output, C.4, C.5 = fixed input |
| 20M, 20M2, 20X2 |
C.6 = fixed input, A.0 = fixed output
|
Effect of increased clock speed
This command only functions at 4MHz. M2, X1 and X2 parts automatically use the internal 4MHz resonator for this command.