#include <Wire.h>
#include <LiquidCrystal.h>
#define NTC_PIN 26 // Connect the NTC sensor to analog pin A0
#define LCD_RS 7 // RS pin of the LCD
#define LCD_EN 8 // EN pin of the LCD
#define LCD_D4 9 // D4 pin of the LCD
#define LCD_D5 10 // D5 pin of the LCD
#define LCD_D6 11 // D6 pin of the LCD
#define LCD_D7 12 // D7 pin of the LCD
// Define LCD pin mapping
LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
int tempPin = 26; // Connect the potentiometer to analog pin A1
void setup() {
pinMode(tempPin, INPUT);
Serial.begin(115200);
lcd.begin(16, 2);
lcd.clear();
}
float readTemperature() {
// Read analog value from the NTC sensor
int sensorValue = analogRead(NTC_PIN);
// Convert analog value to temperature using a simple linear conversion
// Replace this formula with the one corresponding to your specific NTC sensor
float voltage = sensorValue * (5.0 / 1023.0);
float temperature = (voltage - 0.5) * 100.0;
return temperature;
}
void loop() {
// Read temperature from the NTC sensor
float temperature = readTemperature();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temperature:");
lcd.setCursor(0, 1);
lcd.print(" Temp: ");
lcd.print(temperature);
lcd.print(" C");
//Serial.print("Calculated temperature (NTC): ");
Serial.print('sensorValue');
Serial.println(temperature);
delay(1000);
}