SD_MMC.file.println data corruption issue

techtoys
Posts: 28
Joined: Sat Jun 01, 2019 11:11 am

SD_MMC.file.println data corruption issue

Postby techtoys » Tue Apr 04, 2023 4:53 am

Hi All

ESP32 Arduino Core: 2.0.5
Arduino IDE 2.0.4

I am working on a data logging system with ESP32 + SD Card. Using the function SD_MMC.file.println() to save data to SD data.
My code is working but there is intermittent data corruption problem.

Pseudo code is :

Code: Select all

#include "SD_MMC.h"
///...
File archive = fs.open("/dat.txt", FILE_WRITE);
 while(sensor_is_active){
 String data = readSensor();
 char *p_char = data.c_str();
 archive.println(p_char);
}
Problem with the code is that, from time to time, data is corrupted.
How to improve the code to safeguard the data integrity?
I am wondering, is it necessary to partition my data to 512byte buffer before using println()?

John

Who is online

Users browsing this forum: No registered users and 57 guests