It took me quite a while to get my DS18B20P (aka. DS18B20P-PAR) to work properly and give me nice readable Celsius values. I finally got it all to work while keeping the code somewhat clean by using a slightly modified OneWire library and wrapping my own library around it.
I couldn't find any other way to do this, but I wanted to give you guys access to my code, and my changes to the OneWire library (I already sent them over email to the guy who released the latest version). I released my code under Creative Commons Attribution-ShareAlike 3.0 Unported License, the OneWire library is using some different license (explained in the OneWire.cpp source).
I had no trouble talking to multiple DS18B20 chips with the existing OneWire.h. The example code was able to scan the wire for thermometers and report their addresses:
Please don't take this the wrong way, but what functionality does your new code provide that wasn't already provided by the existing onewire libraries? The DS18B20 is probably the most widely used 1-wire device. Am I missing something here? (note: I'm probably missing something here )
Well, when I was trying to get mine to work, I also noticed most other people seemed to have no issues with theirs.. However, most of them did not work for me at all, and the one piece of code that finally was able to read data from the sensor gave junk output a that made no sense, e.g. it said the temperature was 1800, when I touched the sensor for a second it was 2600, etc.
There are really not many differences to the already existing OneWire library and other pieces of code on the net, but a few still:
This one works for me
This one gives useful data, in celsius with decimal precision, e.g. if the sensor thinks it's 24.56C, it will return "24.56"
This one requires you to just run .read() to get data, not ".reset(); .skip(); .write(); delay(); .reset(); .skip(); .write(); .read(); ..."
This code is not that painful to look at
It actually might give you a clue of what error you have, if you have one, instead of just saying "if you get result -10000 you have an error"
... at some point I will probably add the support to give it an address for the sensor, at the moment it uses .skip() as I really don't need the hassle of supporting a gazillion sensors on the one pin. Also I was planning on giving you the option to decide what to do with the 800msec it takes for the sensor to do it's temperature calculations, instead of pointlessly sleeping it away in my code. Neither of these is really a high priority for me, I need data out of the sensor like once every 5 minutes, and I will just have a couple of sensors so I might just as well use different pins for them..