#include <LiquidCrystal.h>
//[ RS, EN, D4, D5, D6, D7 ]
LiquidCrystal lcd(13, 12, 14, 27, 26, 25);
int pinoNTC = 2;
const float BETA = 3950; // Deve corresponder ao coeficiente beta do termistor
float temp = 0;
String lcdMsg = "Temp (°C):";
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(lcdMsg);
}
void loop() {
int valorAnalog = analogRead(pinoNTC);
Serial.println(valorAnalog);
float novaTemp = 1 / (log(1 / (4095. / valorAnalog - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.println(novaTemp);
if (temp != novaTemp) {
Serial.println(novaTemp);
temp = novaTemp;
lcd.setCursor(lcdMsg.length(), 0);
lcd.print(temp);
}
delay(1000);
}