Serial monitor prints what is not in the code

Hi everyone. I have a question about ESP8266.

I use serial.print() in different lines of code for debugging. Recently i finished debugging, removed those serial.print()s and programmed my MCU again. Strangely, I saw those serial.print()s again!! I am sure that i have removed them but they appear again. note that i use erase_flash before uploading the code to clear the flash.

I also tried to program the first code (without any debugging serial.print) on a new module and again saw the debugging prints in serial monitor!!

Does anybody have an idea?

I am working with ESP-12E module and use PlatformIO to program my module.

Please share your full project and a screenshot of the serial monitor.

Hi @maxgerhardt and thanks for your quick answer. My question seems general and not for a specific project.
Unfortunately i can not share my recent project, just please ask me whatever you want to now.

Well if the code is deleted that prints the message and the firmware was properly rebuilt, then it should not be there. Unless you’re experiencing paranormal memory retention of the old firmware, I think there’s some problem on the meta level like:

  • you modified code but didn’t save it (Ctrl+S/File->Save)
  • you are building a different project in a multi-root workspace because you forgot to use the project environment selector
  • PlatformIO couldn’t delete the old firmware.bin because of permission errors, delete the .pio folder of the project and make sure it’s deleted, then rebuild + reupload
  • the message you’re seeing is printed by another code file, use the search bar to search for the message

really thanks for your follow up! :slight_smile:
Let’s see, I downloaded older version of the project from gitlab to test it. So now i have a new folder of project without any debugging serial.print() code. I built and uploaded this project on the esp, and still getting the debugging messages :frowning:

so:

  • I have saved the project.
  • As i said i downloaded the older version and test it on a new project.
  • I tried to delete the .pio folder and it didn’t work.
  • I searched for the printed message in the whole project and didn’t find result.

Try and upload the blinky project to it. Does it still appear to be running your old firmware?

Clearly it is impossible for a program to execute a statement if that statement isn’t in the program.

I would try changing the messages in those Serial.println() statements to say something different, and reload the program. If you still see the old statements then you didn’t have success reloading the program.

Good idea! I uploaded blinky project and it didn;t show the old messages in serial monitor.
After analysing my code, i found out that i have added a line of debuging serial.print() in arduino LittleFS library :man_facepalming: and so i couldn’t find it in VSCode search tool!
@maxgerhardt and @jamesluschen Thank you for your good help and sorry for my mistake :pray: