| Posted: 12:32pm 31 May 2026 |
|
|
|
Have been puzzled by your output only showing "50" between reads. Each 50 is 50mS so you should get something like this.
50 100 150 200 250 300 350 400 450 500 Temp = 19.2`C 50 100 150 200 250 300 350 400 450 500 Temp = 19.3`C
Then when I tried a non-genuine DS18B20 I got the same as you. Further investigation showed it says it has completed the temperature conversion in 33mS. But it hasn't actually finished so the data you get is from a previous read. That is why you got a string of 85°C readings, then the correct temp.
For these non-genuine units you are better off using the MMBasic TEMPR START GPxx,3 before the TEMPR(GPxx) function. The ",3" gives maximum resolution and ensures TEMPR(GPxx) waits long enough before reading.
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. Edited 2026-06-01 08:00 by phil99 |