ESP8266 problem with SDFat library
Posted: Wed Feb 09, 2022 7:07 pm
Hello, i am using the ESP8266 on the Arduino IDE for a project that needs use a SD module to write data from an accelerometer (MPU6050) at high speed (write the data of the 3 axis at every 0.01 seconds), but i have a problem. The SDFat library doesn't seen to work for reasons i can't figure out, and i'm just trying the examples that comes with the library itself and dont even compile.
The example code:
The error that shows to me is: 'SdFat' does not name a type
I tried to search on topics and found this one:
https://forum.arduino.cc/t/esp8266-and- ... msg4888724
I copied his code, that he said it works, but it doesn't work as well, the unique change is that he puts using namespace sdfat after include "SdFat.h". The previous error disappear (i dont know why) but a new one arrives.
His code:
The new error: no match for 'operator=' (operand types are 'fs::File' and 'sdfat::File32')
The situation of my IDE is: the library been used apparently is called ESP8266SDFat, this one comes when installed the esp boards on the boards manager. So i tried aready a few things that dont give me good results.
1. Installed the SDFat library on the Librabry Manager and tried use it, but it gives conflict with the ESP8266SDFat. So first i changed the foulder name of ESP8266 to SdFat as the guy on the linked topic told so. But didn't worked.
2. Then i deleted the ESP8266SDFat library, and compile with the SDFat from library manager... it gives the error: SDFat does not name a type.
3. I deleted the SdFat library from library manager. And let the ESP8266SDFat... but no results
Now i dont know more what to do. I need help and i'm desperate. If someone has passed for this and suceed to overcome this problem, plis help me.
This is my first time on forum, if is something wrong with this post, please tell me.
The example code:
Code: Select all
#include <SPI.h>
//#include <SD.h>
#include "SdFat.h"
SdFat SD;
#define SD_CS_PIN SS
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(SD_CS_PIN)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop() {
// nothing happens after setup
}
The error that shows to me is: 'SdFat' does not name a type
I tried to search on topics and found this one:
https://forum.arduino.cc/t/esp8266-and- ... msg4888724
I copied his code, that he said it works, but it doesn't work as well, the unique change is that he puts using namespace sdfat after include "SdFat.h". The previous error disappear (i dont know why) but a new one arrives.
His code:
Code: Select all
#include <SPI.h>
//#include <SD.h>
#include "SdFat.h"
using namespace sdfat;
SdFat SD;
#define SD_CS_PIN SS
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(SD_CS_PIN)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
The new error: no match for 'operator=' (operand types are 'fs::File' and 'sdfat::File32')
The situation of my IDE is: the library been used apparently is called ESP8266SDFat, this one comes when installed the esp boards on the boards manager. So i tried aready a few things that dont give me good results.
1. Installed the SDFat library on the Librabry Manager and tried use it, but it gives conflict with the ESP8266SDFat. So first i changed the foulder name of ESP8266 to SdFat as the guy on the linked topic told so. But didn't worked.
2. Then i deleted the ESP8266SDFat library, and compile with the SDFat from library manager... it gives the error: SDFat does not name a type.
3. I deleted the SdFat library from library manager. And let the ESP8266SDFat... but no results
Now i dont know more what to do. I need help and i'm desperate. If someone has passed for this and suceed to overcome this problem, plis help me.
This is my first time on forum, if is something wrong with this post, please tell me.