Arduino Uploads wrong Sketch to ESP8266-12

So i have a small piece of code:

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    Serial.write("pls work!"); // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("setup fine");
}

void loop() { // run over and over
  if (Serial.available()) {
    Serial.write(Serial.read());
  }
}

and if i upload it to my MEGA 2560, it says it only uses 2% of the dynamic memory but if i try to upload it to my ESP8266-12 which is on a different port it says it uses 32%. But what i have noticed is that, the 32% was from a different much larger piece of code and i might be wrong about this but i feel like it is trying to upload that code all the time because that code connects to my wifi and everytime i flash the small code to my ESP, the ESP keeps connecting back to my wifi.

The funny thing is that when i first uploaded the small code to my ESP is worked perfectly but i honestly for the life of me don't know what i did or changed after that that made it this way!

I followed this video's instructions:

Does anyone know why is that and how can i fix it, plzz?

I really need this issue to be fixed ASAP as i have a project due soon! :frowning:

did you try to upload an empty to the ESP?

Idahowalker:
did you try to upload an empty to the ESP?

Yes i did try to upload an empty sketch but i keep seeing the 32% for some reason, i don't know why Arduino IDE is hell bent on uploading that code for some reason!

the esp8266 arduino core includes Espressif SDK. always, even if the sketch doesn't use WiFi. it handles WiFi. it connects to last WiFi network automatically