When connecting both sensors only one reads. Using the software UART. Changed the pull up resistor to recommended 4.7K
Have sensor 1 in ice bath while sensor 2 in ambient air laying on bench. Any ideas why only one sensor reads and it is always the same sensor (ice bath clarified this)
Code: Select all
DEVICE = 18F2420
CLOCK = 8
// import modules...
INCLUDE "DS18B20.bas"
INCLUDE "convert.bas"
INCLUDE "suart.bas"
INCLUDE "internalOscillator.bas"
INCLUDE "Utils.bas"
// on display temperature event...
EVENT OnDisplayTemp()
DIM TempA AS SHORTINT
DIM TempB AS WORD
DIM Index AS BYTE
DIM tempf AS WORD
RomID = SearchRomID
GetTemp(TempA, TempB)
UART.Write(DecToStr(TempA),".",DecToStr(TempB,4), $BA, "C")
tempf = ((TempA*10+TempB/1000)*9/5+320)/10
uart.write ("tempeature=",dectostr(tempf),13,10)
DELAYMS(1000)
// display ROM ID...
UART.Write(" ($")
Index = 6
REPEAT
UART.Write(HexToStr(SearchRomID(index),2))
' delayms(1000)
DEC(Index)
UNTIL Index = 0
UART.Write(")",13,10)
END EVENT
// program start...
uart.SetBaudrate(sbr9600)
uart.setmode(umtrue)
uart.settx(portb.7)
SetPin(PORTC.2)
setalldigital
// if we have some DS1820 devices connected to the bus,
// then display temperature for each one...
IF Count > 0 THEN
WHILE true
ConvertAll
FindAll(OnDisplayTemp)
DELAYMS(1000)
'delayms(1000)
WEND
ENDIF