SD Card Speed going down sometimes
Posted: Thu Sep 24, 2020 8:10 am
Hello, I'm using the ESP32 to log some Sensordata with relatively high throughput (3*16bit at 500Hz), but i have the problem, that the SD Card Speed is not constant over the whole time and I lose some data every now and then. The fluctuation occurs every 5-10 minutes and holds for a few seconds. during that time, the writing speed is extremely low.
The card is connected via VSPI (the sensor is on HSPI) and it is a 16Gb SanDisk Ultra. Cables are the shortest jumper cables i had. Devboard is an ESP32-WROOM-32 from AZDelivery.
What could I do to prevent the problem?
example sketch that shows that also showed the problem:
The card is connected via VSPI (the sensor is on HSPI) and it is a 16Gb SanDisk Ultra. Cables are the shortest jumper cables i had. Devboard is an ESP32-WROOM-32 from AZDelivery.
What could I do to prevent the problem?
example sketch that shows that also showed the problem:
- #include "MPU9250.h"
- #include "SPI.h"
- #include "FS.h"
- #include "SD.h"
- #include "timer.h"
- #define FILE_READ "r"
- #define FILE_WRITE "w"
- #define FILE_APPEND "a"
- SPIClass SPI_SD(VSPI);
- const int CS_SD = 5;
- int tsm = 16;
- int t = 0;
- int ts;
- Timer timer_measure;
- File file;
- String datnam = "/temp.txt";
- void measure(){
- file = SD.open(datnam,FILE_APPEND);
- ts = millis()-t;
- t = millis();
- if (ts>3*tsm){
- Serial.print(t);
- Serial.print(" ");
- Serial.println(ts);
- }
- for(int i;i<85;i++){
- String line = String(t) + "\t"
- + String(12345) + "\t"
- + String(12345) + "\t"
- + String(12345);
- file.println(line);
- }
- file.close();
- }
- void setup(){
- Serial.begin(115200);
- Serial.println("Setup SD...");
- if(!SD.begin(CS_SD,SPI_SD)){
- Serial.println("Card Mount Failed");
- delay(1000);
- ESP.restart();
- }
- file = SD.open(datnam,FILE_WRITE);
- file.println("millis\ta\tb\tc");
- file.close();
- timer_measure.setInterval(tsm);
- timer_measure.setCallback(measure);
- timer_measure.start();
- t = millis();
- }
- void loop(){
- timer_measure.update();
- }