Hey, I want to calculate the energy used by recharging a battery. This is done in a void loop. To get [Ws] in the end in need the time that my program spends in one void loop (to sum up the single energies of each loop). Right now I have this:
In setup() at very beginning: unsigned long progstart = millis();
in void loop() at very beginning: unsigned long currentMillis = millis(); ..... calculations ..... delta_t = (progstart - currentMillis)*0.001; //in seconds //progstart = currentMillis;
But I am not sure about the result, it seems wrong! What is the correct solution?
Thanks for help!