Wrong DS18B20?

Tyro

Member
I need to read the temperature and I do not like to re-invent the wheel so, not the cheapest way, I ordered a DS18B20 from Mouser.

The 08M2 circuit is simple, + to +5v, DQ to leg5 (C.2) with a 4k7 pullup to +5v, GND to 0v.

The code is:

main:
readtemp12 c.2,w1
debug
goto main

The data pin idles high, then goes low for 500us then considerable activity for about 10ms then high again. the debug screen shows w1 with 1360 in it. No matter how I change the temperature of the device, the 1360 number does not change. I swapped it for an identical part bought at the same time, no difference. Have I ordered the wrong device? The part number is a Dallas DS18B20P.
 

manuka

Senior Member
Try a simpler READTEMP with the variable as a byte "b1", rather than word "w1". DEBUG is a tad swampy, as all variables will be displayed. SERTXD is very snappy - use the style SERTXD (#b1," "). Stan.
 

bpowell

Senior Member
Have I ordered the wrong device? The part number is a Dallas DS18B20P.
Hmmm...I just ordered some 18b20s from Mouser...I made sure to order the DS18B20+ and NOT the DS18B20+PAR...the +PAR version is for parasitic power only....It has VDD and GND shorter internally...the VDD leg is not/connected to the internal die on a DS18B20+PAR.

If this is the device you purchased, you'll have to operate it in parasitic power mode only...I'm not sure how to do that on PICAXE...but I'm sure it's doable.

Ninja-edit: I *believe* the M2 chips can't do parasitic power reads because they poll the 18B20 to see if it's done with the conversion rather than holding the DQ line high...so you'll probably have to code your own read-temp solution.
 
Last edited:

bpowell

Senior Member
Another thought...since the DS81B20 is returning a value (85) that's the default value it returns..perhaps the command to readtemp isn't getting through? Do you have a 4.7k pullup on the DQ line? Confirmed you're pulling UP and not DOWN?
 

bpowell

Senior Member
Right...hence my comment, "You'll have to code your own read-temp solution"....the PICAXE chip hardware can certainly do it...but the "Readtemp" command won't work on an M2 chip using parasitic power...If the DS18B20 is a +PAR model...there is no way to connect power to it...via the VCC pin at least.
 

Technical

Technical Support
Staff member
DS18B20P (short for DS18B20-PAR) is not a DS18B20+ and does not work with the readtemp commands (as it is a parasitic power only device)



 

Tyro

Member
Sorry for the late reply. It is as I guessed at the beginning, the wrong device. I have just ordered the + device from Mouser.
 

bpowell

Senior Member
Sorry for the late reply. It is as I guessed at the beginning, the wrong device. I have just ordered the + device from Mouser.
You should be able to still use the PAR devices...you just can't use the built-in "Readtemp" command...you'll have to either roll your own code (shouldn't be too difficult) or, use a 20x2, 28x1 or 28x2 or 40x1 or 40x2 and use the One-wire commands (owin / owout).
 

luisss

New Member
Hi i have a problem with an 18b20 temp sensor, if i go to analogic sensor calibration and i choose the readadc option i receive a reading from the hih 4000 humidity sensor but the 18b20 only read 255, if i change to the readtemp option then returns "0", if i charge the program the variable b0 keep in "0" and b1 gives the right value of humidity 60 after the formula.is a problem with my temp sensor?
DALLAS
18B20
0838C3
+293AL
 

bpowell

Senior Member
Hi i have a problem with an 18b20 temp sensor, if i go to analogic sensor calibration and i choose the readadc option i receive a reading from the hih 4000 humidity sensor but the 18b20 only read 255, if i change to the readtemp option then returns "0", if i charge the program the variable b0 keep in "0" and b1 gives the right value of humidity 60 after the formula.is a problem with my temp sensor?
DALLAS
18B20
0838C3
+293AL
Post a picture of your circuit...and share your code as well.

Is the 18b20 wired as shown in the examples in the PICAXE manual? You can just throw a line on it and do a "Read-temp"...there is a pull-up needed, etc.
 

luisss

New Member
Hello this is the code, im using a 40X:


main:

temperatura:
readtemp 0,b0
debug b0
if b0>=19 then high 33
else goto flasha
endif
low 33
goto main


flasha:
high 33
wait 1
low 33
 

Attachments

bpowell

Senior Member
I've never worked with a 40X1 before...but if I'm reading the manual correctly, Pin 2 (Input 0) is not an output...so it can not be used for the one-wire protocol (for readtemp) since that requires SEND as well as RECEIVE.

Maybe try Pin 15 (c0) which is a Input and Output.

Just an idea...
 

luisss

New Member
The problem was in the pin I was using, in2 is adc kind, I change to pin 17 and now is reading well, thanks a lot.
 
Top