Is this an issue or a defined behavior? I am using Arduino IDE 1.6.6

Sometimes I made changes in code, and immediately upload them to the Arduino board. And many times issues already fixed are persisting, leaving me that feeling of "the uploaded code has not the changes I have just made". Then I save my sketch, compile and upload again and the issue vanishes. As long as the issue get someway fixed, I tend to forgot about it.

As software engineer, most of the times I assume the code I am compiling and uploading / publishing to any platform is always the latest, not the latest saved. I believe this is not the behavior of the Arduino IDE. It uploads the last saved version of code, not the last modified.

In summary: I believe the Arduino IDE uploads to the board the last saved version of the sketch, not the current one being modified. Can anyone confirm this?

Thanks in advance.

  • 2
    I can't confirm that since I use an external editor, which necessitates saving before compiling. I sometimes use a menu which I wave the mouse over to compile+upload. ¶ See the last post or two in topic #46983 in forum.arduino.cc which depending on interpretation may or may not suggest that in 2010 it did not work as you say. Jan 5, 2016 at 20:15
  • 2
    I can't prove it (i.e., I haven't looked at the code), but it seems to me that 1.6.6 saves before uploading – seems worth a test. Also worth mentioning the platform where you're seeing this behavior. I'm on a MacBook Pro running OS X 10.11.2.
    – dlu
    Jan 5, 2016 at 21:32
  • Yeah, the option is on. I am on Windows 10. If it's working correctly, then I probably had some issue with the upload, or simply believing I uploaded the last version when actually didn't. I would like to discard as much clues as possible, I hate this kind of "magic" fixes. Thank for your replies!
    – fabrosell
    Jan 6, 2016 at 1:03
  • If you were not using an external editor, it would be the latest, whether it is saved or not. In that case, just use Ctrl-S before the Ctrl-U when uploading. It will save it and upload it. If an external editor, do the Ctrl-S there, then Ctrl-U in the IDE. Don't trust the auto-save option when using an external editor.
    – SDsolar
    Apr 8, 2017 at 3:14

1 Answer 1


I haven't tried it but it would be an easy experiment to make on some throw-away code.

However, do note that saving before compiling or uploading is optional in the Arduino IDE. That may very well be the key to what you observed. I keep mine enabled, i.e., to save before any compile or upload. The option is in the Preferences dialog accessed from the menus, not in the manually-edited preferences.txt file. That might be the key to what you observed.

Update: In that case, including the pre-defined macros __DATE__ and __TIME__ (of the pre-processor run) and __TIMESTAMP__ (of the file's last modification) in a "Hello" string can help debug this.

These pages list the standard, and common predefined macros implemented in gcc's pre-processor. Note also that most version control systems offer similar macros that get replaced at checkout to embed a revision number and other version-control information.

  • Thanks for your reply. Apparently I have the option to save when compiling or uploading on, but I still face some "outdated code" like issues. They got fixed after save, compile and upload. I am guessing now that I may had an upload error. Or not uploading at all. But I would like to discard as most clues as possible. Apparently, the IDE is saving my files as expected... (assuming there is no open bugs on that feature).
    – fabrosell
    Jan 5, 2016 at 21:34
  • In the general sense things like __TIME__ may not fairly depict the compilation flow as these would not cause the editor aspect of the IDE to report that there have been any program changes to invalidate a cached compilation. For example with a traditional Makefile setup timestamps like this don't work unless something else forces a rebuild of the code where they appear. So this isn't really a good test; making a trivial change for example to a printed string would be. Oct 15, 2016 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.