Problem Converting Project from SD to SDFat library

Hi, I am working on a project which it is almost finished and I tried to include a micro SD card in order to log the data I was getting from the sensors. I first tried to do it with the SD library that comes with the Arduino IDE, but then I noticed I needed more memory and I read I had to use the SDFat library. I installed it directly from the Arduino IDE without unzipping it, and I didn’t have any problem with that. The problem is that I don’t know how to transform the project for using it with the SDFat library. Could someone tell me what I have to change or where can I find this information? Here is the part of the code that is involved in the SD data logging process:

#include <SPI.h>
#include <SdFat.h>
#include <DHT.h>;

#define DHTPIN A2
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);
SdFat SD;
File logFile;

float hum;  
float temp; 
void setup() {
  Serial.begin(9600);
  Serial.print(F("Initializing SD"));
  if (!SD.begin(4))
  {
    Serial.println(F("Error initializing"));
    return;
  }
  Serial.println(F("Correctly initialized"));
}

void loop() {
  hum = dht.readHumidity();
  temp = dht.readTemperature();

  logFile = SD.open("datalog.txt", FILE_WRITE);
  
  if (logFile) { 
    logFile.print("Temperature: ");
    logFile.print(temp);
    logFile.print(" ºC, Humidity: ");
    logFile.print(hum);
    logFile.println(" %");
    logFile.close();
  } 
  else {
    Serial.println("Error opening the file");
  }
}

Thanks :slight_smile:

I'd start with the examples the library provides

Why do you assume that SDFat uses less memory?

If the problem is that you wish to free up memory, post your entire code.