From 8e33170c4527462df0e6c66208316b0f7edee897 Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Tue, 21 Jun 2022 15:02:25 +0100 Subject: [PATCH] Fix bug --- battery_tester.ino | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/battery_tester.ino b/battery_tester.ino index 913d434..3f68e50 100644 --- a/battery_tester.ino +++ b/battery_tester.ino @@ -1,3 +1,4 @@ + #include #include @@ -104,17 +105,17 @@ void loop() { float mwatthours; if (timer.hasPassed(1000)) { + unsigned long passed = timer.elapsed(); timer.restart(); + battery_voltage = readVoltage(A0); + if (battery_voltage < 0.8) { delay(200); } else { - unsigned long passed = timer.elapsed(); - shunt_voltage = readVoltage(A1); shunt_current = shunt_voltage/APPARENT_SHUNT_RESISTANCE; - battery_voltage = readVoltage(A0); amps_in_period = shunt_current * passed/1000; watts_in_period = amps_in_period * battery_voltage; -- 2.46.2