Skip to content

Commit

Permalink
Feature: 3-phase SDM: read SDM_TOTAL_POWER
Browse files Browse the repository at this point in the history
Closes #765
  • Loading branch information
AndreasBoehm committed Feb 18, 2025
1 parent a992b10 commit ce1e855
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/powermeter/sdm/serial/Provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ void Provider::pollingLoop()
// reading takes a "very long" time as each readVal() is a synchronous
// exchange of serial messages. cache the values and write later to
// enforce consistent values.
float totalPower = 0.0;
float phase1Power = 0.0;
float phase2Power = 0.0;
float phase3Power = 0.0;
Expand All @@ -158,6 +159,11 @@ void Provider::pollingLoop()
float energyImport = 0.0;
float energyExport = 0.0;

auto dataInFlight = DataPointContainer();
if (_phases == Phases::Three && readValue(lock, SDM_TOTAL_SYSTEM_POWER, totalPower)) {
dataInFlight.add<DataPointLabel::PowerTotal>(totalPower);
}

bool success = readValue(lock, SDM_PHASE_1_POWER, phase1Power) &&
readValue(lock, SDM_PHASE_1_VOLTAGE, phase1Voltage) &&
readValue(lock, SDM_IMPORT_ACTIVE_ENERGY, energyImport) &&
Expand All @@ -172,7 +178,6 @@ void Provider::pollingLoop()

if (!success) { continue; }

auto dataInFlight = DataPointContainer();
dataInFlight.add<DataPointLabel::PowerL1>(phase1Power);
dataInFlight.add<DataPointLabel::VoltageL1>(phase1Voltage);
dataInFlight.add<DataPointLabel::Import>(energyImport);
Expand Down

0 comments on commit ce1e855

Please sign in to comment.