Skip to main content
3 of 3
added 152 characters in body
Juraj
  • 18.3k
  • 4
  • 32
  • 50

To remove a file use SD.remove("datalog.txt");

SD library's FILE_WRITE is O_READ | O_WRITE | O_CREAT | O_APPEND so it would append at the end of the existing file.

to start with an empty file: File file = FS.open("datalog.txt", O_READ | O_WRITE | O_CREAT);

EDIT: opening the file with O_READ | O_WRITE | O_CREAT doesn't clear the content of the file, only starts to overwrite it from the beginning.

Juraj
  • 18.3k
  • 4
  • 32
  • 50