Skip to content

Commit 2ebc0cc

Browse files
committed
Use table if no shunt is installed
1 parent defdadf commit 2ebc0cc

File tree

3 files changed

+51
-10
lines changed

3 files changed

+51
-10
lines changed

readme.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
- [Battery voltage](#battery-voltage)
1616
- [Shunt current](#shunt-current)
1717
- [Avg consumption](#avg-consumption)
18-
- [Time to go](#time-to-go)
18+
- [State of charge (Soc)](#state-of-charge-soc)
19+
- [Time to go (Ttg)](#time-to-go-ttg)
1920
- [Battery full](#battery-full)
2021
- [Temperature](#temperature)
2122
- [Configuration](#configuration)
@@ -117,7 +118,14 @@ Current in amperes flowing through the shunt. If the current is negative, the ba
117118
### Avg consumption
118119
The average current consumption in the last 60 seconds.
119120

120-
### Time to go
121+
### State of charge (Soc)
122+
Shows the charge level of the battery. This is calculated based on the capacity and the Ah consumed and is an estimate based on the current consumption.
123+
124+
If no shunt is used and the current calibration factor is set to 0, the following table is used to calculate the Soc
125+
126+
![alt text](img/Ladezustand_60be.jpg)
127+
128+
### Time to go (Ttg)
121129
If the time is 00:00, then the battery is charging. Otherwise, it will display an estimate in hours and minutes of how long, based on the current consumption, it will take until the battery is empty.
122130

123131
### Battery full
@@ -159,8 +167,13 @@ Assuming a voltage of 75 mV at nominal current, the resulting resistance in ohms
159167
maximum current that may flow through the shut
160168

161169
#### Voltage calibration factor
170+
Use a multimeter to measure the voltage on the battery. The measured voltage divided by the voltage displayed by the battery monitor gives the factor that you enter here.
162171

163172
#### Current calibration factor
173+
Use a multimeter to measure the current at the shunt. The measured current divided by the current displayed by the battery monitor gives the factor that you enter here.
174+
175+
If you do not want to use a shunt, enter 0 here. See also [State of charge (Soc)](#state-of-charge-soc)
176+
164177

165178
### Battery
166179
#### Type

src/StatusHandling.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,35 @@ void BatteryStatus::setParameters(uint16_t capacityAh, uint16_t chargeEfficiency
3737
}
3838

3939
void BatteryStatus::updateSOC() {
40-
stats.socVal = stats.remainAs / batteryCapacity;
40+
if (gCurrentCalibrationFactor != 0) {
41+
stats.socVal = stats.remainAs / batteryCapacity;;
42+
}
43+
else {
44+
if (lastVoltage > 12.6) {
45+
stats.socVal = 1.0;
46+
} else if(lastVoltage > 12.5){
47+
stats.socVal = 0.9;
48+
} else if(lastVoltage > 12.42) {
49+
stats.socVal = 0.8;
50+
} else if(lastVoltage > 12.33) {
51+
stats.socVal = 0.7;
52+
} else if(lastVoltage > 12.2) {
53+
stats.socVal = 0.6;
54+
} else if(lastVoltage > 12.06) {
55+
stats.socVal = 0.5;
56+
} else if(lastVoltage > 11.9) {
57+
stats.socVal = 0.4;
58+
} else if(lastVoltage > 11.75) {
59+
stats.socVal = 0.3;
60+
} else if(lastVoltage > 11.58) {
61+
stats.socVal = 0.2;
62+
} else if(lastVoltage > 11.31) {
63+
stats.socVal = 0.1;
64+
}
65+
else {
66+
stats.socVal = 0.0;
67+
}
68+
}
4169

4270
//Serial.println("BatteryStatus::updateSOC");
4371
//Serial.printf(" socVal: %.3f\n", stats.socVal);
@@ -59,7 +87,7 @@ void BatteryStatus::updateTtG() {
5987
if (_avgCurrent > 0.0) {
6088
stats.tTgVal = static_cast<int>(max(stats.remainAs - minAs, 0.0f) / _avgCurrent);
6189
} else {
62-
stats.tTgVal = INFINITY;
90+
stats.tTgVal = 0;
6391
//Serial.println("BatteryStatus::updateTtG: Infinity");
6492
}
6593

src/version.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#define VERSION_MAJOR 1
2-
#define VERSION_MINOR 1
2+
#define VERSION_MINOR 2
33
#define VERSION_PATCH 0
4-
#define VERSION_BUILD 53
5-
#define VERSION_DATE "2024-06-02"
6-
#define VERSION_TIME "13:14:31"
7-
#define VERSION "1.1.0.53"
8-
#define VERSION_STR "1.1.0.53 (2024-06-02 13:14:31)"
4+
#define VERSION_BUILD 57
5+
#define VERSION_DATE "2024-06-08"
6+
#define VERSION_TIME "15:50:59"
7+
#define VERSION "1.2.0.57"
8+
#define VERSION_STR "1.2.0.57 (2024-06-08 15:50:59)"

0 commit comments

Comments
 (0)