Add min,max; Changed Display formatting, minor fixes
This commit is contained in:
parent
ce64646347
commit
3a6c1ca884
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
!<arch>
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
!<arch>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -51,11 +51,12 @@ void data_logging();
|
|||
|
||||
//Globale Variablen
|
||||
float shuntvoltage_V = 0, shuntvoltage_mV = 0, busvoltage_V = 0, busvoltage_mV = 0, current_A = 0, current_mA = 0, power_W = 0, power_mW = 0;
|
||||
float shuntvoltage_V_max = 0, current_A_max = 0, power_W_max = 0, shuntvoltage_V_min = 0, current_A_min = 0, power_W_min = 0;
|
||||
float Ah = 0, mAh = 0, Wh = 0, mWh = 0;
|
||||
float battery_voltage, battery_average;
|
||||
int i_header = 0;
|
||||
bool button1, button2, button3;
|
||||
bool lcd_light = true;
|
||||
bool lcd_light = true, wifi_enabled = true;
|
||||
bool measuring_run = false, reset_actual = false, reset_minmax =false, battery_low = false;
|
||||
unsigned long lastread = 0;
|
||||
unsigned long tick;
|
||||
|
@ -174,6 +175,7 @@ void setup() {
|
|||
lcd.print("Done");
|
||||
} else {
|
||||
lcd.print("Wi-Fi disabled");
|
||||
wifi_enabled = false;
|
||||
}
|
||||
|
||||
//Init ina219s
|
||||
|
@ -197,7 +199,6 @@ void setup() {
|
|||
task.addTask(t3);
|
||||
task.addTask(t4);
|
||||
task.addTask(t5);
|
||||
t1.enable();
|
||||
t2.enable();
|
||||
t3.enable();
|
||||
t4.enable();
|
||||
|
@ -223,6 +224,15 @@ void setup() {
|
|||
lcd.setCursor(0,3);
|
||||
lcd.print("Done. Starting up...");
|
||||
delay(1500);
|
||||
//Display IP address
|
||||
if (wifi_enabled) {
|
||||
lcd.clear();
|
||||
lcd.setCursor(6,1);
|
||||
lcd.print("IP address");
|
||||
lcd.setCursor(5,2);
|
||||
lcd.print(WiFi.localIP());
|
||||
delay(1500);
|
||||
}
|
||||
//Load Default Screen
|
||||
lcd_init();
|
||||
}
|
||||
|
@ -244,7 +254,8 @@ void lcd_print() {
|
|||
lcd.print(busvoltage_V);
|
||||
if (current_A > 10) {lcd.setCursor(1,1);} else if (current_A < 0) {lcd.setCursor(1,1);} else {lcd.setCursor(1,1); lcd.print(" ");}
|
||||
lcd.print(current_A);
|
||||
if (power_W > 10) {lcd.setCursor(1,2);} else if (power_W < 0){lcd.setCursor(1,2);} else {lcd.setCursor(1,2); lcd.print(" ");}
|
||||
lcd.setCursor(0,2);
|
||||
if (power_W < 100 && power_W > 10) {lcd.print(" ")}; else if (power_W < 10) {lcd.print(" ")};
|
||||
lcd.print(power_W);
|
||||
if (Ah > 10) {lcd.setCursor(13,1);} else if (Ah < 0){lcd.setCursor(11,1);} else {lcd.setCursor(11,1); lcd.print(" ");}
|
||||
lcd.print(Ah);
|
||||
|
@ -377,12 +388,37 @@ void readCurrent() {
|
|||
mAh = Ah * 1000;
|
||||
Wh += (power_W * tick)/3600000.0;
|
||||
mWh = Wh * 1000;
|
||||
|
||||
if (shuntvoltage_V_max < shuntvoltage_V) {
|
||||
shuntvoltage_V_max = shuntvoltage_V;
|
||||
}
|
||||
if (current_A_max < current_A) {
|
||||
current_A_max = current_A;
|
||||
}
|
||||
if (power_W_max < power_W) {
|
||||
power_W_max = power_W;
|
||||
}
|
||||
if (shuntvoltage_V_min > shuntvoltage_V) {
|
||||
shuntvoltage_V_min = shuntvoltage_V;
|
||||
}
|
||||
if (current_A_min > current_A) {
|
||||
current_A_min = current_A;
|
||||
}
|
||||
if (power_W_min > power_W) {
|
||||
power_W_min = power_W;
|
||||
}
|
||||
}
|
||||
if (reset_actual) {
|
||||
Ah = 0;
|
||||
Wh = 0;
|
||||
data_timestamp = 0;
|
||||
reset_actual = false;
|
||||
shuntvoltage_V_max = 0;
|
||||
current_A_max = 0;
|
||||
power_W_max = 0;
|
||||
shuntvoltage_V_min = 0;
|
||||
current_A_min = 0;
|
||||
power_W_min = 0;
|
||||
}
|
||||
lastread = newtime;
|
||||
ina219.recalibrate();
|
||||
|
@ -460,17 +496,19 @@ void web_measuring_reset(AsyncWebServerRequest *request) {
|
|||
}
|
||||
|
||||
void web_get_values(AsyncWebServerRequest *request) {
|
||||
request->send( 200, "application/json", "{\"voltage\":" + String(busvoltage_V) + ", \"current\":" + String(current_A) + ", \"power\":" + String(power_W) + ", \"Ah\":" + String(Ah) + ", \"Wh\":" + String(Wh) + ", \"battery\":" + String(battery_voltage) + ", \"run\":" + String(measuring_run) + "}");
|
||||
request->send( 200, "application/json", "{\"voltage\":" + String(busvoltage_V) + ", \"current\":" + String(current_A) + ", \"power\":" + String(power_W) + ", \"Ah\":" + String(Ah) + ", \"Wh\":" + String(Wh) + ", \"battery\":" + String(battery_voltage) + ", \"run\":" + String(measuring_run) + ", \"run\":" + String(shuntvoltage_V_max) + ", \"run\":" + String(shuntvoltage_V_min) + ", \"run\":" + String(current_A_max) + ", \"run\":" + String(current_A_min) + ", \"run\":" + String(power_W_max) + ", \"run\":" + String(power_W_min) + "}");
|
||||
}
|
||||
|
||||
void data_logging() {
|
||||
if (measuring_run) {
|
||||
File tempLog = SPIFFS.open("/datalog.csv", "a");
|
||||
tempLog.print(data_timestamp); tempLog.print(',');
|
||||
tempLog.print(busvoltage_V); tempLog.print(',');
|
||||
tempLog.print(current_A); tempLog.print(',');
|
||||
tempLog.println(power_W);
|
||||
tempLog.close();
|
||||
File datalog = SPIFFS.open("/datalog.csv", "a");
|
||||
datalog.print(data_timestamp); datalog.print(',');
|
||||
datalog.print(busvoltage_V); datalog.print(',');
|
||||
datalog.print(current_A); datalog.print(',');
|
||||
datalog.println(power_W); datalog.print(',');
|
||||
datalog.println(Ah); datalog.print(',');
|
||||
datalog.println(Wh);
|
||||
datalog.close();
|
||||
data_timestamp++;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue