Pages: [1] 2   Go Down
Author Topic: Help with DS18S20  (Read 1061 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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,
Logged

Offline Offline
Edison Member
*
Karma: 33
Posts: 1468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just hook up one to get started.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Czech Republic
Offline Offline
Sr. Member
****
Karma: 4
Posts: 313
Absolute Beginner, yet.
Newbie in Arduino
since May 2013
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this:
http://www.pjrc.com/teensy/td_libs_OneWire.html
Logged

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...

Connecticut, USA
Offline Offline
Full Member
***
Karma: 8
Posts: 220
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley-wink
Logged

It's all about the skills

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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();
}
Logged

Connecticut, USA
Offline Offline
Full Member
***
Karma: 8
Posts: 220
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 03, 2013, 02:33:25 pm by elac » Logged

It's all about the skills

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Connecticut, USA
Offline Offline
Full Member
***
Karma: 8
Posts: 220
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you show a pic of your setup?
You need 4.7k ohm can you get that resistance?
Logged

It's all about the skills

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* Untitled Sketch_bb.jpg (631.94 KB, 1755x1179 - viewed 35 times.)
Logged

Stockholm Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Connecticut, USA
Offline Offline
Full Member
***
Karma: 8
Posts: 220
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ground is pin 1.
Your pic shows you have ground as pin 3.
Logged

It's all about the skills

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.
Logged

Connecticut, USA
Offline Offline
Full Member
***
Karma: 8
Posts: 220
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley-wink
Logged

It's all about the skills

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1] 2   Go Up
Jump to: