PROBLEMS WHEN RAISING DATA RESERVOIR TO MEMORY MICRO-SD

Good afternoon dear community. I am new to the field, even though I have anime anemometer, the programming of the anemometer is included, however, when I try to modify the sketch and upload it I get the message in the serial: ERROR ON OPENING THE FILE.
I have tried to format the memory in FAT32, change the code but nothing works for me, I do not know what else to do. It is for this reason that I appeal to your support.
This is the code that I have been working on based on contributions from third parties:

#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
const int chipSelect = 10; //cs or the save select pin from the sd shield is connected to 10.
RTC_DS1307 RTC;
//------------------------------------  ANEMOMETRO  ------------------------------------

// --- Constantes ---
const float pi = 3.14159265;     //Número de pi
int period = 1000;               //Tempo de medida(miliseconds)
int delaytime = 1000;            //Invervalo entre as amostras (miliseconds)
int radius = 147;                //Raio do anemometro(mm)


// --- Variáveis Globais ---
//unsigned int Sample  = 0;        //Armazena o número de amostras
unsigned int counter = 0;        //Contador para o sensor  
unsigned int RPM = 0;            //Rotações por minuto
//float speedwind ;             //Velocidade do vento (m/s)
float windspeed ;             //Velocidade do vento (m/s)

//---------------------------------------------------------------------------------//

//int led=3;

File dataFile;
//DateTime now;

void setup () {

//pinMode(led, OUTPUT);

//------------------------------------  ANEMOMETRO  ------------------------------------
   
  pinMode(2, INPUT);        //configura o digital 2 como entrada
  digitalWrite(2, HIGH);    //internall pull-up active
    
//---------------------------------------------------------------------------------// 
    Serial.begin(9600);
  //setup clock
  Wire.begin();
  RTC.begin();
//check or the Real Time Clock is on
  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    // uncomment it & upload to set the time, date and start run the RTC!
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
//setup SD card
   Serial.print("Initializing SD card...");

  // see if the SD card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");

 /* //write down the date (year / month / day         prints only the start, so if the logger runs for sevenal days you only findt the start back at the begin.
    now = RTC.now();
    dataFile = SD.open("met.txt", FILE_WRITE);
    dataFile.print("Start logging on: ");
    dataFile.print(now.year(),DEC);
    dataFile.print('/');
    dataFile.print(now.month(),DEC);
    dataFile.print('/');
    dataFile.print(now.day(),DEC);
    dataFile.println(" ");
    dataFile.println("Time            Counter            RPM            Velocidad del viento (m/s)");
   
 //   dataFile.close();

*/

}

void loop (void){


//read the time
  DateTime now = RTC.now();


//open file to log data in.
   dataFile = SD.open("met.txt", FILE_WRITE);
   
  // if the file is available, write to it:
  // log the temperature and time.
  if (dataFile) {

    dataFile.print(now.hour(),DEC);
    dataFile.print(":");
    dataFile.print(now.minute(),DEC);
    dataFile.print(":");
    dataFile.print(now.second(),DEC);
    Serial.print(" ");

    //Sample++;
//    dataFile.print(Sample);
    dataFile.print("Empezo la medicion...");
    //windvelocity();
    dataFile.println("   Terminado.");


    dataFile.print(now.hour(),DEC);
    dataFile.print(":");
    dataFile.print(now.minute(),DEC);
    dataFile.print(":");
    dataFile.print(now.second(),DEC);
    dataFile.print(" ");

    dataFile.print(counter);
    dataFile.print(" ");
    //RPMcalc();
    dataFile.print(RPM);
    dataFile.print(" ");
    dataFile.println(windspeed);
       
    dataFile.close();
    // print to the serial port too:
    //Serial.println("data stored");

  /* digitalWrite(led, HIGH);   // enciende el LED (HIGH es el nivel de voltaje)
   delay(100);               // espera un segundo
   digitalWrite(led, LOW);
   delay(100);
*/

    // read wind
    Serial.print(now.hour(),DEC);
    Serial.print(":");
    Serial.print(now.minute(),DEC);
    Serial.print(":");
    Serial.print(now.second(),DEC);
    Serial.print(" ");
    //Sample++;
    //Serial.print(Sample);
    Serial.print("Empezo la medicion...");
    windvelocity();
    Serial.println("   Terminado.");

    Serial.print(now.hour(),DEC);
    Serial.print(":");
    Serial.print(now.minute(),DEC);
    Serial.print(":");
    Serial.print(now.second(),DEC);
    Serial.print(" ");
    
    Serial.print("Counter: ");
    Serial.print(counter);
    Serial.print(";  RPM: ");
    RPMcalc();
    Serial.print(RPM);
    Serial.print(";  Velocidad del viento: ");
    WindSpeed();
    Serial.print(windspeed);
    Serial.print(" m/s ");
 

  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error al abrir");
  }
  
  



  //delay(1000); // this will log the temperature every second.
  delay(delaytime);
}


  //Função para medir velocidade do vento
void windvelocity()
{
//  speedwind = 0;
  windspeed = 0;
  
  counter = 0;  
  attachInterrupt(0, addcount, RISING);
  unsigned long millis();       
  long startTime = millis();
  while(millis() < startTime + period) {}
}


//Função para calcular o RPM
void RPMcalc()
{
  RPM=((counter)*60)/(period/1000);  // Calculate revolutions per minute (RPM)
}


//Velocidade do vento em m/s
void WindSpeed()
{
  windspeed = ((4 * pi * radius * RPM)/60) / 1000;  //Calcula a velocidade do vento em m/s
 
} //end WindSpeed


//Velocidade do vento em km/h
/*void SpeedWind()
{
  speedwind = (((4 * pi * radius * RPM)/60) / 1000)*3.6;  //Calcula velocidade do vento em km/h
 
} //end SpeedWind
*/

//Incrementa contador
void addcount()
{
  counter++;
}