Hello everyone, I need help! Please
I've stored some values on an sd card from a sensor reading and I want to do an automatic addition of that values that has been stored on the sd card.
So the sensor stored the values on the sd card in a .txt file format using an arduino uno + Sd card module + DS3231 (module to get the time and date).
I want to add all the values (only the values, not the time and date) and get a "grand total" at the end.
How can I do the automatic addition? Any idea guys
Where does the addition need to go? In the file or just on screen somewhere ?
If it’s not in the file then
create a global variable or suitable type for the sum
in setup() read/parse the data in the file and calculate the sum
in loop, each time you are have added a new sample to the file, also update the sum
If it’s in the file, you need to decide where you want to have it as it will impact how you write back in the file. As it’s a text file the number of characters to represent the sum will vary and having some padding upfront will make your life easier eg don’t write in the file
Sum = 99
But
Sum = 99
So that you can overwrite one of the space when you write the next sum
Sum = 132
And not change all the file (if it’s not at the end)
Alternatively write a csv file and when you need to do some maths import that into a spreadsheet
Actually the circuit, it's a current & voltage meter that measured AC voltage and current.
The file log .txt on the sd card contains the data:
Date, time, voltage, current sensor 1 and current 2.
At the end, let say each 10mins, it should add all current sensor 1 and give a grand total, do the same thing for current 2.
unfortunately, I don't know how to do that addition.
no binary format.
"What happens when the arduino crashes or looses power or you remove the SD card? Should history be taken into account when you start the Arduino?"
I will take that into consideration but right now I need someone to help me with this addition thing.