#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#define SENSOR_PIN 23
OneWire oneWire(SENSOR_PIN);
DallasTemperature DS18B20(&oneWire);
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27 (from DIYables LCD), 16 columns and 2 rows
float tempC; // temperature in Celsius
float tempF; // temperature in Fahrenheit
void setup() {
DS18B20.begin(); // initialize the sensor
lcd.init(); // initialize the LCD
lcd.backlight(); // turn on the backlight
}
void loop() {
DS18B20.requestTemperatures(); // send the command to get temperatures
tempC = DS18B20.getTempCByIndex(0); // read temperature in Celsius
lcd.clear();
lcd.setCursor(0, 0); // display position
lcd.print(tempC); // display the temperature in Celsius
lcd.print((char)223); // display ° character
lcd.print("C");
delay(500);
}