// Potentiometer is connected to GPIO 34 (Analog ADC1_CH6)
const int sensorPin = 34; // GPIO 34 (input)
void setup() {
Serial.begin(115200); // Start serial communication at 115200 baud rate
Serial.println("Hello, ESP32!");
delay(1000);
}
void loop() {
// Reading potentiometer value
int sensorValue = analogRead(sensorPin); // Read the voltage from the divider (0-4095)
// Calculate the actual voltage using the voltage divider formula
float voltage = (sensorValue / 4095.0) * 3.3; // Voltage at analog pin
float actualVoltage = voltage * ((10.0 + 2.2) / 2.2); // Scale back to 12V
// Print the actual voltage to the Serial Monitor
Serial.print("Actual Voltage: ");
Serial.print(actualVoltage);
Serial.println(" V");
delay(500); // Wait for 500 milliseconds before the next reading
}