#include <LiquidCrystal_I2C.h> // address, width, height
LiquidCrystal_I2C lcd(0x27, 20, 4);
#define ADC_VREF_mV 5000.0 // in millivolt
#define ADC_RESOLUTION 1024.0
#define PIN_LM35 A0
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
}
void loop() {
// get the ADC value from the temperature sensor
int adcVal = analogRead(PIN_LM35);
// convert the ADC value to voltage in millivolt
float milliVolt = adcVal * (ADC_VREF_mV / ADC_RESOLUTION);
// convert the voltage to the temperature in Celsius
float tempC = milliVolt / 10;
// convert the Celsius to Fahrenheit
float tempF = tempC * 9 / 5 + 32;
// print the temperature in the Serial Monitor:
Serial.print("Temperature: ");
Serial.print(tempC); // print the temperature in Celsius
Serial.print("°C");
Serial.print(" ~ "); // separator between Celsius and Fahrenheit
Serial.print(tempF); // print the temperature in Fahrenheit
Serial.println("°F");
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(tempC); // print the temperature in Celsius
lcd.print("°C");
lcd.setCursor(6,1);
lcd.print(tempF); // print the temperature in Fahrenheit
lcd.println("°F");
lcd.setCursor(0,2);
lcd.print("Syamsy/18/EK2D");
delay(1000);
}