neiltechspec
Senior Member
Comments please.
Been playing with DS18B20's.
This alternate way of parasite power using just two wires seems to work quite well.
Reading every 6 seconds, the supplied Vdd to the two wire 18B20 never drops below 4.3v.
Using the correct method & my method, stuck the two together & varied the temp from 5c (outside) & 50c of both & they read the same.
Picture cockup - C.3 & C.4 are transposed.
Neil.
Been playing with DS18B20's.
This alternate way of parasite power using just two wires seems to work quite well.
Reading every 6 seconds, the supplied Vdd to the two wire 18B20 never drops below 4.3v.
Using the correct method & my method, stuck the two together & varied the temp from 5c (outside) & 50c of both & they read the same.
Code:
;Indoor DS18B20 (if fitted) on pin c.1
;Outdoor DS18B20 (if fitted) on pin c.2
;Lantronix Port 2 on pin c.4
;display temp to 1 decimal place resolution
#picaxe 08M2
#no_data
#terminal 4800
main:
high c.2
do
for b0=1 to 5
if b0=5 then gosub clscreen
gosub indoor
gosub outdoor
pause 5000
next
loop
indoor: ;read temperature, sertxd & serout it
readtemp12 C.1,w9 ;read raw data into variable w9
if w9=0 then ;check for DS18B20 fitted
sertxd("Indoor DS18B20 not present",13,10)
serout C.4,T2400,("Indoor Sensor not present",13,10)
pause 750
return
endif
b22 = 43 ;sign is "+"
if w9 > 2048 then ;check for below 0 deg
b22 = 45 ;if temp is below 0 sign is "-"
let w9 = - w9 ;two's compliment
endif
w10 = w9 * 10 / 16
bintoascii w10,b23,b24,b25,b26,b27
sertxd ("Indoor Temp: ",b22,b25,b26,".",b27,"c",13,10)
serout C.4,T2400,("Indoor Temp: ",b22,b25,b26,".",b27,"c",13,10)
return
outdoor: ;read temperature, sertxd & serout it
readtemp12 C.2,w9 ;read raw data into variable w9
high c.2
if w9=0 then ;check for DS18B20 fitted
sertxd("Outdoor DS18B20 not present",13,10,13,10)
serout C.4,T2400,("Outdoor Sensor not present",13,10,13,10)
pause 750
return
endif
b22 = 43 ;sign is "+"
if w9 > 2048 then ;check for below 0 deg
b22 = 45 ;if temp is below 0 sign is "-"
let w9 = - w9 ;two's compliment
endif
w10 = w9 * 10 / 16
bintoascii w10,b23,b24,b25,b26,b27
sertxd ("Outdoor Temp: ",b22,b25,b26,".",b27,"c",13,10,13,10)
serout C.4,T2400,("Outdoor Temp: ",b22,b25,b26,".",b27,"c",13,10,13,10)
return
clscreen:
serout C.4,T2400,(27,91,50,74) ;clear terminal screen
pause 80
serout C.4,T2400,(27,91,72) ;home cursor
pause 80
b0=1
return
Neil.
Attachments
-
70.5 KB Views: 89
Last edited: