Go Down

Topic: DS18B20 error (Read 1 time) previous topic - next topic

kristof

Hello,
I made a temperature controller unit for my car. It runs on WVO. It measures 8 different temperatures with the DS18B20. Everything works great for a month now, but a few days ago suddenly a get the temperature -127 on the lcd for all the 8 sensors. When I removed 1 specific sensor everything works again ( I get a -127 for that sensor on the lcd ). I replaced this sensor with another DS18B20 and it works again. So, problem solved I thought. But this morning, I get the error again.(-127 value for al the sensors )
After a minute the values where back to normal. I worked with the "old" Onewire lib in my arduino software. So I downloaded the latest version a will trie to upload my sketch later this day to see if this solved the problem.
Anyone another suggestion? Someone can explain this or had this problem also?
Thanks

Code: [Select]

/*
  Example of using the SparkSoftLCD library for the Arduino
 
  2010 C. A. Church
     http://openmoco.org/   
*/

 

#include "SparkSoftLCD.h"

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

// Data wire is plugged into pin 3 on the Arduino
#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.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
DeviceAddress TempSensor1 = { 0x28, 0x53, 0x5C, 0xEC, 0x02, 0x00, 0x00, 0xC9 };
DeviceAddress TempSensor2 = { 0x28, 0x75, 0x61, 0xEC, 0x02, 0x00, 0x00, 0xA5 };
DeviceAddress TempSensor3 = { 0x28, 0xBA, 0x6C, 0xEC, 0x02, 0x00, 0x00, 0xF2 };
DeviceAddress TempSensor4 = { 0x28, 0x9C, 0x3F, 0x82, 0x03, 0x00, 0x00, 0x03 };
DeviceAddress TempSensor5 = { 0x28, 0x35, 0x43, 0x82, 0x03, 0x00, 0x00, 0x85 };
DeviceAddress TempSensor6 = { 0x28, 0x1D, 0x3B, 0x82, 0x03, 0x00, 0x00, 0xC1 };
DeviceAddress TempSensor7 = { 0x28, 0xAB, 0x2E, 0x82, 0x03, 0x00, 0x00, 0xDA };
DeviceAddress TempSensor8 = { 0x28, 0x0E, 0x47, 0x82, 0x03, 0x00, 0x00, 0x8F };


  // LCD transmit pin
#define LCD_TX 2

SparkSoftLCD lcd = SparkSoftLCD(LCD_TX);

int temperatuur1=0;  // Warmte wisselaar
int temperatuur2=0;  // IP ingang, deze mag niet boven de 69°C komen. vanaf 66°C moet de elektrische verwarming van de filter uitgeschakeld worden. Vanaf 69°C moet de bypas opspringen. Op 68°c mag deze terug afspringen
int temperatuur3=0;  // Temperatuur Filter
int temperatuur4=0;  // Buiten temperatuur
int temperatuur5=0;  // IP uitgang
int temperatuur6=0;  // Temperatuur Tracing, deze mag max 45°C worden,
int temperatuur7=0;  // Temperatuur Leiding
int temperatuur8=0;  // Temperatuur tank

int outputTR =  4;  // Aansturen Tracing 
int outputFI =  5;  // Aansturen verwarming Filter
int outputVA =  6;  // Aantsturen vacuumklep
int outputBY =  7;  // Aansturen ByPass

void setup() {

pinMode(outputTR, OUTPUT);
pinMode(outputFI, OUTPUT);
pinMode(outputVA, OUTPUT);
pinMode(outputBY, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);


 
Serial.begin(9600);
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(TempSensor1, 10);
  sensors.setResolution(TempSensor2, 10);
  sensors.setResolution(TempSensor3, 10);
  sensors.setResolution(TempSensor4, 10);
  sensors.setResolution(TempSensor5, 10);
  sensors.setResolution(TempSensor6, 10);
  sensors.setResolution(TempSensor7, 10);
  sensors.setResolution(TempSensor8, 10);
 
 
   // setup lcd
   
pinMode(LCD_TX, OUTPUT);
lcd.begin(9600);
lcd.clear();

   // hidden cursor
lcd.cursor(0);

show_setup();


}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
//float temp1 = sensors.getTempC(TempSensor1);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
    Serial.print(" F: ");
    Serial.print(DallasTemperature::toFahrenheit(tempC));
  }
}

void loop() {
 
sensors.requestTemperatures();
 
temperatuur1 = sensors.getTempC(TempSensor1);
temperatuur2 = sensors.getTempC(TempSensor2);
temperatuur3 = sensors.getTempC(TempSensor3);
temperatuur4 = sensors.getTempC(TempSensor4);
temperatuur5 = sensors.getTempC(TempSensor5);
temperatuur6 = sensors.getTempC(TempSensor6);
temperatuur7 = sensors.getTempC(TempSensor7);
temperatuur8 = sensors.getTempC(TempSensor8);
 
// Serial.print("Getting temperatures...\n\r");
//                                      sensors.requestTemperatures();
 
  //Serial.print("Temp5: ");
// printTemperature(TempSensor1);
  //Serial.print("\n\r");
  //Serial.print("Temp2: ");
  //printTemperature(TempSensor2);
  //Serial.print("\n\r");
  //Serial.print("temperatuur1: ");
//Serial.print(temperatuur5);
// Serial.print("\n\r");
  //Serial.print("temperatuur2: ");
  //Serial.print(temperatuur2);
  //Serial.print("\n\r");
  //Serial.print("temperatuur3: ");
  //Serial.print(temperatuur3);
  //Serial.print("\n\r\n\r");
 
 

 
  delay (400);
    lcd.clear();
   
      // block-style blinking cursor:2
      // underscore style cursor:1
      // hidden cursor:0
    lcd.cursor(0);
    // cursorTO ( rij, kolom )
    lcd.cursorTo(1,1);
    lcd.print("WW  IP  FI  OT");
    lcd.cursorTo(1,3);
    lcd.print(temperatuur1);
    lcd.cursorTo(1,7);
    lcd.print(temperatuur2);
    lcd.cursorTo(1,11);
    lcd.print(temperatuur3);
    lcd.cursorTo(1,15);
    lcd.print(temperatuur4);
   // delay(500);
   
   // lcd.clear();
   
      // hidden cursor
    lcd.cursor(0);
    lcd.cursorTo(2,1);
    lcd.print("IP  TR  LE  TA");
    lcd.cursorTo(2,3);
    lcd.print(temperatuur5);
    lcd.cursorTo(2,7);
    lcd.print(temperatuur6);
    lcd.cursorTo(2,11);
    lcd.print(temperatuur7);
    lcd.cursorTo(2,15);
    lcd.print(temperatuur8);
   
   
   
   // regeling tracing
   if ( (temperatuur6) < (-20) )
   {
    digitalWrite(outputTR, LOW); //error, inlezeing gebeurd niet goed
   
   }
   else
   {
      if ( temperatuur6 < 44 )
     {
      digitalWrite(outputTR, HIGH);
     }
   
     else
     {
      digitalWrite(outputTR, LOW);
     }
     
   }
   // regeling filter, inlezen temperatuur ingang IP en temperatuur filter
   
   if ( (temperatuur3) < (-20))
   {
    digitalWrite(outputFI, LOW) ; //error, inlezing temperatuur gebeurd niet goed
   }
   else
   {
     if ( (temperatuur3 < 80)&&(temperatuur2 < 64) )
     {
      digitalWrite(outputFI, HIGH);
     }
     else
     {
      digitalWrite(outputFI, LOW);
     }
     
   }
   
   // regeling Bypass, inlezen temperatuur ingang IP en temperatuur uitgang ip
   
   if (((temperatuur2) < (-20))||((temperatuur5) < (-20) ) )
   {
     digitalWrite(outputBY, LOW);// error, inlezing temperatuur gebeurd niet goed
   }
   else
   {
      if ( (temperatuur2 > 68)||(temperatuur5 >78 ) )
     {
      digitalWrite(outputBY, HIGH);
     }
     else
     {
      digitalWrite(outputBY, LOW);
     }
   
   }

}



void show_setup() {
 
lcd.print("Frontera on PPO");

   // send cursor to 2nd row, first column
lcd.cursorTo(2,1);

delay(400);

for (byte i = 0; i <= 15; i++ ) {
     delay(150);
       // scroll display to the right
     lcd.scroll(true);
}

delay(400);
lcd.print("Version V09");


for (byte i = 0; i <= 15; i++ ) {
     delay(150);
       // scroll back to the left, revealing our new text
     lcd.scroll(false);
     //lcd.clear();
}

}

RIDDICK

if they all read -127, then it might be that a defective part ruins the 1-wire-talk-show... :)

so:
r u doing something weird to those sensors?
over-voltage?
wrong cabling?
over-temperature?
under-temperature?
-Arne

pylon

How did you wire them? Only two wires (data and GND) or three wires (data, Vcc and GND)? In the two-wire setup you might need to change the pull-up resistor value to have enough power for all the sensors (although the measurement is distributed over time they all have to react to the 1-wire protocol and need some power for that. What value are you using? Is it an option for you to use the three wire setup?

MarkT

In the two wire setup you have to use active pull-up during temperature conversions - nothing works otherwise. 

My suspicion is interference - are all the sensors decoupled (if 3-wire)?  Is the cable properly shielded?  A car can be a very electrically noisy environment.  If sensors are failing repeatedly then there will be a cause - over voltage spikes is a likely possibility.  I've got a network of ten DS18B20's in a little wireless network (home and garden, not car) and they all have worked fine for 10 months now with no obvious false readings (out of millions) - these devices should be very reliable if treated right.  (but the sensors are all on short leads in my case).
[ I won't respond to messages, use the forum please ]

kristof

Thank you for your replys.

I use 3 wire setup. Max length is 3 meter. I use a normal wire ( coating with inside 3 wire + shield wire around. but the "shield" wire is not connected to ground). Max temp. are 90°C.
I updated the "onwire" lib, but the same problems. I now replaced the arduino with another. For the moment no problems. Maybe the arduino was "broken". It was not new, I used it before on other projects, but it did works for a few months. I will try the new arduino, if I get the problem again, I will connect one side of the shield wire to ground.
Thanks for the reply, I will keep you updated.

MarkT

First try connecting the shield to Arduino ground at the Arduino end and not connecting it to anything else.  This means that no currents can be induced along the shield due to ground loops.  Can also try grounding it at each sensor so that the sensor chain cannot act as an antenna.
[ I won't respond to messages, use the forum please ]

kristof

Hello,
I connected the shield to the ground like MarkT suggested. I also changed the 4k7 to a 2k2 resistor. But no positive result. The same problem, sometimes everything works good, and sometimes the reading of the 8 sensors give -127. If I then remove 1 sensor than the reading of the other 7 sensors are ok again, and I get a -127 value for the removed sensor. Could the sensor be broken? I will try changing the sensor and hope it will fix the problem.

MarkT

Sounds worth substituting that sensor - is it fully reliable with it taken out?
[ I won't respond to messages, use the forum please ]

kristof

yes, it works when taking out.

goetzc

I have a similar issue, did you find a solution or the cause of the problem?

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