Skip to content

Commit

Permalink
meters_rs485_bricklet: Add SDM630MCT-V2 support
Browse files Browse the repository at this point in the history
The register set is identical to the existing SDM630.
The only observable difference is the meter ID.
  • Loading branch information
MattiasTF committed Dec 10, 2024
1 parent 7d02fc2 commit af5cd8a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ static uint16_t registers[400];
static const MeterInfo * const supported_meters[] = {
&sdm72dm,
&sdm630,
&sdm72dmv2
&sdm72dmv2,
// sdm72ctm is missing. Sequence doesn't match meter type defines.
&sdm630mctv2,
};

[[gnu::const]]
Expand Down
44 changes: 30 additions & 14 deletions software/src/modules/meters_rs485_bricklet/sdm630_defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ static void sdm630_slow_read_done(const uint16_t *all_regs, uint32_t meter_slot,
meters.update_all_values(meter_slot, all_values);
}

static void sdm630_reset(uint32_t meter_slot, ConfigRoot *reset)
{
float total = 0;
float import = 0;
float export_ = 0;

meters.get_energy_imexsum(meter_slot, &total);
meters.get_energy_import(meter_slot, &import);
meters.get_energy_export(meter_slot, &export_);

reset->get("energy_total")->updateFloat(total);
reset->get("energy_import")->updateFloat(import);
reset->get("energy_export")->updateFloat(export_);

api.writeConfig(meters.get_path(meter_slot, Meters::PathType::Base) + "sdm630_reset", reset);
}

const MeterInfo sdm630 {
0x0070,
METER_TYPE_SDM630,
Expand All @@ -93,19 +110,18 @@ const MeterInfo sdm630 {
sdm630_slow_read_done,
sdm630_fast_read_done,
"SDM630",
[](uint32_t meter_slot, ConfigRoot *reset){
float total = 0;
float import = 0;
float export_ = 0;

meters.get_energy_imexsum(meter_slot, &total);
meters.get_energy_import(meter_slot, &import);
meters.get_energy_export(meter_slot, &export_);

reset->get("energy_total")->updateFloat(total);
reset->get("energy_import")->updateFloat(import);
reset->get("energy_export")->updateFloat(export_);
sdm630_reset
};

api.writeConfig(meters.get_path(meter_slot, Meters::PathType::Base) + "sdm630_reset", reset);
}
const MeterInfo sdm630mctv2 {
0x0079,
METER_TYPE_SDM630MCTV2,
sdm630_slow,
ARRAY_SIZE(sdm630_slow),
sdm630_fast,
ARRAY_SIZE(sdm630_fast),
sdm630_slow_read_done,
sdm630_fast_read_done,
"SDM630MCT-V2",
sdm630_reset
};
1 change: 1 addition & 0 deletions software/src/modules/meters_rs485_bricklet/sdm630_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
#include "meter_defs.h"

extern const MeterInfo sdm630;
extern const MeterInfo sdm630mctv2;

0 comments on commit af5cd8a

Please sign in to comment.