I have simple problem with not simple solution.

My workflow is:

  • Read CID from SD card
  • Send CID via Http to clodud
  • Download specific text from cloud
  • Write this text to file in same SD card

All is working except last step. I cannot figure out how to write to file using SDFat lib. I have to use SDFat for reading CID and other low lvl data from card. Im strugling on "open File" step. Have numerous problems with multiple declarations and none of combinations SD.h SDFat.h and FS.h not working for me. Please, help me, how to open file.

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include "SdFat.h"
#include "sdios.h"

SdFat sd;


void WriteToFile(String payload) {
  fs::File myFile;
  myFile = sd.open("test.txt", FILE_WRITE);



So what is wrong: Using ESP8266 I cannot compile code due to multiple occurence of fs::File and File32.

C:\...\Arduino\libraries\SdFat\src/SdFat.h:400:16: error: 'typedef class File32 File' conflicts with a previous declaration
 typedef File32 File;

Now I rebuild whole code for ESP32 chip. I can compile and upload code. It can read CID send it, read incoming file and ope SD card. But when writing to file I got

error: Cannot open file
Check SD format.

I tried several formats, Fat16, Fat32, exFat on several SD cards from 2 to 64Gbs. All of them were unlocked, all of them were formated to 2 partitions (thats what I want) and 1 partition (for testing) withouth difference. I was also tweeking SPI speed When I set more than 16MHz, it fails (Using ESP32 Wroom)

EDIT2: When I first open volume, call chvol() on volume (not sd card) then it works and I can open file and write to it. Wtf?

  if (!volume.begin(sd.card())) {
    Serial.println("Could not find exFat partition.\nMake sure you've formatted the card");

  • 1
    If you don't describe us the problems more detailed, we can not say what went wrong. Does the code not compile? Is there an error message, when you run the prog? Perhaps you locked the SD card, so writing is impossible, or you have to change the FAT Vlolume with sd.chvol(). Does open for read work? Have you tried that?.... Just saying "it doesn't work" is not enough! ;-). Dec 2, 2020 at 13:14
  • 1
    I edited question with some news and updates
    – 110mat110
    Dec 3, 2020 at 10:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.