Pages: [1]   Go Down
Author Topic: All of my one wire temperature sensors aren't working?  (Read 555 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 0
Posts: 255
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright I feel like I am going crazy. I've hooked up my one wire temperature sensors exactly the same as I did 3 or 4 weeks ago, and am running the same script on the same arduino on the same IDE version, but all I get is "No more addresses". I've tried a 4.7k resistor, 2.2k resistor, and a 10k resistor, and well as using it in non parasite mode, and I get nothing. Nada, no change. This is driving me crazy, what the heck is going on?

I also tried it on a pro mini and am  getting the same result, what the heck.

http://playground.arduino.cc/Learning/OneWire

Black wire is connecting pins 1 and 3. Blue wire is going to ground, yellow wire is going to pin 10 from pin 2(data), and the orange wire is connecting 5v to pin 2 via resistor.\
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1676
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Black wire
 Blue wire
yellow wire
 orange wire


The picture is too tedious to read and doesn't seem to tell much anyway. It might be better to deal with three wires only.

5v to 5v
gnd to gnd
data to data with a the 4.7k pullup from same to 5v.

Indeed, why would you do it any other way?

If you wire the sensor the wrong way round, it will get very hot but it can survive it.

While your different values may not be doing any actual harm, there is no good reason to use anything other than the recommended 4.7k in your setup.

I don't know what code you are using. I found that by far the best code and the best tutortials are those at Hacktronics.
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 255
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need parasitic power mode for this application, and I have tried wiring it directly, but it is still not detected. I've used the code from hacktronix and the example code from the one wire library both with the same results.
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1676
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hummm

I would avoid parasite power until you are sure there is no alternative, and you certainly don't need it with that breadboard.

Since you use the Hacktronics code, I assume you have properly identified the addresses beforehand.

You mention "all", so does this problem apply to a multitude? If so, there may be a some dumb code problem, probably easily fixed. I say this because I have found the sensor very robust and a swag of duds seems pretty unlikely.
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 255
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hummm

I would avoid parasite power until you are sure there is no alternative, and you certainly don't need it with that breadboard.

Since you use the Hacktronics code, I assume you have properly identified the addresses beforehand.

You mention "all", so does this problem apply to a multitude? If so, there may be a some dumb code problem, probably easily fixed. I say this because I have found the sensor very robust and a swag of duds seems pretty unlikely.

Yeah the only thing left is trying this on another computer, my desktop is what I always used this on but this time I used my laptop, anyways here's the code, and it's always worked just fine until now.

Code:
#include <OneWire.h>

// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library

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, 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("  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");
}
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1676
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know if it's going to be helpful but I think that milesburton means kiss-of-death, and at least this is an alternative that compiles kosher and forms the basis for my stuff.

Code:
//  This Arduino sketch reads DS18B20 "1-Wire" digital
//  temperature sensors.
//  Copyright (c) 2010 Mark McComb, hacktronics LLC
//  License: http://www.opensource.org/licenses/mit-license.php (Go crazy)
//  Tutorial:
//  http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
//  code uses Arduino LCD stuff, for shield on Freetronics EtherTen.
//  Serial print commands are for PLX-DAQ
//  Research your own pins!

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(8,9,A2,5,6,7);
int flag;
// Data wire is on pin 3
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress InThermo = {  0x28, 0x69, 0xC2, 0xB0, 0x03, 0x00, 0x00, 0X9F };
DeviceAddress OutThermo = { 0x28, 0x7A, 0x8B, 0xC0, 0x03, 0x00, 0x00, 0x2F };

//temperature variables
float InTemp, OutTemp, diff, drain, flow, power, tempC;

void setup(void)
{
 
  Serial.begin(9600);
  Serial.println("LABEL,Time,TempIn,TempOut,diff");
  lcd.begin(16, 2);
  lcd.print("temp in     out");   

  // Start up the library
  sensors.begin();
  sensors.setResolution(InThermo, 12);
  sensors.setResolution(OutThermo, 12);
}

void loop(void)
{
  delay(1000);
    Serial.print("DATA,TIME,       ");
  flag = 0;
  //Get the sensor readings. There are two of them
  sensors.requestTemperatures();

  GetandPrint(InThermo);
  InTemp=tempC;
  flag = 1;

  GetandPrint(OutThermo);
  diff = tempC - InTemp;
  Serial.print (diff);
  Serial.println(" ,  ");

}

void GetandPrint(DeviceAddress deviceAddress)
{
  tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  }
  else {
    Serial.print(tempC);
    Serial.print(" ,  ");
  }
  lcd.setCursor (1,1);
  if (flag==1)
    (
    lcd.setCursor (11,1)
      );
  lcd.print (tempC);
}

Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 255
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I grabbed a 10k resistor, and for some reason it works now, but a 4.7k didn't work at all. I'm not sure if it's going to throw off the accuracy though. My fan is showing a temp of 23 degrees, but this is showing a bit under 25, so maybe ill try a lower resistor.

uhg just tried in parasite mode and now it's not working. What the hell.
« Last Edit: June 21, 2013, 12:32:43 am by XOIIO » Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 255
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it works with a 2.2k ohm resistor as well, maybe the temp a bit further from the fan is higher, but it still doesnt find it in parasitic mode.
« Last Edit: June 21, 2013, 12:39:20 am by XOIIO » Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1676
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know why a 10k would work where a 4.7 doesn't but I don't think either has a bearing on the temperature accuracy. I'm sure something else is going on.
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 255
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

but what could it be? why would it work in regular mode and not in parasite mode. Last time I used the same damn resistor and it worked perfectly, but this time it's not working at all.

uuuuuuhg
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 255
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well got it working, found a way to use 3 wired, odd thing is my pro mini needed a totally different wire than my mega
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1676
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well got it working,

Ah well, that's a relief..... I'm afraid I don't know anything about those exotic Arduinos...
Logged

Pages: [1]   Go Up
Jump to: