TEMPR(), TEMPR START

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 Picomite CMM2

Syntax:
TEMPR( pin )
TEMPR START pin [, precision]

Description:

TEMPR( pin )

Return the temperature measured by a DS18B20 temperature sensor connected to 'pin' (which does not have to be configured). 
The CPU speed must be 20 MHz or above. The returned value is degrees C with a default resolution of 0.25ºC. 
If there is an error during the measurement the returned value will be 1000. The time required for the overall measurement is 200ms and interrupts will be ignored during this period. 

Alternatively the TEMPR START command can be used to start the measurement and your program can do other things while the conversion is progressing. 
When this function is called the value will then be returned instantly assuming the conversion period has expired. 
If it has not, this function will wait out the remainder of the conversion time before returning the value. The DS18B20 can be powered separately by a 3V to 5V supply or it can operate on parasitic power from the Maximite. 
See the manual chapter "Special Hardware Devices" for more details.

TEMPR START pin [, precision]

This command can be used to start a conversion running on a DS18B20 temperature sensor connected to 'pin'. 
Normally the TEMPR() function alone is sufficient to make a temperature measurement so usage of this command is optional. 
This command will start the measurement on the temperature sensor. 
The program can then attend to other duties while the measurement is running and later use the TEMPR() function to get the reading. 
If the TEMPR() function is used before the conversion time has completed the function will wait for the remaining conversion time before returning the value. 
Any number of these conversions (on different pins) can be started and be running simultaneously.
 'precision' is the resolution of the measurement and is optional. It is a number between 0 and 3 meaning: 
0 = 0.5ºC resolution, 100 ms conversion time. 
1 = 0.25ºC resolution, 200 ms conversion time (this is the default). 
2 = 0.125ºC resolution, 400 ms conversion time. 
3 = 0.0625ºC resolution, 800 ms conversion time.

MMBasic assumes a parasitic power connection and waits the pre-determined time, rather than interrogating the sensor to see if it has finished the conversion.

If you need to read sensors other than the DS18B20 or multiple sensors on the one pin, see the onewire command.

 TEMPR START 42, 2 ' 0.125ºC resolution, 400 ms conversion time.
 '< do other tasks >
 PAUSE 400
 PRINT "Temperature: " TEMPR(42)

Last edited: 29 September, 2020