DS1820 giving me wrong temperature

I'm completely new on these things. I've connected a DS1820 to a Arduino Duemilanove and reading the temperature given be the DS1820 via the USB cable.
The thing is that I'm given wrong temperature. I've tried another DS1820, but it's giving me the same result.
Ideas, anyone?

I'm using the OneWire code on arduino.cc (sorry, can't link) and the temperature given to me is 2,37. It isn't the hottest house in the city, but it's NOT 2,37 C! :wink: (The DS1820 is placed right by the PC.)

Here's your link: Arduino Playground - OneWire

The datasheet for DS18x20 shows that there are various differences in how long it takes to settle on a temperature sample, for different model sensors. The page linked above shows that there are differences in the units they compute, as well. The big unitless integer has to be converted to a human-like temperature and unless your code is sure of the right conversion and the right sensor model type, it's going to come out wrong.

What's the comma in your 2,37 ? The source code on that page tries to come up with fractional degrees with a period, and two digits for hundredths of a degree following it. I doubt it's 2.37¬įC in your house either.

The comma in my result is required by C#, for some strange reason, to convert the string to a float when reading from the serial port.

I think that my temperature unit is a DS18S20. I solved my problem after reading the data sheet.

Thanks, halley!

The solution:

void loop()
  int HighByte, LowByte, TReading, SignBit, Whole, Fract;

  OneWireOutByte(TEMP_PIN, 0xcc);
  OneWireOutByte(TEMP_PIN, 0x44); // perform temperature conversion, strong pullup for one sec

  OneWireOutByte(TEMP_PIN, 0xcc);
  OneWireOutByte(TEMP_PIN, 0xbe);

  LowByte = OneWireInByte(TEMP_PIN);
  HighByte = OneWireInByte(TEMP_PIN);
  TReading = (HighByte << 8) + LowByte;
  SignBit = TReading & 0x8000;  // test most sig bit
  if (SignBit)
    TReading = (TReading ^ 0xffff) + 1;
  Whole = TReading >> 1;
  Fract = TReading & 0x0001;
  if (Fract > 0)
  delay(5000);      // 5 second delay.  Adjust as necessary

Edit: The reason I couldn't give you the link is that it was my first post. Strange rule, by the way.

What's the comma in your 2,37 ?

Unanswered question.

In (mainland) Europe (ie not here in the UK), the decimal point is routinely marked with a comma.
If you check the code above, you'll see that the comma is entered as a literal. It isn't a mistake - just the way things are done in some places!