#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
// Data wire is plugged into digital pin 6 on the Arduino
#define ONE_WIRE_BUS 6
// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);
// I2C address 0x27, 16 column and 2 rows
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup(void)
{
sensors.begin(); // Start up the library
Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.backlight();
}
void loop(void)
{
lcd.clear(); // clear display
// Send the command to get temperatures
sensors.requestTemperatures();
float temperature = sensors.getTempCByIndex(0);
lcd.setCursor(0, 0); // move cursor to (0, 0)
lcd.print("Temp.: ");
lcd.print(temperature);
lcd.print((char)176); //shows degrees character
lcd.print("C");
//print the temperature in Celsius
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print((char)176);//shows degrees character
Serial.print("C | ");
if(temperature < 18.00 || temperature > 25.00){
lcd.setCursor(1,1);
lcd.print("t out of range ");
Serial.println("t out of range");
}
delay(1000);
}