Just a side project


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3316
Posted: 12:11pm 31 May 2026      

Had a look at Claud's** code and it calls a DS18B20() Function that isn't included.
You could add one from the "tempr not working" thread but MMbasic has it's own.
TEMPR START GPxx,3 : Temp = TEMPR(GPxx)
Print Temp

The ",3" sets the resolution to 1/16°, ,2 = 1/8°, ,1 = 1/4° and ,0 = 1/2°. Lower resolutions convert faster.

The example above shows TEMPR(GPxx) immediately following TEMPR START but it doesn't need to. You can put other code between to make use of the 600mS or so it takes to do a conversion.
When reading multiple DS18B20s for maximum efficiency do all the TEMPR STARTs in a block, other code then all the TEMPR(GPxx)s in a block.
eg for 4 sensors on pins 4 to 7 (GP2 to GP5)
For n=4 to 7 : TEMPR START n,3 : Next

** Should we be using a capital "C" as claude isn't a person?
Edited 2026-06-01 08:00 by phil99