strange ds18b20 problems

static4067

New Member
Hello all,

I'm using a picaxe 28x2 with a ds18b20 sensor. I have the sensor on 5v, ground, and the signal pulled high on a 4.7k resistor to pin c.7.

Using the below code:

Code:
Celsius:
Readtemp12 c.7,w1                                   'read in result ds18b20

 convert:                                           
  let b9 =43                                       'Display + (43)   space (32)
IF W1 > 64655 THEN                                  '  info     - 55 degrees          = 64656
  let b9 =45                                       'Display - (45)
W1 = - W1                                           '  info   if - ie w1=1000   display   - 10.00 C
ENDIF                                
W1 = W1 * 25 / 4                                    '  info      + ie w1=8500   display     85.00 C
                                          
BINTOASCII w1,b8,b7,b6,b5,b4 
IF b8 = "0" THEN  : b8 = " "  :ENDIF                       ' zero blanking b8
IF b8 =  " "  AND  b7 =  "0"  THEN : b7 = " "  :ENDIF      ' zero blanking b7
  
SERTXD (CR, LF, "Temperature  ",b9,b8,b7,b6,".",b5,b4,"  Degrees C", CR, LF)'resolution to 0.06

PAUSE 1000
GOTO celsius
And I get the below results with the sensor just sitting on the table.

Code:
Temperature  + 71.52  Degrees C

Temperature  +120.31  Degrees C

Temperature  +120.62  Degrees C

Temperature  + 47.59  Degrees C

Temperature  +127.50  Degrees C

Temperature  + 44.21  Degrees C

Temperature  + 42.34  Degrees C

Temperature  +118.81  Degrees C

Temperature  + 73.02  Degrees C

Temperature  + 61.21  Degrees C

Temperature  + 49.02  Degrees C

Temperature  + 43.77  Degrees C

Temperature  + 60.96  Degrees C

Temperature  + 36.90  Degrees C

Temperature  + 56.46  Degrees C

Temperature  +121.87  Degrees C

Any ideas on why this is happening?
 

AllyCat

Senior Member
Hi,

Put a w1 = 0 immediately before the READTEMP12 and a SERTXD(#w1) or a DEBUG immediately after it, to be sure. But to me, it seems most likely to be a "hardware" issue, either a bad connection or an inadequate power supply / decoupling, etc.

Cheers, Alan.
 

static4067

New Member
Thank you both, I took AllyCat's suggestion on hardware and tried a new DS18B20 sensor and started getting proper readings. I suspect this one had gone bad for some reason.
 

static4067

New Member
Thanks Technical! The kicker was this sensor worked great until a power cycle on the board. When the chip came back up is when I began getting these wonky readings.
 

hippy

Technical Support
Staff member
The kicker was this sensor worked great until a power cycle on the board.
For future reference it is always best to give full details or circumstances of a problem as that will more easily help others identify what an issue may be. Glad to hear everything is back to working as expected.
 
Top