tempr not working


Author Message
JanVolk
Guru

Joined: 28/01/2023
Location: Netherlands
Posts: 385
Posted: 06:40pm 20 May 2026      

G'day Lizby,

Rejected DS18B20 temperature sensors are left out in later versions and can be used with an extra timeout.
Or try the code below.


' Function TEMPR() and TEMPW() Dallas DS18B20. V6.03.00RC10
Const Pin$="GP14"

Do
 Print
 Print "DS18B20 TEMPW(";Pin$;"):"; Str$(TEMPW(Pin$),3,2);" ";     Chr$(176);"C"
 Print "DS18B20 TEMPR(GP14):";     Str$(TEMPR(GP14),3,2);" ";     Chr$(176);"C"
 Print "DS18B20 TEMPR(GP14):";     Str$(TEMPR(GP14,200),3,2);" "; Chr$(176);"C"
 ' TEMPR(pin [,timeout])   Manual: Ver 6.02.01 Page 200  PicoMite User Manual.
 Pause 5000
Loop

Function TEMPW(Pin$)
 Local T1,T2,b,t
 OneWire Reset Pin$
 OneWire Write Pin$,1,2,&HCC,&H44
 Pause 80
 t=Timer
 OneWire Write Pin$,1,2,&HCC,&HBE
 OneWire Read  Pin$,2,2,T1,T2
 TEMPW = ((T2 And &B111)*256+T1)/16
 If T2 And &B1000 Then TEMPW=-TEMPW
End Function


Jan.