Skip to content

Commit

Permalink
Introduces limit to power reports
Browse files Browse the repository at this point in the history
In case the reported power is for the defined settings so hight, that the duration of the pulse is longer than the frequency of the pulses.
  • Loading branch information
mmmichl committed Jun 1, 2024
1 parent 8e0607c commit 2e2fe38
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,15 @@ Depending on your HP model, SG3 might be configurable in "ECO mode", "Normal mod
Note: Smart Grid needs to be switched ON in the heatpump configuration menu, otherwise SG1 and SG2 contacts are not evaluated.

## Step 5 (optional) - Pulse Meter feature
ESPaltherma can communicate how much energy the HP should consume via a pulse meter. For this, uncomment and confugre `PIN_PULSE`, `PULSES_PER_kWh` and `PULSE_DURATION_MS` in `src/setup.c`. Send energy amount in Watt to MQTT channel `espaltherma/pulse/set`. Current Watt setting is available in `espaltherma/pulse/state`.
ESPaltherma can communicate how much energy the HP should consume via a pulse meter. For this, uncomment and confugre `PIN_PULSE`, `PULSES_PER_kWh` and `PULSE_DURATION_MS` in `src/setup.h`. Send energy amount in Watt to MQTT channel `espaltherma/pulse/set`. Current Watt setting is available in `espaltherma/pulse/state`.

*TODO more close description what it is to do*

Note the limits to reporded Watt. Both limits depend on
* `PULSES_PER_kWh` (default is 1000)
* `PULSE_DURATION_MS` (default is 75)
For these defaults, the minimum reported power is 60 and the maximum is 21 kWh. If you need to represent more power, try reducing `PULSE_DURATION_MS`. If this is not sufficient, adapt `PULSES_PER_kWh` but keep it in sync with the HP setting.

# Troubleshooting

## Specific issues with M5
Expand Down
16 changes: 11 additions & 5 deletions include/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,24 @@ void callbackPulse(byte *payload, unsigned int length)
String ss((char*)payload);
long target_watt = ss.toInt();

// TODO check for maximum supported watt setting (smaller duration between pulse than pulse lenght)

// also converts from kWh to Wh
float WH_PER_PULSE = 1.0 / PULSES_PER_kWh * 1000;
float WH_PER_PULSE = (1.0 / PULSES_PER_kWh) * 1000;

ms_until_pulse = (3600.0 / target_watt * WH_PER_PULSE * 1000) - PULSE_DURATION_MS;
ms_until_pulse = ((3600.0 / target_watt) * WH_PER_PULSE * 1000) - PULSE_DURATION_MS;
if ((ms_until_pulse + PULSE_DURATION_MS) > 60 * 1000) {
// cap the maximum pulse length to 1 minute
// a change of the pulse is only applied, after the current pulse is finished. Thus if the pulse rate is very low,
// it will take a long time to adjust the rate
ms_until_pulse = 60 * 1000;
Serial.printf("Capping pulse to %d Watt to ensure pulse rate is <= 60 sec\n", (int) WH_PER_PULSE * 60);
target_watt = (long) WH_PER_PULSE * 60;
Serial.printf("Capping pulse to %d Watt to ensure pulse rate is <= 60 sec\n", target_watt);
}
if (ms_until_pulse < 20) {
// ensure a 20 ms gap between two pulses
ms_until_pulse = 20;
long original_target = target_watt;
target_watt = (long) ((1000 * WH_PER_PULSE * 3600) / (ms_until_pulse + PULSE_DURATION_MS));
Serial.printf("WARNING pulse frequency to high, capping at %d Watt! Target is %d Watt. Decrease PULSE_DURATION or PULSES_PER_kWh\n", target_watt, original_target);
}
if (timerPulseStart == NULL) {
setupPulseTimer();
Expand Down

0 comments on commit 2e2fe38

Please sign in to comment.