Dallas DS18B20 code
Archiver
Posts: 46,084
Hello, i tried to modify the example code on the manual for the ds1820
to my ds18b20 with no luck, my bs2p doesnt read the correct
temperature value. Please anyone help me.
Best regards,
Kalun mailto:klnlau@v...
to my ds18b20 with no luck, my bs2p doesnt read the correct
temperature value. Please anyone help me.
Best regards,
Kalun mailto:klnlau@v...
Comments
Chuck
'program setup for 1-wire temperature sensor Dallas 1820
'install in program #1
'9/19/00
r var byte(9)
w var byte
x var byte
p var nib
s var nib
ioterm 0
p=1
s=9
'gosub LCDINIT
'gosub CHIPINFO
'read serial number
lcdout s,0,[noparse][[/noparse]"1-wire S/N"]
lcdcmd s,128+64
owout p,1,[noparse][[/noparse]$33]
owin p,2,[noparse][[/noparse]str r\8]
debug "S/N "
for w=0 to 7
debug hex2 r(w)
lcdout s,0,[noparse][[/noparse]hex2 r(w)]
next
debug cr
pause 2000
'read temperature
owout p,1,[noparse][[/noparse]$cc,$44]
pause 500
owout p,1,[noparse][[/noparse]$cc,$be]
owin p,2,[noparse][[/noparse]str r\8]
x=(((r(0)/2)*18)/10)+32
debug dec x," deg F",cr
lcdout s,128+64,[noparse][[/noparse]"& its temp, ",dec x,%11011111,"F"]
pause 3000
run 0
'initialize LCD
LCDINIT
lcdcmd s,48 'set function
pause 5
lcdcmd s,48
pause 0
lcdcmd s,48
pause 0
lcdcmd s,32
pause 0
lcdcmd s,44
pause 0
lcdcmd s,8 'display off
lcdcmd s,12 'display on
lcdcmd s,6 'set mode
lcdcmd s,1 'clear display
return
'display information
CHIPINFO
lcdcmd s,1
lcdout s,128,[noparse][[/noparse]"BASIC Stamp2p reads 1-wire S/N.........."]
for x=1 to 60
pause 200
lcdcmd s,24
next
pause 1000
lcdcmd s,1
return
[noparse][[/noparse]Non-text portions of this message have been removed]