-
Notifications
You must be signed in to change notification settings - Fork 7.7k
esp32 panic'ed
#7745
-
"Hello all, I have an ESP32 with an SD card module. I want to read data from the SD card and save it in variables. However, after the ESP reads the data, it panics.
this is the code:
`
#include <SPI.h>
#include <SD.h>
#include "FS.h"
String DataTemp;
String Parametro;
short i;
String AllData[7];
int Pointer = 0;
int count = 0;
void readFile(fs::FS &fs, const char * path){
Serial.printf("Reading file: %s\n", path);
File file = fs.open(path);
if(!file){
Serial.println("Failed to open file for reading");
return;
}
Serial.print("Read from file: ");
while(file.available()){
char c = file.read();
if (isPrintable(c)) { //
DataTemp.concat(c);
}
else if (c == '\n') { // End of line
Parametro = DataTemp; //
DataTemp = ""; // Reset to null ready to read the next line
Serial.print("The parameter is: ");
Serial.println(Parametro); // Show us the valu
AllData[Pointer] = Parametro;
Pointer++;
}
}
for (count=0;count<5;count++) {
Serial.println(AllData[count]);
delay(100);
}
delay(100);
file.close();
}
void setup() {
Serial.begin(115200);
delay(10);
if(!SD.begin(5)){
Serial.println("Card Mount Failed");
return;
}
uint8_t cardType = SD.cardType();
if(cardType == CARD_NONE){
Serial.println("No SD card attached");
return;
}
Serial.print("SD Card Type: ");
if(cardType == CARD_MMC){
Serial.println("MMC");
} else if(cardType == CARD_SD){
Serial.println("SDSC");
}else if(cardType == CARD_SDHC){
Serial.println("SDHC");
} else {
Serial.println("UNKNOWN");
}
}
void loop() {
readFile(SD,"/data.txt");
delay(20000);
}
`
Can anyone help me with this problem?, and how I can save data from one line in this form (0,69.50,20.10) in variables x=0 y=69.50 z=20.10 ?
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment