Qwiic OpenLog read file and save as int or float

I have a project where i run a stepper motor and count the revolutions. I save various data to the SD card via openlog. I have this running for months at a time and have power outages. I would like to write the cycles to a file on the SD card and if there is a power outage during the reboot it reads the file and loads the cycle count from the SD card into the program.

I have been able to find example code on reading a file and writing to serial, but i have not been able to save numbers to use in the program.

Any ideas or help here?

IF the power outage occurs before you write the data and close the file so the actual data is written and the directory is updated to show the new file length, you will still not have the data you want.
You either need to close the file every time you update the information or you need a battery back up, just like for your PC!

1 Like

That’s good advice, I do write the data to SD and close the file then wait some time. I have no problem writing the data and i found ways to read the data and display it one byte at a time in Serial but I need to read a .txt file and take the numbers in the file and store them in variables in the program.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.