#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#define ONE_WIRE_BUS 4 // Data wire
float tempC, tempF; // Temperature values in Celcius & Farenheit
// Setup a oneWire instance to
// communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to
// Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
// LCD address 0x27 for a 16x2 display
LiquidCrystal_I2C lcd(0x27,16,4);
void setup(void) {
lcd.init(); // Initialize the lcd
lcd.backlight(); // Turn On LCD backlight
sensors.begin(); // Start up the library
}
void loop(void){
// Call sensors.requestTemperatures() to issue a global temperature
// and Requests to all devices on the bus
sensors.requestTemperatures();
// Why "byIndex"? You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
tempC = sensors.getTempCByIndex(0);
lcd.setCursor(0,0); // Print on line 1 column 0
lcd.print(tempC);
lcd.print(" degC ");
tempF = sensors.getTempFByIndex(0);
lcd.setCursor(0,1); // Print on line 2 column 0
lcd.print(tempF);
lcd.print(" degF ");
delay(1000);
}