Skip to content

Commit

Permalink
fix datatype and autocal zero current
Browse files Browse the repository at this point in the history
  • Loading branch information
jhon-p16 committed Dec 5, 2023
1 parent ad83507 commit a727efa
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/BslibEnergyMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void BslibEnergyMeter::SetFilterSamples(unsigned int _numberOfSamples) {
int BslibEnergyMeter::FilterValueADC(unsigned int pinADC) {
unsigned long valueADC = 0;
int filteredValueADC = 0;
for (int i = 0; i < numberOfSamples; i++) {
for (unsigned int i = 0; i < numberOfSamples; i++) {
valueADC += analogRead(pinADC);
}
filteredValueADC = valueADC / numberOfSamples;
Expand All @@ -127,17 +127,17 @@ float BslibEnergyMeter::SoftwareDAC(int digitalValue) {
int BslibEnergyMeter::AutoCalibrationCurrent(int lastVRef) {

float vRef = FilterValueADC(inPinCurrentRef);
float vOut = FilterValueADC(inPinCurrent);
// float vOut = FilterValueADC(inPinCurrent);

if (lastVRef == vRef) {
calibrationCurrent = vRef;
} else {
calibrationCurrent = vRef;
}
// if (lastVRef == vRef) {
// calibrationCurrent = vRef;
// } else {
// calibrationCurrent = vOut;
// }
// algunos sensores tienen un offset (compensacion) cuando Vref<Vout
// float offset = vOut - vRef;
// calibrationCurrent += offset;
return calibrationCurrent;
return vRef;
}

void BslibEnergyMeter::CalCurrent() {
Expand Down

0 comments on commit a727efa

Please sign in to comment.