ESP32 SD writes but doesn't append
Posted: Sat Feb 13, 2021 12:16 pm
I've got a microSD module adapter from the far east, and so far so good, and although it can create files using writeFile, it does not append messages. It returns true, i.e: message appended successfully but when you read the file on the computer or when ESP32 reads on reboot, it's blank.
This is how I call the function:
I've even tried the writeFile function with but no luck. When calling appendFile for the first time, this appears:
When the appendFile is called for the second time, this appears in serial monitor:
I am using two SPI devices: MFRC522, and before calling SD's functions, I do a to "enable" the SD functions till it completes its operations and returns back to to disable it.
I've also tried both FAT32 and FAT, no success.
The example in SD(esp32) works fine - writing, appending, deleting, renaming, etc. all work well.
Thanks in advance.
UPDATE: seems like is causing the problem. When I remove it, the appending works fine. As I said, I'm using two SPI with a 330Ohm resistor between MISO and microSD adapter module. Though, before SD functions, I use this function:
Then after SD operations are completed, I use this:
But it doesn't help.
This is how I call the function:
- char* sdFileName = "/v.ea";
- if (appendFile(SD, sdFileName, "Heyy")) {
- //success
- } else {
- //failed
- }
Code: Select all
file.seek(EOF)
- [W][sd_diskio.cpp:149] sdCommand(): token error [17] 0x17
- Appending succesfully.
- [W][sd_diskio.cpp:149] sdCommand(): token error [17] 0x17
- [W][sd_diskio.cpp:149] sdCommand(): token error [17] 0x5
- [W][sd_diskio.cpp:149] sdCommand(): token error [17] 0x5
- [E][vfs_api.cpp:265] VFSFileImpl(): fopen(/sd/v.ea) failed
- Appending failed.
Code: Select all
digitalWrite(SD_SS, LOW)
Code: Select all
HIGH
I've also tried both FAT32 and FAT, no success.
The example in SD(esp32) works fine - writing, appending, deleting, renaming, etc. all work well.
Thanks in advance.
UPDATE: seems like
Code: Select all
rfid.init();
- void activate_SD() {
- rfid.PCD_SoftPowerDown();
- digitalWrite(MFRC522_SSPin, HIGH);
- digitalWrite(SDMOD_SS, LOW);
- if (DEBUG == 1) {
- Serial.println("SD is active.");
- }
- }
- void activate_RFID() {
- rfid.PCD_SoftPowerUp();
- rfid.PCD_Init();
- digitalWrite(SDMOD_SS, HIGH);
- digitalWrite(MFRC522_SSPin, LOW);
- if (DEBUG == 1) {
- Serial.println("RFID is active.");
- }
- }