const float referenceVoltage = 3.3; // Set the reference voltage to the actual value in your simulation
const int batteryPin = 0; // Analog pin connected to the battery voltage divider
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
}
void loop()
{
// put your main code here, to run repeatedly:
// Read the battery voltage
int sensorValue = analogRead(batteryPin);
// Convert the analog reading to voltage
float voltage = sensorValue * ((referenceVoltage) / 4095.0);
// Print the battery voltage to the Serial Monitor
Serial.print("Sensor Value: ");
Serial.print(voltage); // Print with 2 decimal places
Serial.println(" V");
delay(1000); // this speeds up the simulation
}