a7670 voltage calibration fix
This commit is contained in:
parent
008b6250ea
commit
16ce6bc6d2
|
|
@ -135,6 +135,7 @@ namespace BATTERY_Utils {
|
||||||
double inputDivider = (1.0 / (390.0 + 100.0)) * 100.0; // The voltage divider is a 390k + 100k resistor in series, 100k on the low side.
|
double inputDivider = (1.0 / (390.0 + 100.0)) * 100.0; // The voltage divider is a 390k + 100k resistor in series, 100k on the low side.
|
||||||
return (((sampleSum/100) * adcReadingTransformation) / inputDivider) + 0.285; // Yes, this offset is excessive, but the ADC on the ESP32s3 is quite inaccurate and noisy. Adjust to own measurements.
|
return (((sampleSum/100) * adcReadingTransformation) / inputDivider) + 0.285; // Yes, this offset is excessive, but the ADC on the ESP32s3 is quite inaccurate and noisy. Adjust to own measurements.
|
||||||
#else
|
#else
|
||||||
|
#ifdef HAS_ADC_CALIBRATION
|
||||||
if (calibrationEnable){
|
if (calibrationEnable){
|
||||||
float voltage = esp_adc_cal_raw_to_voltage(sampleSum / 100, &adc_chars);
|
float voltage = esp_adc_cal_raw_to_voltage(sampleSum / 100, &adc_chars);
|
||||||
voltage *= 2; // for 100K/100K voltage divider
|
voltage *= 2; // for 100K/100K voltage divider
|
||||||
|
|
@ -143,6 +144,9 @@ namespace BATTERY_Utils {
|
||||||
} else {
|
} else {
|
||||||
return (2 * (sampleSum/100) * adcReadingTransformation) + voltageDividerCorrection; // raw voltage without mapping
|
return (2 * (sampleSum/100) * adcReadingTransformation) + voltageDividerCorrection; // raw voltage without mapping
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
return (2 * (sampleSum/100) * adcReadingTransformation) + voltageDividerCorrection; // raw voltage without mapping
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
// return mapVoltage(voltage, 3.34, 4.71, 3.0, 4.2); // mapped voltage
|
// return mapVoltage(voltage, 3.34, 4.71, 3.0, 4.2); // mapped voltage
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue