#define TX_PIN 21 #define RX_PIN 20 #define SENSOR_PIN 4 // Define the ADC pin (use a safe GPIO) #define REF_VOLTAGE 3.3 // ESP32-C3 operates on 3.3V #define ADC_RESOLUTION 4095 // 12-bit ADC resolution (0-4095) float voltageDividerFactor = 4.3; // Adjust based on the sensor calibration void setup() { Serial.begin(115200); Serial1.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN); } void loop() { int adcValue = analogRead(SENSOR_PIN); // Read ADC value float voltage = (adcValue * REF_VOLTAGE) / ADC_RESOLUTION; // Convert ADC to voltage float measuredVoltage = voltage * voltageDividerFactor; // Adjust based on sensor ratio Serial1.println(measuredVoltage); Serial.print("Sent:measuredVoltage="); Serial.print(measuredVoltage); Serial.println("V"); delay(1000); }