DS18B20 Scrambled LCD HELP!

Hi everyone,

I'm new to arduino and coding in general, but I'm really enjoying it so far. I've been slowly working my up starting from the basic examples. I then moved onto using the ds18b20 temp sensor to display min max and current temp for two sensors on a 20x4 lcd.

I have everything working how I like, except after running for some time (not sure how long, few hours or more), I end up with a screen full of scrambled characters. See the photos.

How it looks when it's working:

When it scrambles:

The code:

/* YourDuino.com Example: Multiple DS18B20 Temperature Sensors
 Displayed on 4x20 character LCD display
 
 DS18B20 Pinout (Left to Right, pins down, flat side toward you)
 - Left   = Ground
 - Center = Signal (Pin 10):  (with 3.3K to 4.7K resistor to +5 or 3.3 )
 - Right  = +5 or +3.3 V
 
/*-----( Import needed libraries )-----*/
// Get 1-wire Library here: http://www.pjrc.com/teensy/td_libs_OneWire.html
//Get DallasTemperature Library here:  http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library
//Download: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move original LiquidCrystal library elsewhere, copy this in it's place

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

//-----( Declare Constants and Pin Numbers )-----

#define ONE_WIRE_BUS 3  // Data wire is plugged into port 3 on the Arduino (can be changed) 

//I2C LCD ONLY - UNCOMMENT
/*#define I2C_ADDR    0x27  // Define I2C Address for the PCF8574A 
 //---(Following are the PCF8574 pin assignments to LCD connections )----
 // This are different than earlier/different I2C LCD displays
 #define BACKLIGHT_PIN  3
 #define En_pin  2
 #define Rw_pin  1
 #define Rs_pin  0
 #define D4_pin  4
 #define D5_pin  5
 #define D6_pin  6
 #define D7_pin  7
 
 #define  LED_OFF  0
 #define  LED_ON  1*/
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

/*-----( Declare objects )-----*/

// Setup a oneWire instance to communicate with any OneWire devices 
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass address of our oneWire instance to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// DS18B20 Probes
DeviceAddress Probe1 = { 
  0x28, 0xC5, 0xEC, 0x34, 0x05, 0x00, 0x00, 0xE2 }; // ROOM
DeviceAddress Probe2 = { 
  0x28, 0x6B, 0x17, 0xCB, 0x04, 0x00, 0x00, 0x3B }; // TANK

LiquidCrystal lcd(8, 7, 5, 4, 16, 2);

float nowTemp1;
float nowTemp1w;
float nowTemp1d;

float minTemp1=255;
float minTemp1w;
float minTemp1d;

float maxTemp1=-255;
float maxTemp1w;
float maxTemp1d;



float nowTemp2;
float nowTemp2w;
float nowTemp2d;

float minTemp2=255;
float minTemp2w;
float minTemp2d;

float maxTemp2=-255;
float maxTemp2w;
float maxTemp2d;

void setup()   /****** SETUP: RUNS ONCE ******/
{
  //------- Initialize the Temperature measurement library--------------
  sensors.begin();
  // set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
  sensors.setResolution(Probe1, 12);
  sensors.setResolution(Probe2, 12);

  //---------------- Initialize the lcd ------------------  
  lcd.begin (20,4);  // 20 characters, 4 lines

  float temp1 = sensors.getTempC(Probe1);
  float maxTemp1 = temp1;
  float minTemp1 = temp1;

  float temp2 = sensors.getTempC(Probe2);
  float maxTemp2 = temp2;
  float minTemp2 = temp2;

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  sensors.requestTemperatures(); // Send the command to get temperatures

    Probe1Loop();
  Probe2Loop();
  displayTemperature1Loop();
  displayTemperature2Loop();
  rounding1Loop();
  rounding2Loop();

}


void displayTemperature1Loop()
{
  lcd.setCursor(2,0);
  lcd.print("ROOM");

  lcd.setCursor(0,1);
  lcd.print("Now ");
  {
    if (nowTemp1 == -127) lcd.print("Error");

    else{
      lcd.print(nowTemp1w,1);
      lcd.setCursor(7,1);
      lcd.print(nowTemp1d,0);
    }
  }

  lcd.setCursor(0,2);
  lcd.print("Max ");
  {
    if (maxTemp1 == -127) lcd.print("Error");

    else{
      lcd.print(maxTemp1w,1);
      lcd.setCursor(7,2);
      lcd.print(maxTemp1d,0);
    }
  }


  lcd.setCursor(0,3);
  lcd.print("Min ");
  {
    if (minTemp1 == -127) lcd.print("Error");

    else{
      lcd.print(minTemp1w,1);
      lcd.setCursor(7,3);
      lcd.print(minTemp1d,0);
    }
  }

}


void displayTemperature2Loop()
{
  lcd.setCursor(14,0);
  lcd.print("TANK");

  lcd.setCursor(12,1);
  lcd.print("Now ");
  {
    if (nowTemp2 == -127) lcd.print("Err");

    else{
      lcd.print(nowTemp2w,1);
      lcd.setCursor(19,1);
      lcd.print(nowTemp2d,0);
    }
  }

  lcd.setCursor(12,2);
  lcd.print("Max ");
  {
    if (maxTemp2 == -127) lcd.print("Err");

    else{
      lcd.print(maxTemp2w,1);
      lcd.setCursor(19,2);
      lcd.print(maxTemp2d,0);
    }
  }


  lcd.setCursor(12,3);
  lcd.print("Min ");
  {
    if (minTemp2 == -127) lcd.print("Err");

    else{
      lcd.print(minTemp2w,1);
      lcd.setCursor(19,3);
      lcd.print(minTemp2d,0);
    }
  }

}
//Temp Calculations Probe 1
void Probe1Loop()
{
  float temp1 = sensors.getTempC(Probe1);

  nowTemp1=temp1; 

  if (temp1 > maxTemp1) maxTemp1 = temp1;

  if (temp1 < minTemp1) minTemp1 = temp1;
}


//Temp Calculations Probe 2
void Probe2Loop()
{
  float temp2 = sensors.getTempC(Probe2);

  nowTemp2=temp2; 

  if (temp2 > maxTemp2) maxTemp2 = temp2;

  if (temp2 < minTemp2) minTemp2 = temp2;

}

void rounding1Loop()
{
  int temp1r = nowTemp1 * 10 + 0.5;
  nowTemp1w=temp1r/10; 
  nowTemp1d=temp1r%10;

  int maxTemp1r = maxTemp1 * 10 + 0.5;
  maxTemp1w = maxTemp1r/10;
  maxTemp1d = maxTemp1r%10;

  int minTemp1r = minTemp1 * 10 + 0.5;
  minTemp1w = minTemp1r/10;
  minTemp1d = minTemp1r%10;
}

void rounding2Loop()
{
  int temp2r = nowTemp2 * 10 + 0.5;
  nowTemp2w=temp2r/10; 
  nowTemp2d=temp2r%10;

  int maxTemp2r = maxTemp2 * 10 + 0.5;
  maxTemp2w = maxTemp2r/10;
  maxTemp2d = maxTemp2r%10;

  int minTemp2r = minTemp2 * 10 + 0.5;
  minTemp2w = minTemp2r/10;
  minTemp2d = minTemp2r%10;
}
//*********( THE END )**********

I have tried using both 2.2k and 4.7k pullup resistors, with no change. I have also tried both sensors individually, same results again. Not sure it it's a hardware fault or more likely, my noob coding.

Really stuck on this, any help would be much appreciated.

I couldn't see the scrambled display photo. Did you forget that?

Hmmm, images fixed I hope.

  {
    if (minTemp1 == -127) lcd.print("Error");

    else{
      lcd.print(minTemp1w,1);
      lcd.setCursor(7,3);
      lcd.print(minTemp1d,0);
    }
  }

You have a very strange syntax for if clauses. Usually the curly braces around the whole block is not necessary but it would be easier to read if you put the "lcd.print("Error");" into such a code block.

Remove the pin defines as they seem to be wrong.

Remove the

#include "Wire.h"

It's not used.

I also didn't find out why you define three float values for every output value.

float nowTemp2;
float nowTemp2w;
float nowTemp2d;

It's interesting that on both scrambled displays a text fragment of "Error" is visible. Try to fix the above issues and post the results your get.

I'm really surprised you get anything readable at all.

Your code seems to be a mish-mash of code for a i2C device and code for a non-I2c. I assume it is I2C as I believe most 4x20s are. You need a proper library LiquidCrystal_I2C2004V1. I recall a decent example is included.

If the LCD is not I2C, all allusion to I2C is just confusing junk, and you should get rid of it.

You appear to be using the same temp code as me, and I'm sure there is nothing wrong with it

pylon:

  {

if (minTemp1 == -127) lcd.print("Error");

else{
      lcd.print(minTemp1w,1);
      lcd.setCursor(7,3);
      lcd.print(minTemp1d,0);
    }
  }




You have a very strange syntax for if clauses. Usually the curly braces around the whole block is not necessary but it would be easier to read if you put the "lcd.print("Error");" into such a code block.

Will do, this was something I noticed on some code I've used off the net, wasn't sure if it was right or wrong.

Remove the pin defines as they seem to be wrong.

Not sure what you mean here sorry?

Remove the

#include "Wire.h"

It's not used.

Ok thanks, will do.

I also didn't find out why you define three float values for every output value.

float nowTemp2;

float nowTemp2w;
float nowTemp2d;

I did that when I was trying to work out how best to do the rounding and display it, now that you've pointed it out I think I know what I should've done. I will try this now.

It's interesting that on both scrambled displays a text fragment of "Error" is visible. Try to fix the above issues and post the results your get.

I noticed this too, and I have it print error when the probe returns -127, which leads me to believe there is something going on the 1 or both sensors.

Thanks very much for the help, will work some more on the code and try to work it out.

Nick_Pyner:
I'm really surprised you get anything readable at all.

Your code seems to be a mish-mash of code for a i2C device and code for a non-I2c. I assume it is I2C as I believe most 4x20s are. You need a proper library LiquidCrystal_I2C2004V1. I recall a decent example is included.

If the LCD is not I2C, all allusion to I2C is just confusing junk, and you should get rid of it.

You appear to be using the same temp code as me, and I'm sure there is nothing wrong with it

I am using a non - I2C 20x4 lcd. I think the code that I started with was originally written for an I2C lcd, which is what I was using to begin with. I then stopped using it as it was only 16x2, and I simply commented out the code relating to i2c. I will remove this completely as well as make the changes above and upload for you guys to see.

Thanks for your help.

How does this look?

//Multiple DS18B20 Temperature Sensors
// Displayed on 4x20 character LCD display

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

//-----( Declare Constants and Pin Numbers )-----

#define ONE_WIRE_BUS 3  // Data wire is plugged into port 3 on the Arduino (can be changed) 

/*-----( Declare objects )-----*/

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

// DS18B20 Probes
DeviceAddress Probe1 = { 
  0x28, 0xC5, 0xEC, 0x34, 0x05, 0x00, 0x00, 0xE2 }; // ROOM
DeviceAddress Probe2 = { 
  0x28, 0x6B, 0x17, 0xCB, 0x04, 0x00, 0x00, 0x3B }; // TANK

LiquidCrystal lcd(8, 7, 5, 4, 16, 2);

int nowTemp1;
int minTemp1=1269;
int maxTemp1=-1269;

int nowTemp2;
int minTemp2=1269;
int maxTemp2=-1269;

void setup()   /****** SETUP: RUNS ONCE ******/
{
  sensors.begin();
  sensors.setResolution(Probe1, 12);
  sensors.setResolution(Probe2, 12);

  lcd.begin (20,4);

  float temp1 = sensors.getTempC(Probe1);
  nowTemp1 = temp1 * 10 + 0.5;
  int maxTemp1 = nowTemp1;
  int minTemp1 = nowTemp1;

  float temp2 = sensors.getTempC(Probe2);
  nowTemp2 = temp2 * 10 + 0.5;
  int maxTemp2 = nowTemp2;
  int minTemp2 = nowTemp2;

}//--(end setup )---


void loop()
{
  sensors.requestTemperatures();

    tempCalc1();
  tempCalc2();
  displayTemperature1();
  displayTemperature2();


}


void displayTemperature1()
{
  lcd.setCursor(2,0);
  lcd.print("ROOM");

  lcd.setCursor(0,1);
  lcd.print("Now ");
  if (nowTemp1 == -1269){
    lcd.print("Err");
  }
  else{
    lcd.print(nowTemp1/10);
    lcd.setCursor(6,1);
    lcd.print(".");
    lcd.print(nowTemp1%10);
  }

  lcd.setCursor(0,2);
  lcd.print("Max ");
  if (maxTemp1 == -1269){
    lcd.print("Err");
  }
  else{
    lcd.print(maxTemp1/10);
    lcd.setCursor(6,2);
    lcd.print(".");
    lcd.print(maxTemp1%10);
  }

  lcd.setCursor(0,3);
  lcd.print("Min ");
  if (minTemp1 == -1269){
    lcd.print("Err");
  }
  else{
    lcd.print(minTemp1/10);
    lcd.setCursor(6,3);
    lcd.print(".");
    lcd.print(minTemp1%10);
  }
}


void displayTemperature2()
{
  lcd.setCursor(14,0);
  lcd.print("TANK");

  lcd.setCursor(12,1);
  lcd.print("Now ");
  if (nowTemp2 == -1269){
    lcd.print("Err");
  }
  else{
    lcd.print(nowTemp2/10);
    lcd.setCursor(18,1);
    lcd.print(".");
    lcd.print(nowTemp2%10);
  }

  lcd.setCursor(12,2);
  lcd.print("Max ");
  if (maxTemp2 == -1269){
    lcd.print("Err");
  }
  else{
    lcd.print(maxTemp2/10);
    lcd.setCursor(18,2);
    lcd.print(".");
    lcd.print(maxTemp2%10);
  }

  lcd.setCursor(12,3);
  lcd.print("Min ");
  if (minTemp2 == -1269){
    lcd.print("Err");
  }
  else{
    lcd.print(minTemp2/10);
    lcd.setCursor(18,3);
    lcd.print(".");
    lcd.print(minTemp2%10);
  }
}

//Temp Calculations Probe 1
void tempCalc1()
{
  float temp1 = sensors.getTempC(Probe1);

  nowTemp1=temp1 * 10 + 0.5;

  if (nowTemp1 > maxTemp1) maxTemp1 = nowTemp1;

  if (nowTemp1 < minTemp1) minTemp1 = nowTemp1;
}


//Temp Calculations Probe 2
void tempCalc2()
{
  float temp2 = sensors.getTempC(Probe2);

  nowTemp2=temp2 * 10 + 0.5; 

  if (nowTemp2 > maxTemp2) maxTemp2 = nowTemp2;

  if (nowTemp2 < minTemp2) minTemp2 = nowTemp2;
}


//*********( THE END )**********/

better but surely you don't need all that int stuff and can just deal with floats. I think your main problem is just formatting.

I'm off to watch Downton and may look at this tomorrow.

The rounding isn't necessary because the Print class does it already in printFloat, which is called by the print method for a float in the two argument version.

lcd.print(rawValue,1);

I thought you were using the same code as me, but apparently not.
I don't think your code should be much more complicated than this
You need to make sure all the characters are over- written when a new value is displayed.

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

 Use your own DS18B20 addresses, keys etc.
 
 */
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(8,9,A2,5,6,7); 

byte InThermo[8] =  {
  0x28, 0x69, 0xC2, 0xB0, 0x03, 0x00, 0x00, 0X9F};
byte OutThermo[8] = {
  0x28, 0x7A, 0x8B, 0xC0, 0x03, 0x00, 0x00, 0x2F};

#define ONE_WIRE_BUS 3   //pin 3

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

float InTemp, OutTemp, tempC;    
float diff;

void setup() {
  lcd.begin(16, 2);
  lcd.setCursor (0,0);
 
  delay(2000);
  sensors.begin();
  sensors.setResolution(InThermo, 12);
  sensors.setResolution(OutThermo, 12);

}

void loop() {

    //get the values from the DS8B20's 
    sensors.requestTemperatures();

InTemp = (sensorValue(InThermo));
OutTemp = (sensorValue(OutThermo));  
    diff = OutTemp - InTemp;

    lcd.setCursor (0,0);
    lcd.print(InTemp);
    lcd.setCursor (0,1);
    lcd.print (OutTemp);
    lcd.setCursor (8,1);
    lcd.print(diff);
    
    delay(1000);
    
}  // loop ends here


//sensorValue function
float sensorValue (byte deviceAddress[])
{
tempC = sensors.getTempC (deviceAddress);
  return tempC;
}

byte bcdToDec(byte val)  {
  // Convert binary coded decimal to normal decimal numbers
  return ( (val/16*10) + (val%16) );
}

pylon:
The rounding isn't necessary because the Print class does it already in printFloat, which is called by the print method for a float in the two argument version.

lcd.print(rawValue,1);

I'm not sure I follow here, could you explain further?

Nick_Pyner:
I thought you were using the same code as me, but apparently not.
I don't think your code should be much more complicated than this
You need to make sure all the characters are over- written when a new value is displayed.

/*

/*
//  Copyright (c) 2010 Mark McComb, hacktronics LLC
//  License: http://www.opensource.org/licenses/mit-license.php (Go crazy)
//  Tutorial:
//  Arduino 1-Wire Tutorial
//  code uses Arduino LCD stuff, for shield on Freetronics EtherTen.

Use your own DS18B20 addresses, keys etc.

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

LiquidCrystal lcd(8,9,A2,5,6,7);

byte InThermo[8] =  {
 0x28, 0x69, 0xC2, 0xB0, 0x03, 0x00, 0x00, 0X9F};
byte OutThermo[8] = {
 0x28, 0x7A, 0x8B, 0xC0, 0x03, 0x00, 0x00, 0x2F};

#define ONE_WIRE_BUS 3   //pin 3

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

float InTemp, OutTemp, tempC;    
float diff;

void setup() {
 lcd.begin(16, 2);
 lcd.setCursor (0,0);

delay(2000);
 sensors.begin();
 sensors.setResolution(InThermo, 12);
 sensors.setResolution(OutThermo, 12);

}

void loop() {

//get the values from the DS8B20's
   sensors.requestTemperatures();

InTemp = (sensorValue(InThermo));
OutTemp = (sensorValue(OutThermo));  
   diff = OutTemp - InTemp;

lcd.setCursor (0,0);
   lcd.print(InTemp);
   lcd.setCursor (0,1);
   lcd.print (OutTemp);
   lcd.setCursor (8,1);
   lcd.print(diff);
   
   delay(1000);
   
}  // loop ends here

//sensorValue function
float sensorValue (byte deviceAddress[])
{
tempC = sensors.getTempC (deviceAddress);
 return tempC;
}

byte bcdToDec(byte val)  {
 // Convert binary coded decimal to normal decimal numbers
 return ( (val/16*10) + (val%16) );
}

Ok, I will give this a go tonight.

I know my code is a mish mash and although the code below has been working since last night without error, I would like to better understand and improve it before moving on.

//Multiple DS18B20 Temperature Sensors
// Displayed on 4x20 character LCD display

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

//-----( Declare Constants and Pin Numbers )-----

#define ONE_WIRE_BUS 3 // Data wire is plugged into port 3 on the Arduino (can be changed)

/-----( Declare objects )-----/

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

// DS18B20 Probes
DeviceAddress Probe1 = {
0x28, 0xC5, 0xEC, 0x34, 0x05, 0x00, 0x00, 0xE2 }; // ROOM
DeviceAddress Probe2 = {
0x28, 0xF2, 0xDE, 0x35, 0x05, 0x00, 0x00, 0x02 }; // TANK

LiquidCrystal lcd(8, 7, 5, 4, 16, 2);

int nowTemp1;
int minTemp1=1269;
int maxTemp1=-1269;

int nowTemp2;
int minTemp2=1269;
int maxTemp2=-1269;

void setup() /****** SETUP: RUNS ONCE ******/
{
sensors.begin();
sensors.setResolution(Probe1, 12);
sensors.setResolution(Probe2, 12);

lcd.begin (20,4);

float temp1 = sensors.getTempC(Probe1);
nowTemp1 = temp1 * 10 + 0.5;
maxTemp1 = nowTemp1;
minTemp1 = nowTemp1;

float temp2 = sensors.getTempC(Probe2);
nowTemp2 = temp2 * 10 + 0.5;
maxTemp2 = nowTemp2;
minTemp2 = nowTemp2;

}//--(end setup )---

void loop()
{
sensors.requestTemperatures();

tempCalc1();
tempCalc2();
displayTemperature1();
displayTemperature2();
delay(1000); // <---- Do I need this? Too Long? Too Short?

}

void displayTemperature1()
{
lcd.setCursor(0,0);
lcd.print(" ROOM");

lcd.setCursor(0,1);
lcd.print("Now ");
if (nowTemp1 == -1269){
lcd.print("Err ");
}
else{
lcd.print(nowTemp1/10);
lcd.setCursor(6,1);
lcd.print(".");
lcd.print(nowTemp1%10);
}

lcd.setCursor(0,2);
lcd.print("Max ");
if (maxTemp1 == -1269){
lcd.print("Err ");
}
else{
lcd.print(maxTemp1/10);
lcd.setCursor(6,2);
lcd.print(".");
lcd.print(maxTemp1%10);
}

lcd.setCursor(0,3);
lcd.print("Min ");
if (minTemp1 == -1269){
lcd.print("Err ");
}
else{
lcd.print(minTemp1/10);
lcd.setCursor(6,3);
lcd.print(".");
lcd.print(minTemp1%10);
}
}

void displayTemperature2()
{
lcd.setCursor(6,0);
lcd.print(" ROOM2 ");

lcd.setCursor(8,1);
lcd.print(" Now ");
if (nowTemp2 == -1269){
lcd.print("Err ");
}
else{
lcd.print(nowTemp2/10);
lcd.setCursor(18,1);
lcd.print(".");
lcd.print(nowTemp2%10);
}

lcd.setCursor(8,2);
lcd.print(" Max ");
if (maxTemp2 == -1269){
lcd.print("Err ");
}
else{
lcd.print(maxTemp2/10);
lcd.setCursor(18,2);
lcd.print(".");
lcd.print(maxTemp2%10);
}

lcd.setCursor(8,3);
lcd.print(" Min ");
if (minTemp2 == -1269){
lcd.print("Err ");
}
else{
lcd.print(minTemp2/10);
lcd.setCursor(18,3);
lcd.print(".");
lcd.print(minTemp2%10);
}
}

//Temp Calculations Probe 1
void tempCalc1()
{
float temp1 = sensors.getTempC(Probe1);

nowTemp1=temp1 * 10 + 0.5;

if (nowTemp1 > maxTemp1) maxTemp1 = nowTemp1;

if (nowTemp1 < minTemp1) minTemp1 = nowTemp1;
}

//Temp Calculations Probe 2
void tempCalc2()
{
float temp2 = sensors.getTempC(Probe2);

nowTemp2=temp2 * 10 + 0.5;

if (nowTemp2 > maxTemp2) maxTemp2 = nowTemp2;

if (nowTemp2 < minTemp2) minTemp2 = nowTemp2;
}

//( THE END )*/

This is what I have been running since last night. It seems to be working fine so far, although I'd like to improve it as much as possible. Will update when I have something new.

OK

You have something that works, but I just think there is a swag of redundant stuff in there........

Exactly. I'd really like to slim it down, and try to learn how to do it properly.

The code I posted is derived from the Hacktronics tutorial. I believe it has all you need. Any maths you need is straighforward when you use floats.

OK thanks, I think I understand how your code works, the part I'm stuck on is getting the min and max floats and displaying everything without bloating the sketch like mine.

tanked_kiwi:

pylon:
The rounding isn't necessary because the Print class does it already in printFloat, which is called by the print method for a float in the two argument version.

lcd.print(rawValue,1);

I'm not sure I follow here, could you explain further?

Brilliant! This saves so much unnecessary code it's not funny. I really did take the long road...... I've got a lot to learn.

Thanks a heap!

Nick_Pyner:
I thought you were using the same code as me, but apparently not.
I don't think your code should be much more complicated than this
You need to make sure all the characters are over- written when a new value is displayed.

/*

/*
//  Copyright (c) 2010 Mark McComb, hacktronics LLC
//  License: http://www.opensource.org/licenses/mit-license.php (Go crazy)
//  Tutorial:
//  Arduino 1-Wire Tutorial
//  code uses Arduino LCD stuff, for shield on Freetronics EtherTen.

Use your own DS18B20 addresses, keys etc.

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

LiquidCrystal lcd(8,9,A2,5,6,7);

byte InThermo[8] =  {
 0x28, 0x69, 0xC2, 0xB0, 0x03, 0x00, 0x00, 0X9F};
byte OutThermo[8] = {
 0x28, 0x7A, 0x8B, 0xC0, 0x03, 0x00, 0x00, 0x2F};

#define ONE_WIRE_BUS 3   //pin 3

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

float InTemp, OutTemp, tempC;    
float diff;

void setup() {
 lcd.begin(16, 2);
 lcd.setCursor (0,0);

delay(2000);
 sensors.begin();
 sensors.setResolution(InThermo, 12);
 sensors.setResolution(OutThermo, 12);

}

void loop() {

//get the values from the DS8B20's
   sensors.requestTemperatures();

InTemp = (sensorValue(InThermo));
OutTemp = (sensorValue(OutThermo));  
   diff = OutTemp - InTemp;

lcd.setCursor (0,0);
   lcd.print(InTemp);
   lcd.setCursor (0,1);
   lcd.print (OutTemp);
   lcd.setCursor (8,1);
   lcd.print(diff);
   
   delay(1000);
   
}  // loop ends here

//sensorValue function
float sensorValue (byte deviceAddress[])
{
tempC = sensors.getTempC (deviceAddress);
 return tempC;
}

byte bcdToDec(byte val)  {
 // Convert binary coded decimal to normal decimal numbers
 return ( (val/16*10) + (val%16) );
}

Ok, I have been playing with this and I think I understand how it works.

You only have to add each device address and define their resolutions and outputs to read as many sensors as you like, by calling sensorValue. However, I can't work out how to store min and max values for individual sensors with a single function. Help?