#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
// Data wire is plugged into port 7 on the Arduino
#define ONE_WIRE_BUS 7
// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// Start serial communication for debugging purposes
Serial.begin(9600);
// Start up the library
sensors.begin();
// Set up the LCD's number of columns and rows
lcd.begin(16, 2);
// Print a message to the LCD
lcd.print("Temp: ");
}
void loop() {
// Request temperature measurements
sensors.requestTemperatures();
// Fetch the temperature in Celsius
float tempC = sensors.getTempCByIndex(0);
// Print temperature to the Serial Monitor
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println(" C");
// Set the cursor to column 0, line 1
lcd.setCursor(0, 1);
// Print the temperature to the LCD
lcd.print(tempC);
lcd.print((char)223); // Degree symbol
lcd.print("C");
// Wait before repeating the loop
delay(1000);
}