// Define the pin connected to the NTC thermistor
const int thermistorPin = A0;
#include <LiquidCrystal.h>
// Define the series resistor value in ohms
const float seriesResistor = 10000.0; // 10k ohms
// Constants for the Steinhart-Hart equation
const float A = 0.001129148;
const float B = 0.000234125;
const float C = 0.0000000876741;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop() {
// Read the analog value from the thermistor
int rawADC = analogRead(thermistorPin);
// Convert the analog value to resistance
float resistance = seriesResistor / ((1023.0 / rawADC) - 1);
// Calculate temperature using the Steinhart-Hart equation
float temperatureK = 1 / (A + B * log(resistance) + C * pow(log(resistance), 3));
float temperatureC = temperatureK - 273.15; // Convert Kelvin to Celsius
lcd.clear(); // Clear the LCD screen
lcd.setCursor(1, 0); // Set cursor to the first column of the first row
lcd.print("Temp: ");
lcd.setCursor(7, 0);
lcd.print(temperatureC);
lcd.setCursor(13, 0);
lcd.print("C");
// Print temperature to serial monitor
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
}