I submit the code you are using is obsolete junk, and the sooner it is wiped out of cyberspace the better. It also goes some way to explain your original question. The only useful line in that code is
// The DallasTemperature library can do all this work for you!
and it is just a comment, not a command.
You might find this a lot more usable - and understandable. At least it doesn't waste your time messing about with sensors you will never see.
Arduino 1-Wire Tutorial.
Note that there are two programmes to use, one to sniff the address and the other to use the sensor.
BTW code like
OneWire ds(9); // on pin 10
does not signal clear intent!
Below is an example. The notable thing about it is that it is about 50 lines long
/* Basic 2xDS18B20 code for serial monitor, bluetooth, Excel or w.h.y.
Derived from Hacktronics. USE THEIR ADDRESS SNIFFER, test one sensor at
a time, and substitute your numbers.
Use Hacktronics connections diagram.
http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
Stay away from using parasite power
-127C means bad connection
85 means you haven't gotten a read yet, probably just the
wrong order of commands
*/
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wires are 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);
byte Thermo1[8] = {0x28, 0x39, 0xFD, 0x50, 0x04, 0x00, 0x00, 0X69};
byte Thermo2[8] = {0x28, 0x09, 0xA9, 0xC0, 0x03, 0x00, 0x00, 0x95};
float tempC,Temp1,Temp2;
void setup(){
Serial.begin(9600);
sensors.begin();
delay(500);//Wait for newly restarted system to stabilize
/* // No resolution command means default to 12 bit
sensors.setResolution(Thermo1, 10);
sensors.setResolution(Thermo2, 10);
*/
}
void loop() {
sensors.requestTemperatures(); // call readings from the addresses
Temp1 = sensorValue(Thermo1);
Temp2 = sensorValue(Thermo2);
Serial.print(" Temp1 = ");
Serial.print(Temp1);
Serial.print(" Temp2 = ");
Serial.println(Temp2);
delay(1000);
}
//sensorValue function
float sensorValue (byte deviceAddress[])
{
tempC = sensors.getTempC (deviceAddress);
return tempC;
}