



#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
/********************************************************************/
// Data wire for temp in is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
/*
* The setup function. We only start the sensors here
*/
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
lcd.begin();
lcd.clear();
Serial.begin(9600);
// Start up the library
// Turn on the blacklight and print a message.
lcd.backlight();
lcd.print("Hello,...!");
delay(2000);
lcd.clear();
}
void loop()
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
/********************************************************************/
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperature readings
Serial.println("DONE");
lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0
lcd.print("TmpIn :"); // Prints Sensor Val: to LCD
lcd.print(sensors.getTempCByIndex(0));
lcd.print((char)223); // Prints value on sensorVal1 to LCD
lcd.setCursor(0,1); // Sets the cursor to col 1 and row 0
lcd.print("TmpOut:"); // Prints Sensor Val: to LCD
lcd.print(sensors.getTempCByIndex(1)); // Prints value on sensorVal2 to LCD
lcd.print((char)223);
/********************************************************************/
Serial.print("Temperature out: ");
Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?
// You can have more than one DS18B20 on the same bus.
// 0 refers to the first IC on the wire
// delay(1000);
Serial.print("Temperature in: ");
Serial.print(sensors.getTempCByIndex(1)); // Why "byIndex"?
// You can have more than one DS18B20 on the same bus.
// 1 refers to the second IC on the wire
delay(1000);
}