Go Down

Topic: Dallas Temperature Control Library released ;) (Read 23425 times) previous topic - next topic


Yes, thanks to James Whiddon the library can change precision and read temperatures as Rusty suggested.

You can grab the latest version (Aside from my wiki) here: http://download.milesburton.com/Arduino/MaximTemperature/DallasTemperature_250.zip


Champion, I'll check this out as soon as I get home.


Im a bit confused, does this library support only one temp sensor pr digital pin?


Nope, it supports up to 64 devices per pin if I recall correctly. I could even be more


I know the onewire bus supports that.

You wrote in post #3 in this thread:
"This library isn't designed to use more than one device on the wire. You could but I didn't see the need for "version 1"."

That made me believe that i can only adress one tempsensor for each digital pin whilst using your library.


Sadly I cannot edit old posts. If you take a look at the web page you'll notice the library has been upgraded many times of the last few months. Each version has a change log so you can see what has been upgraded since.

Worth a look over, I hope the Arduino guys can sort the forum. Sorry for the confusion ;)


Ahh I see.. thanks!

So the latest stable version is 3.40?

Ill get it tested right away.


Dec 20, 2009, 08:12 am Last Edit: Dec 20, 2009, 08:17 am by gjelsvik Reason: 1
Works like a charm with multiple sensors :)

Though, i very often get 85C // 185F wich i only got  occanionally with the onewire library from the playground: http://www.arduino.cc/playground/Learning/OneWire

Now i have two sensors on my breadboard. If i touch one of them, to heat it up, It starts to read 85C and wont work until Arduino reset. With the onewire library it would read 85C once or twice, I could just unplug and reinsert the sensor, and it would read correct. I didnt have to reset the Arduino.

Should i run sensors.begin(); In loop main to avoid this?


Hmm, you shouldn't see a crash at 85F, there could be a fault. I'll take a look when I get a chance.

You shouldn't need to use begin more than once


According to "google" the 85C / 185F is the value the DS18B20 is returning right after a reset.
So it might be my breadbord/ loose cables that is causing this. I have soldered it up now, and it doesnt give me a 85C anymore.

Great library, much easier to implement than the OneWire that is on the playground. You should get yours on the playground aswell.


Hmm, Unless someone took it off it should still be there. A little hidden maybe ;)


Has anyone tried dynamically plugging in and unpluging sensors. I can not find a way of seeing is the sensor has gone, isValid only appears to check the CRC of the stored sensor ID. At the moment I am reading the resolution, which works most the time but is a bit of a cludge. Any suggestions most welcome - it is for yet another Arduino Beer Making machine - I'll post more on the that when it is done.

Many thanks for the excellent code.


I want to convert the sensor address to a string, but I have hard time getting it to work.

This is what I tried:
Code: [Select]

void DeviceAddressString(DeviceAddress deviceAddress)
 char *deviceAddressString="";
 char *tempAddr;
 strcpy(deviceAddressString, "");
 for (uint8_t i = 0; i < 8; i++)
   itoa(*deviceAddress[i], tempAddr, 10);
   strcat(deviceAddressString, tempAddr);

A call to this function should fill deviceAddressString with the value of the device address.

Code: [Select]


Help/suggestions are appreciated.



    Normally 1-wire device addresses are written out as hex, base 16.
Also, the way you're concatenating the output from itoa(), all of your
decimal numbers will be "squished" together without any character
separating them.  What you'd get is something like 950001261316316.

  Here's two functions I use to print out my 1-wire addresses.
I use them for debugging 1-wire code.
Code: [Select]
#define OW_ADDR_LEN     8     // bytes (64-bits

// Convert a byte to a 2-digit hex string, zero-filled, NULL terminated.
// Serial.print(x, HEX) doesn't do zero-fill.
char *byte2hex(byte b)
   static const char hex[] = "0123456789ABCDEF";
   static char answer[3] = {
       '\0', '\0', '\0'             };

   answer[0] = hex[(b & 0xf0) >> 4];
   answer[1] = hex[b & 0x0f];

   return (answer);    

// Print a OW address, but no newline afterwards
void print_address(byte *x)
   byte i;
   byte *p;

   p = &x[OW_ADDR_LEN-1];     // Point to end of address

   for (i=0; i<OW_ADDR_LEN; i++)

   Serial.print(" ");

Go Up