MrDEB
Well-Known Member
Using the software uart and two DS18B20 sensors the code only finds one sensor.
I connected both sensors seperatly to see if they actually work. =Both work
Wondered if both had same ID number= different ID #'s
Next to try is putting a delay between sensor read. ?? Maybe a quirk with software uart??
I connected both sensors seperatly to see if they actually work. =Both work
Wondered if both had same ID number= different ID #'s
Next to try is putting a delay between sensor read. ?? Maybe a quirk with software uart??
Code:
DEVICE = 18F2420
CLOCK = 8
// import modules...
INCLUDE "DS18B20.bas"
INCLUDE "convert.bas"
INCLUDE "suart.bas"
INCLUDE "internalOscillator.bas"
// on display temperature event...
EVENT OnDisplayTemp()
DIM TempA AS SHORTINT
DIM TempB AS WORD
DIM Index AS BYTE
RomID = SearchRomID
GetTemp(TempA, TempB)
UART.Write(DecToStr(TempA),".",DecToStr(TempB,4), $BA, "C")
// display ROM ID...
UART.Write(" ($")
Index = 3
REPEAT
UART.Write(HexToStr(SearchRomID(Index),2))
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)
// 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)
WEND
ENDIF