Pin - is the digital I/O pin to which the temperature sensor is attached.
Variable - receives the raw 12 bit data read.
Read 12 bit temperature data from a DS18B20 digital temperature sensor and store in a word variable.
The conversion can take up to 750ms. Both readtemp and readtemp12 take the same time to convert. This command is designed for more advanced users, for standard 'whole degree' data use the simpler readtemp command. The readtemp12 temperature is read back as the raw 12 bit data into a word variable (0.0625 degrees Celsius resolution). The user must interpret the data through mathematical manipulation. See the DS18B20 datasheet for more information on the 12 bit Temperature/Data relationship.
Note the readtemp12 command does not work directly the same with the older DS1820 or DS18S20 as they have a different internal resolution. However example 2 below shows a workaround for the DS18S20. The readtemp12 command is not designed to be used with parasitically powered DS18B20 sensors (DS18B20-PAR) as the 5V pin of the sensor must always be connected.
The readtemp12 command requires use of a digital I/O pin which is able to be used for both input and output. It cannot be used on the following pins due to silicon restrictions:
||C.3 = fixed input, C.0 = fixed output
||C.3 = fixed input, B.0 = fixed output
||C.3 = fixed input, 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.