
Originally Posted by
blueroomelectronics Same here, the DS18B20 must be different enough from the DS18S20. Might be fun just to fix the module and make an 18S20 module.
The DS18B20 module works fine. I just didn't understand how to use it. David Barker (Swordfish Developer) has posted an article on the Wiki that explains it very nicely.
Here's working code for Junebug and DS18B20
You will have to modify the sensor address data to suit your own 18B20:
Code:
Device = 18F1320
Clock = 8
Config OSC = INTIO2, WDT = OFF
Include "DS18B20.bas"
include "convert.bas"
Include "USART.bas"
const Sensor_A(8) as byte = ($28, $00, $7c, $46, $01, $00, $00, $10)
// display a sensor value...
sub DisplaySensor(byrefconst pID() as byte)
dim TempA as shortint
dim TempB as word
RomID = pID
Convert
GetTemp(TempA, TempB)
USART.Write(DecToStr(TempA),".",DecToStr(TempB,2), "C",13,10)
end sub
// program start...
osccon = $72
high(PORTA.3)
SetBaudrate(br9600)
SetPin(PORTA.4)
while true
DisplaySensor(Sensor_A)
delayms(1000)
wend
END