#include <LiquidCrystal_PCF8574.h>

#include <DallasTemperature.h>

 

LiquidCrystal_PCF8574 lcd(0x27);

 

// DS18B20 data wire

#define ONE_WIRE_BUS 0

 

// 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);

 

float tempC;

char grados = 223;

 

void setup() {

  // put your setup code here, to run once:

  sensors.begin();

 

  lcd.begin(20, 4);

  delay(200);

  lcd.setBacklight(255);

  lcd.print("Temperatura:");

}

 

void loop() {

  // put your main code here, to run repeatedly:

  sensors.requestTemperatures(); // Send the command to get temperatures

 

  tempC = sensors.getTempCByIndex(0);

  if (tempC != DEVICE_DISCONNECTED_C)

  {

    lcd.setCursor(13, 0);

    lcd.print(tempC, 1);

    lcd.print(grados);

    lcd.print("C ");

  }

  else

  {

    lcd.setCursor(13, 0);

    lcd.print("error!");

  }

}