#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Alamat I2C dan ukuran LCD
const int analogPin = 34; // Pin analog untuk sensor NTC
const float VCC = 3.3; // Tegangan referensi
const float beta = 3950.; // Koefisien Beta sensor NTC
const float maxBit = 4095.;
void setup() {
Serial.begin(9600);
lcd.init(); // Inisialisasi LCD
lcd.backlight(); // Aktifkan pencahayaan LCD
lcd.setCursor(0, 0);
lcd.print("Suhu: ");
analogReadResolution(12); // Resolusi bacaan ADC
pinMode(analogPin, INPUT);
}
void loop() {
int sensorValue = analogRead(analogPin);
Serial.print("sensor value:");
Serial.println(sensorValue);
float voltage = (sensorValue / maxBit) * VCC; // Konversi nilai ADC ke tegangan
Serial.print(voltage);
Serial.println(" V\t");
float tempC = 1 / (log(1 / (maxBit / sensorValue - 1)) / beta + 1. / 298.15) - 273.15;
lcd.setCursor(7, 0);
lcd.print(tempC, 1); // Menampilkan suhu dengan satu desimal
lcd.print("C");
delay(1000); // Delay satu detik
}