Name:
readtemp12
Syntax:

READTEMP12 pin,wordvariable

Pin - is the input pin.

Variable - receives the raw 12 bit data read.

Description:

Read 12 bit temperature data from a DS18B20 digital temperature sensor and store in variable.

The conversion takes up to 750ms. Both readtemp and readtemp12 take the same time to convert. This command is for advanced users only. For standard 'whole degree' data use the readtemp command. The 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 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 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 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.

Applies To:
All (except 08, 18, 28)
See Also:
Related Create:
Share:
Print:

Read temperature

Read a 12-bit temperature value from a DS18B20 temperature sensor on pin B.1 and report the result

Code Example:
main:	readtemp12 B.1,w1	; read value into b1
	debug			; transmit to computer screen
	goto main
Copy Code Submit an Example

Submit Your Own Code!

You must be logged in to submit code examples. Login now.

Comments

  • Login to leave a comment.