void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Hello, ESP32!");
}
float floatMap(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void loop() {
// put your main code here, to run repeatedly:
int analogValue = analogRead(34);
// Assuming your analog sensor output range is 0-4095 and you want to map it to a voltage range of 0-3.3V
float voltage = floatMap(analogValue, 0, 4095, 0, 3.3);
Serial.print("Analog: ");
Serial.print(analogValue);
Serial.print(", Voltage: ");
Serial.println(voltage);
delay(1000);
}