Go Down

Topic: DS18B20 Temperature Sensor returns "No more addresses." (Read 8293 times) previous topic - next topic

el_supremo

Code: [Select]
Yes I am wiring correctly
That doesn't tell me much. Exactly which pin have you wired the data pin to?

I've also used the code in msg #1(OP) which uses pin 10, and the diagram in msg #2 (which uses pin 10). It works. Both sample sketches work, provided that the 18B20 is wired to the correct pin.

Either your wiring and/or your code are incorrect or you aren't using DS18B20 sensors.
Look at the flat surface of the sensors. Do the first two lines have this written on it?
DALLAS
18B20

Can you take a clear, focused photo of the way that you have the DS18B20 wired and attach it here?

Pete
Don't send me technical questions via Private Message.

alphacheese

Code: [Select]
Yes I am wiring correctly
That doesn't tell me much. Exactly which pin have you wired the data pin to?

I've also used the code in msg #1(OP) which uses pin 10, and the diagram in msg #2 (which uses pin 10). It works. Both sample sketches work, provided that the 18B20 is wired to the correct pin.

Either your wiring and/or your code are incorrect or you aren't using DS18B20 sensors.
Look at the flat surface of the sensors. Do the first two lines have this written on it?
DALLAS
18B20

Can you take a clear, focused photo of the way that you have the DS18B20 wired and attach it here?

Pete
I cannot confirm print on IC as it is a waterproof model and is located in a steel tube with heatshrink tubing, no writing on the outside.

I have tried everything I can think of and read of. Let me regale you. Here is the code I started with. It's included in the examples of the OneWire Library.
Code: [Select]
#include <OneWire.h>

OneWire  ds(10);  // on pin 10 (a 4.7K resistor is necessary)

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

void loop(void) {
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
  
  if ( !ds.search(addr)) {
    Serial.println("No more addresses.");
    Serial.println();
    ds.reset_search();
    delay(250);
    return;
  }
  
  Serial.print("ROM =");
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print(addr[i], HEX);
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return;
  }
  Serial.println();
 
  // the first ROM byte indicates which chip
  switch (addr[0]) {
    case 0x10:
      Serial.println("  Chip = DS18S20");  // or old DS1820
      type_s = 1;
      break;
    case 0x28:
      Serial.println("  Chip = DS18B20");
      type_s = 0;
      break;
    case 0x22:
      Serial.println("  Chip = DS1822");
      type_s = 0;
      break;
    default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44);        // 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("  Data = ");
  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();

  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // "count remain" gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    // at lower res, the low bits are undefined, so let's zero them
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    //// default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
  fahrenheit = celsius * 1.8 + 32.0;
  Serial.print("  Temperature = ");
  Serial.print(celsius);
  Serial.print(" Celsius, ");
  Serial.print(fahrenheit);
  Serial.println(" Fahrenheit");
}

I have the VCC wire of sensor wired to breadboard rail wired to 5v on arduino (tried different ports on breadboard, confirmed 5.00v coming from arduino). I have ground wire of sensor wired to breadboard rail wired to ground of arduino (tested different ports on breadboard). I have a 4.7K ohm resistor wired from 5v rail wired to data wire of sensor. I have tested a 2.2K ohm and 10K ohm resistor with 5 different sensors. The data wire from breadboard is in digital pin 10 of my uno.  I have attempted wiring to pin 2, 3, 4, 7, and 8 and changed accordingly in sketch:

Code: [Select]
OneWire  ds(10); or OneWire ds(2); or OneWire ds(7); ... etc
I am not using parasite mode, changed code to:

Code: [Select]
ds.write(0x44);


I have tried running as parasite with VCC wire of sensor disconnected and code:


Code: [Select]
ds.write(0x44, 1);
I have tried every combination of trying different sensor, in parasite mode or not, different arduino pins, different resistors, different breadboard ports, and different codes. I have tried these codes as well to detect sensor and get ID:

Code: [Select]
#include <OneWire.h>

OneWire  ds(3);  // Connect your 1-wire device to pin 3

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

void discoverOneWireDevices(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
 
  Serial.print("Looking for 1-Wire devices...\n\r");
  while(ds.search(addr)) {
    Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
    for( i = 0; i < 8; i++) {
      Serial.print("0x");
      if (addr[i] < 16) {
        Serial.print('0');
      }
      Serial.print(addr[i], HEX);
      if (i < 7) {
        Serial.print(", ");
      }
    }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
        return;
    }
  }
  Serial.print("\n\r\n\rThat's it.\r\n");
  ds.reset_search();
  return;
}

void loop(void) {
  // nothing to see here
}


Get this reported back:
Code: [Select]
Looking for 1-Wire devices...



That's it.


I can't thin of what to try next.
If you don't have anything helpful to contribute, then DON'T post anything at all.

alphacheese

SOLVED

Got it! I found your post here and my data wire and VCC wire were labeled wrong from the manufacturer too!

This image is wrong for my sensors. For anyone else: the red is VCC and yellow is data on my sensors.
If you don't have anything helpful to contribute, then DON'T post anything at all.

el_supremo

Don't send me technical questions via Private Message.

Nick_Pyner

SOLVED

Got it! I found your post here and my data wire and VCC wire were labeled wrong from the manufacturer too!

This image is wrong for my sensors. For anyone else: the red is VCC and yellow is data on my sensors.
Wow! I haven't heard of that before - just somebody who wrote the instructions being incompetent to instruct. The image is probably wrong for everybody else's sensors too. One would expect red to be 5v, even though the others may vary. (I still think that code is junk)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy