#include <LiquidCrystal.h>
float Vin=5.0; // [V]
float Rt=10000; // Resistor t [ohm]
float R0=10000; // value of rct in T0 [ohm]
float T0=298.15; // use T0 in Kelvin [K]
float Vout=0.0; // Vout in A0
float Rout=0.0; // Rout in A0
// use the datasheet to get this data.
float T1=273.15; // [K] in datasheet 0º C
float T2=373.15; // [K] in datasheet 100° C
float RT1=35563; // [ohms] resistence in T1
float RT2=549; // [ohms] resistence in T2
float beta=0.0; // initial parameters [K]
float Rinf=0.0; // initial parameters [ohm]
float TempK=0.0; // variable output
float TempC=0.0; // variable output
LiquidCrystal lcd(12,11,5,4,3,2);
void setup() {
lcd.begin(16,2);
pinMode(0, INPUT);
//parâmetros
beta=(log(RT1/RT2))/((1/T1)-(1/T2));
Rinf=R0*exp(-beta/T0);
}
void loop()
{
Vout=Vin*((float)(analogRead(0))/1024.0); // calc for ntc
Rout=(Rt*Vout/(Vin-Vout));
TempK=(beta/log(Rout/Rinf)); // calc for temperature
TempC=TempK-273.15;
lcd.setCursor(0,0);
lcd.print("Temperature: ");
lcd.setCursor(0,1);
lcd.print(TempC);
lcd.write(0xdf); // to display °
lcd.print("C ");
//lcd.print((TempC * 9)/5 + 32); // C to F
//lcd.write(0xdf);
//lcd.print("F");
delay(500);
}