#include <LiquidCrystal.h>
// Define LCD pins
const int rs = 13, en = 33, d4 = 21, d5 = 03, d6 = 41, d7 = 40;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Define KY-013 pin
const int tempPin = 34;
void setup() {
lcd.begin(16, 2); // Initialize the 16x2 LCD
pinMode(tempPin, INPUT);
}
void loop() {
// Read analog value from KY-013 sensor
int rawValue = analogRead(tempPin);
// Convert raw value to temperature in Celsius
float voltage = (rawValue / 4095.0) * 3.3; // ESP32 ADC range 0-4095, 3.3V
float temperatureC = (voltage - 0.5) * 100.0; // Example calculation, adjust if needed
// Display temperature on the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperatureC);
lcd.print(" C");
delay(1000); // Update every second
}