Skip to content

Commit ee5c674

Browse files
committed
more accurate voltage sensing formula
1 parent 8c2c1c6 commit ee5c674

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pio_workspace/lib/power_custom/adc_sensors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void ADCSensors::refreshCurrent() {
8383
}
8484

8585
float ADCSensors::convertVoltage(float adcVoltage) {
86-
return (adcVoltage - 0.08) * (16.8 - 12.8) / (1.27 - 0.08) + 12.8;
86+
return (adcVoltage * 2) * (16.8 - 12.8) / (2.586 - 0.180) + 12.5;
8787
}
8888

8989
float ADCSensors::convertCurrent(float adcCurrent) {

pio_workspace/lib/power_custom/adc_sensors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include "Wire.h"
66
#include "Adafruit_ADS1X15.h"
77

8-
#define ADC_VOLTAGE_ADDR 0x4B
98
#define ADC_CURRENT1_ADDR 0x48
109
#define ADC_CURRENT2_ADDR 0x49
10+
#define ADC_VOLTAGE_ADDR 0x4B
1111

1212
class ADCSensors {
1313
public:
@@ -21,9 +21,9 @@ class ADCSensors {
2121
bool voltageEnabled;
2222
bool currentEnabled;
2323

24-
Adafruit_ADS1115 adcVoltage;
2524
Adafruit_ADS1115 adcCurrent1;
2625
Adafruit_ADS1115 adcCurrent2;
26+
Adafruit_ADS1115 adcVoltage;
2727

2828
int16_t rawADCVoltage[2];
2929
float computedADCVoltage[2];

0 commit comments

Comments
 (0)