DS18S20 thermometer not working properly.

Hi, my DS18S20 1-wire thermometers arrived, wired it up to the arduino, but it doesn't return anything tht makes sense to the com port.

here's what i get from the 1-wire code from arduino.cc

P=1 26 0 4B 46 FF FF 10 10 8B CRC=8B No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF 10 10 8B CRC=8B No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF 10 10 8B CRC=8B No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF F 10 7F CRC=7F No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF 10 10 8B CRC=8B No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF F 10 7F CRC=7F No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF F 10 7F CRC=7F No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF F 10 7F CRC=7F No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF F 10 7F CRC=7F No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF F 10 7F CRC=7F No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF F 10 7F CRC=7F No more addresses. R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF F 10 7F CRC=7F No more addresses. R=10 5E 7B E3 1 8 0 C7

i've messed around with the code and it just doesn't work :(

what is wrong? i'm sure the wiring isn't wrong...

The example is working correctly. What you are seeing is the raw values returned from the device. R is the address for the device. P is the data returned CRC is the checksum to compare against the last value of P

You now need to find another example that will take the: R=10 5E 7B E3 1 8 0 C7 P=1 26 0 4B 46 FF FF 10 10 8B CRC=8B

and turn it into something you can read.

This should help explain it. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1208206686

Gordon

Hi, i thought that was it, but in the example he had a code that is suposed to do that, but it didn’t, i now wired it up to an lcd using this code:

#include <LCD3Wire.h> 
#include <DallasTemperature.h>


// Arduino pins
#define LCD_LINES 2  // number of lines in your display
#define DOUT_PIN  7  // Dout pin
#define STR_PIN   6  // Strobe pin
#define CLK_PIN   5  // Clock pin

//create object to control an LCD.  
LCD3Wire lcd = LCD3Wire(LCD_LINES, DOUT_PIN, STR_PIN, CLK_PIN); 
DallasTemperature tempSensor1; 
// You may instantiate as many copies as you require.

char * floatToString(char * outstr, float value, int places, int minwidth, bool rightjustify);

void setup(void) {
  // initialize
    lcd.init();
    tempSensor1.begin(12); // Data wire is plugged into pin 12 on the Arduino
}

void loop(void) {
  float temp;
  char buff[10];
    switch(tempSensor1.isValid())
   {
       case 1:
           Serial.println("Invalid CRC");
                 tempSensor1.reset(); // Attempts to redetect IC
           return;
       case 2:
           Serial.println("Not a valid device");
                 tempSensor1.reset(); // Attempts to redetect IC
           return;
   }
   temp = (tempSensor1.getTemperature());
   lcd.cursorTo(2,0); 
   lcd.printIn(floatToString(buff,temp,3,0,false));
   lcd.print(0xDF);// degree sign
   lcd.print('C');


}


// floatToString.h
//
// Tim Hirzel
// tim@growdown.com
// March 2008
// float to string
// 
// If you don't save this as a .h, you will want to remove the default arguments 
//     uncomment this first line, and swap it for the next.  I don't think keyword arguments compile in .pde files

//char * floatToString(char * outstr, float value, int places, int minwidth=, bool rightjustify) {
char * floatToString(char * outstr, float value, int places, int minwidth, bool rightjustify) {
    // this is used to write a float value to string, outstr.  oustr is also the return value.
    int digit;
    float tens = 0.1;
    int tenscount = 0;
    int i;
    float tempfloat = value;
    int c = 0;
    int charcount = 1;
    int extra = 0;
    // make sure we round properly. this could use pow from <math.h>, but doesn't seem worth the import
    // if this rounding step isn't here, the value  54.321 prints as 54.3209

    // calculate rounding term d:   0.5/pow(10,places)  
    float d = 0.5;
    if (value < 0)
        d *= -1.0;
    // divide by ten for each decimal place
    for (i = 0; i < places; i++)
        d/= 10.0;    
    // this small addition, combined with truncation will round our values properly 
    tempfloat +=  d;

    // first get value tens to be the large power of ten less than value    
    if (value < 0)
        tempfloat *= -1.0;
    while ((tens * 10.0) <= tempfloat) {
        tens *= 10.0;
        tenscount += 1;
    }

    if (tenscount > 0)
        charcount += tenscount;
    else
        charcount += 1;

    if (value < 0)
        charcount += 1;
    charcount += 1 + places;

    minwidth += 1; // both count the null final character
    if (minwidth > charcount){        
        extra = minwidth - charcount;
        charcount = minwidth;
    }

    if (extra > 0 and rightjustify) {
        for (int i = 0; i< extra; i++) {
            outstr[c++] = ' ';
        }
    }

    // write out the negative if needed
    if (value < 0)
        outstr[c++] = '-';

    if (tenscount == 0) 
        outstr[c++] = '0';

    for (i=0; i< tenscount; i++) {
        digit = (int) (tempfloat/tens);
        itoa(digit, &outstr[c++], 10);
        tempfloat = tempfloat - ((float)digit * tens);
        tens /= 10.0;
    }

    // if no places after decimal, stop now and return

    // otherwise, write the point and continue on
    if (places > 0)
    outstr[c++] = '.';


    // now write out each decimal place by shifting digits one by one into the ones place and writing the truncated value
    for (i = 0; i < places; i++) {
        tempfloat *= 10.0; 
        digit = (int) tempfloat;
        itoa(digit, &outstr[c++], 10);
        // once written, subtract off that digit
        tempfloat = tempfloat - (float) digit; 
    }
    if (extra > 0 and not rightjustify) {
        for (int i = 0; i< extra; i++) {
            outstr[c++] = ' ';
        }
    }


    outstr[c++] = '\0';
    return outstr;
}

and it’s working :)(i didnt wire it to the cd before because i didn’t have my 595’s)

there some temperature errors, though, before it was displaying 22C, when it’s actually 17C, but i’t getting there now…
thanks anyway :slight_smile: