#include <LiquidCrystal_I2C.h>
#define BETA 3950
LiquidCrystal_I2C lcd(0x27, 16, 2);
float toCelsius(unsigned int analogValue)
{
return 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
}
float toFahrenheit(unsigned int analogValue)
{
return toCelsius(analogValue) * 9/5 + 32;
}
void setup()
{
lcd.begin(16, 2);
lcd.backlight();
}
void loop()
{
float t = analogRead(A0);
lcd.setCursor(0, 0);
lcd.print(String(toCelsius(t)) + " C");
lcd.setCursor(0, 1);
lcd.print(String(toFahrenheit(t)) + " F");
delay(250);
}