Go Down

Topic: Help with DS18S20 (Read 1 time) previous topic - next topic

luketheduke

I just got 4 DS18S20 thermometers from Jamecohttp://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?search_type=jamecoall&catalogId=10001&freeText=302551&langId=-1&productId=302551&storeId=10001&ddkey=http:StoreCatalogDrillDownView but when I tryed the example program that comes with the onewire libraryhttp://playground.arduino.cc/Learning/OneWire it just kept on saying "No more addresses". All help is appreciated.
Thanks in advance,

KeithRB

Just hook up one to get started.

luketheduke

I did but it gave me the error message listed in my first post

K5CZ

Try this:
http://www.pjrc.com/teensy/td_libs_OneWire.html
Arduino Uno R3, Arduino Mega 2560 R3, Ethermega (R3), and some Ethernet Shields (R3), Chronodots, TMP36 sensors, DS18B20 sensors, LCDs/TFTs, RS232C to learn and play...

elac

How do you have it hooked up?
Are you using a 4.7k ohm resistor?
The more info you give the more people can help.  ;)
It's all about the skills

luketheduke

I'm using 2 resistors for about 4.4kohms which is connected to vdd on one side and to 5v on the other side. the middle pin is connected to pin D10 and the rightmost pin is connected to gnd. here is my program
Code: [Select]
#include <OneWire.h>

/* DS18S20 Temperature chip i/o */

OneWire  ds(10);  // on pin 10

void setup(void) {
  Serial.begin(9600);
}

void loop(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
 
  if ( !ds.search(addr)) {
    Serial.print("No more addresses.\n");
    ds.reset_search();
    delay(250);
    return;
  }
 
  Serial.print("R=");
  for( i = 0; i < 8; i++) {
    Serial.print(addr[i], HEX);
    Serial.print(" ");
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.print("CRC is not valid!\n");
      return;
  }
 
  if ( addr[0] != 0x10) {
      Serial.print("Device is not a DS18S20 family device.\n");
      return;
  }

  // The DallasTemperature library can do all this work for you!

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);         // start conversion, with parasite power on at the end
 
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
 
  present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE);         // Read Scratchpad

  Serial.print("P=");
  Serial.print(present,HEX);
  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    Serial.print(data[i], HEX);
    Serial.print(" ");
  }
  Serial.print(" CRC=");
  Serial.print( OneWire::crc8( data, 8), HEX);
  Serial.println();
}

elac

#6
Oct 03, 2013, 09:30 pm Last Edit: Oct 03, 2013, 09:33 pm by elac Reason: 1
The 4.7k ohm resistor needs to go from 5v supply to the middle pin (DQ) then connect the middle pin (DQ) of the DS18S20 to pin 10 of the Arduino. And ground to ground.
It's all about the skills

luketheduke

I wired it up as you said but it is still giving me the error I had in the first place.

elac

Can you show a pic of your setup?
You need 4.7k ohm can you get that resistance?
It's all about the skills

luketheduke

the schematic is attached and I'll try to get the extra 40 or so ohms I need.

Hi the Vdd pin is not connected. Try to you connected it +5V or if you use PARASITE-POWERconnect it to GND.

elac

Ground is pin 1.
Your pic shows you have ground as pin 3.
It's all about the skills

luketheduke

Ive now moved all the pins to their correct positions and I can read its address and whatever else it spits out. could i have help with decoding what it gives me over the serial port? here is the code
Code: [Select]
#include <OneWire.h>

// DS18S20 Temperature chip i/o
OneWire ds(10);  // on pin 10

void setup(void) {
  // initialize inputs/outputs
  // start serial port
  Serial.begin(9600);
}

void loop(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
      Serial.print("No more addresses.\n");
      ds.reset_search();
      return;
  }

  Serial.print("R=");
  for( i = 0; i < 8; i++) {
    Serial.print(addr[i], HEX);
    Serial.print(" ");
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.print("CRC is not valid!\n");
      return;
  }

  if ( addr[0] == 0x10) {
      Serial.print("Device is a DS18S20 family device.\n");
  }
  else if ( addr[0] == 0x28) {
      Serial.print("Device is a DS18B20 family device.\n");
  }
  else {
      Serial.print("Device family is not recognized: 0x");
      Serial.println(addr[0],HEX);
      return;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);         // start conversion, with parasite power on at the end

  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.

  present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE);         // Read Scratchpad

  Serial.print("P=");
  Serial.print(present,HEX);
  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    Serial.print(data[i], HEX);
    Serial.print(" ");
  }
  Serial.print(" CRC=");
  Serial.print( OneWire::crc8( data, 8), HEX);
  Serial.println();
}

this is what it gives me over serial:
P=1 30 0 4B 46 FF FF A 10 47  CRC=47
No more addresses.
R=10 95 5F D 2 8 0 FF Device is a DS18S20 family device.
the values seem to change so I am wondering if somewhere in there the temperature is imbedded in it.

elac

Great, glad to hear you have it working.
Try using this library:
http://milesburton.com/Dallas_Temperature_Control_Library
Give the "Tester" example a try.
It will give you a lot of understandable info. and the temp in F and C.
You will need to connect the signal pin  to pin 2 instead of  pin 10.
If you need help ask.  ;)
It's all about the skills

luketheduke

when I ran the tester code it sent this over and over out of the serial port:
Requesting temperatures...DONE
Temperature for device: 0
Temp C: 85.00 Temp F: 185.00
I know for sure that it is not over 100 degrees F here. So what is my problem now?

Go Up