Well, nobody has seen the code, but the fact that you get some sort of reading, and it is fine with one sensor, rather implies it is kosher. I guess there is the faintest possibility that your code is improperly addressing multiple sensors but I have never heard of such a thing giving a result like yours. Similarly, your description of the events clearly implies that your hardware items are equally kosher.
This pretty well means that the wiring is the only area left that merits your attention. Wiring your probes in the manner recommended is a recognised method that, by separating the probes, may even offer a better means of identifying the problem.
Suboptimal is a relative term. The best description of suboptimal wiring I can think of, is wiring that doesn't work.
There may also be a problem of cable length, compounded when you add more DS18B20, or bad home connection.
Here is a version of the Hacktronics 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
// modernised, compacted, and metricated by Nick Pyner
// code uses Arduino LCD stuff, for shield on Freetronics EtherTen.
// Serial print commands are for PLX-DAQ
// Research your own pins!
// temps
#include <OneWire.h>
#include <DallasTemperature.h>
//16x2 LCD
#include <LiquidCrystal.h>
//SD
#include <SD.h>
#include "Wire.h"
File myFile;
char filename[] = "00000000.CSV";
// clock
#include <string.h>
#include "RTClib.h"
#include "Wire.h"
#define DS1307_ADDRESS 0x68
RTC_DS1307 RTC;
LiquidCrystal lcd(8,9,56,5,6,7); // patchwire is D4 to A2 (pin56) for Mega with this proto
int flag;
int second, minute, hour;
// 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)
{
// start serial port
Serial.begin(9600);
delay(300);//Wait for newly restarted system to stabilize
Serial.print("Temperature measurement, two sensors:\n\n");
Serial.print("Initializing SD card...");
pinMode(10, OUTPUT);
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization OK.");
FileName; // first file named as today's date
// if the file opened okay, write to it: This is an IF-THEN-ELSE on validity of myFile
if (myFile) {
Serial.print("Writing to file...");
myFile.println(" date time temp. IN OUT Diff");
myFile.close();//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>CLOSE
Serial.println("done.");
Serial.println(" date time temp. IN OUT DIFF");
} else {
Serial.println("error opening test.txt");
}
// set up the LCD,s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("temp in out");
// Start up the library
sensors.begin();
sensors.setResolution(InThermo, 12);
sensors.setResolution(OutThermo, 12);
}
void loop(void)
{
delay(1000);
printDate();
if (hour == 0 && minute == 0 && second == 0)
{
FileName();
}
flag = 0;
myFile = SD.open("test.txt", FILE_WRITE); //+++++++++++++OPEN
//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(" , ");
myFile.close();//++++++++++++++++++++++++ CLOSE
}
void GetandPrint(DeviceAddress deviceAddress)
{
tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
}
else {
Serial.print(tempC);
Serial.print(" , ");
myFile.print(tempC);
myFile.print(" , ");
}
lcd.setCursor (1,1);
if (flag==1)
{
lcd.setCursor (11,1);
myFile.println();
};
lcd.print (tempC);
}
void printDate(){
// Reset the register pointer
Wire.beginTransmission(DS1307_ADDRESS);
byte zero = 0x00;
Wire.write(zero);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 7);
int second = bcdToDec(Wire.read());
int minute = bcdToDec(Wire.read());
int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
int monthDay = bcdToDec(Wire.read());
int month = bcdToDec(Wire.read());
int year = bcdToDec(Wire.read());
//print the date EG 3/1/11 23:59:59
Serial.print(monthDay);
Serial.print("/");
Serial.print(month);
Serial.print("/");
Serial.print(year);
Serial.print(" ");
Serial.print(hour);
Serial.print(":");
Serial.print(minute);
Serial.print(":");
if (second < 10)
{
Serial.print("0");
};
Serial.print(second);
Serial.print(" ");
}
byte bcdToDec(byte val) {
// Convert binary coded decimal to normal decimal numbers
return ( (val/16*10) + (val%16) );
}
void FileName(){
DateTime now = RTC.now();
filename[0] = (now.year()/1000)%10 + '0'; //To get 1st digit from year()
filename[1] = (now.year()/100)%10 + '0'; //To get 2nd digit from year()
filename[2] = (now.year()/10)%10 + '0'; //To get 3rd digit from year()
filename[3] = now.year()%10 + '0'; //To get 4th digit from year()
filename[4] = now.month()/10 + '0'; //To get 1st digit from month()
filename[5] = now.month()%10 + '0'; //To get 2nd digit from month()
filename[6] = now.day()/10 + '0'; //To get 1st digit from day()
filename[7] = now.day()%10 + '0'; //To get 2nd digit from day()
//filename[8] = ".csv";
myFile = SD.open(filename, FILE_WRITE);
myFile.close();
}