"FLASH overflowed by 34056 bytes"

Hi everybody

I´ve tried to make the Arduino log the data from an MPU6050 to an SD card but I ran into a problem and can't find the solution?

I use a:
MKR wifi 1010
MPU6050
ethernet shield for MKR gsm series*

The error message:
"region `FLASH' overflowed by 34056 bytes

collect2: error: ld returned 1 exit status

exit status 1"

the code:

/* 
 

#include <Wire.h>
#include <SPI.h>
#include <SD.h>

File dataFile;

const int chipSelect = 4;

const int MPU=0x68; 
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

void setup() {
  
   while (!Serial) {
    ; 
  }
  
    Serial.print("Initializing SD card...");

  
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
 
    while (1);
  }
  Serial.println("card initialized.");
  
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B); 
  Wire.write(0);    
  Wire.endTransmission(true);

  Serial.begin(9600);
 
  delay(1500); 

 
 
}

void loop() {
  
    String dataString = "";
    
     dataFile = SD.open("datalog.txt", FILE_WRITE);


  if (dataFile) {
    dataFile.println("Accelerometer: ");
    dataFile.println("X = "); dataFile.println(AcX);
    dataFile.println(" | Y = "); dataFile.print(AcY);
    dataFile.println(" | Z = "); dataFile.println(AcZ); 
  
    dataFile.println("Gyroscope: ");
    dataFile.println("X = ");    dataFile.println(GyX);
    dataFile.println(" | Y = "); dataFile.println(GyY);
    dataFile.println(" | Z = "); dataFile.println(GyZ);
    dataFile.println(" ");

    delay(333);
  
  }
 
  else {
    Serial.println("error opening datalog.txt");
  
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);  
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,12,true);  
  AcX=Wire.read()<<8|Wire.read();    
  AcY=Wire.read()<<8|Wire.read();  
  AcZ=Wire.read()<<8|Wire.read();  
  GyX=Wire.read()<<8|Wire.read();  
  GyY=Wire.read()<<8|Wire.read();  
  GyZ=Wire.read()<<8|Wire.read();  
  
 
  
  Serial.println("Accelerometer: ");
  Serial.println("X = "); Serial.println(AcX);
  Serial.println(" | Y = "); Serial.print(AcY);
  Serial.println(" | Z = "); Serial.println(AcZ); 
  
  Serial.println("Gyroscope: ");
  Serial.println("X = "); Serial.println(GyX);
  Serial.println(" | Y = "); Serial.println(GyY);
  Serial.println(" | Z = "); Serial.println(GyZ);
  Serial.println(" ");
  delay(333);
  
  
  
  
  
  }
}

plz, help...

You don't close() the file anywhere.

but I have tried adding the close bracket but it still prints the error...

Get rid of the "/*" at the top.

Your code for reading the accel/gyro is inside the ELSE...meaning that it only reads those if it doesn't open the data file.

I´ve moved the accel/gyro inside the if statement and removed the "/*" but still shows the same error...

Post your entire code and the entire error message(s).

I solved the problem. But thanks for your time!