Closed schlimmchen closed 1 month ago
@greymda, are you able to test the firmware build as part of this PR's build run?
@schlimmchen is this firmware upgradeable via OTA on a 4MB board? if not, i don't have access physically to the setup and can't write it using a cable :( the board is still using the "old" partition schema...
is this firmware upgradeable via OTA on a 4MB board?
No.
In the long run, I advise you to upgrade your hardware if you usually don't have physical access to it.
yep, I am planning to get the ESP32-WROVER-VIE as it has the same pin layout with the one i'm using now on Lukas's board. but it will take a while.
@schlimmchen what do you think about adding this change to use day/night from 'SunPosition' instead of relying on solarPower to detect day/night?
diff --git a/src/PowerLimiter.cpp b/src/PowerLimiter.cpp
index 58e8713a..c2ad86f9 100644
--- a/src/PowerLimiter.cpp
+++ b/src/PowerLimiter.cpp
@@ -17,6 +17,7 @@
#include <ctime>
#include <cmath>
#include <frozen/map.h>
+#include "SunPosition.h"
PowerLimiterClass PowerLimiter;
@@ -239,7 +240,10 @@ void PowerLimiterClass::loop()
auto getBatteryPower = [this,&config]() -> bool {
if (config.PowerLimiter.IsInverterSolarPowered) { return false; }
- if (_nighttimeDischarging && getSolarPower() > 0) {
+ auto isDayPeriod = (SunPosition.isSunsetAvailable() && SunPosition.isDayPeriod())
+ || getSolarPower() > 0;
+
+ if (_nighttimeDischarging && isDayPeriod) {
_nighttimeDischarging = false;
return isStartThresholdReached();
}
@@ -248,12 +252,10 @@ void PowerLimiterClass::loop()
if (isStartThresholdReached()) { return true; }
- // TODO(schlimmchen): should be supported by sunrise and sunset, such
- // that a thunderstorm or other events that drastically lower the solar
- // power do not cause the start of a discharge cycle during the day.
if (config.PowerLimiter.SolarPassThroughEnabled &&
config.PowerLimiter.BatteryAlwaysUseAtNight &&
- getSolarPower() == 0 && !_batteryDischargeEnabled) {
+ !isDayPeriod &&
+ !_batteryDischargeEnabled) {
_nighttimeDischarging = true;
return true;
}
yes, please. this is what I had in mind. I was too lazy to do it until now. can you create a PR against this one?
Awesome 🚀
I realised that I made a mistake which would still take solarPower into consideration when its night. A new PR fixes this issue: https://github.com/helgeerbe/OpenDTU-OnBattery/pull/1160
I finished my battery setup today and installed this PRs build. I will report back after 2 or 3 full days and nights if this now works as expected.
I can confirm that this works as expected
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.
the switch "always start discharging battery at night" would cause to stop discharging the battery when there was solar power and the battery was discharged below the start threshold.
this change introduces a nighttime discharging boolean variable, which is enabled the instant we decide to start a battery discharge cycle due to nighttime havin arrived. we reset this variable as soon as it is daytime (solar power available). in that case, we allow discharging the battery if the start threshold was reached. this can actually be the case if the battery is charged with cheap electricity during the night.
removed comments as they merely spell out what the if statement already expresses quite nicely.
closes #1123.