Hi i try to read file from SD it cannot read it. I use 5v FAT32 sd card with microsd card module. So for it prints file exists
but when i add open&read code it says newparam.txt not found. I just do not understand how it works
Please do not post screenshots of code (or error messages); use code tags as described in https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#posting-code-and-common-code-problems.
Further please post full code (or a representative example that exhibits the behaviour).
So you're saying that in the second code you will see the message "Failed to open newparam.txt after confirming existance"?
Not really, for this code it prints newparam.txt not found!
#include <SPI.h>
#include <SD.h>
#define CS_CHIP 10
File myFile;
void setup() {
Serial.begin(9600);
while (!Serial);
if (!SD.begin(CS_CHIP)) {
Serial.println(F("SD initialization failed."));
return;
}
if (!SD.exists("/newparam.txt")) {
Serial.println(F("newparam.txt not found!"));
return false;
}else{
Serial.println(F("newparam.txt found!"));
myFile = SD.open("/newparam.txt");
if (myFile) {
Serial.println(F("Opened newparam.txt:"));
while (myFile.available()) {
char c = myFile.read();
Serial.write(c);
}
myFile.close();
} else {
Serial.println(F("Failed to open newparam.txt after confirming existence."));
}
}
}
void loop() {
}
For this code below, prints "newparam.txt found!"
#include <SPI.h>
#include <SD.h>
#define CS_CHIP 10
File myFile;
void setup() {
Serial.begin(9600);
while (!Serial);
if (!SD.begin(CS_CHIP)) {
Serial.println(F("SD initialization failed."));
return;
}
if (!SD.exists("/newparam.txt")) {
Serial.println(F("newparam.txt not found!"));
return false;
}else{
Serial.println(F("newparam.txt found!"));
}
}
void loop() {
}
I can't help further but last week I encountered something similar with serial ports on a Linux system. I haven't had the time yet to look at that to figure out what is causing this.