How to track your project versions

Very often we tend to create several test versions of an Arduino project on our computer, without any version control.
It may become confusing after uploading to remember which version is currently running, especially if some time has passed since uploading.
For that, I use (and recommend) to add to any project setup() I make a header that automatically prints out on startup or reset the file name, date and time of saving.
The code is simple: (Can also use formatted printout sprintf or printf)

Serial.println(); Serial.print(__FILE__); Serial.print("  "); 
Serial.print(__DATE__); Serial.print(" "); Serial.println(__TIME__);
1 Like

That's a good way to do it. If the project uses a display it can be printed there.

This prints the date & time it was compiled and uploaded, not saved.

If local saving I use a folder with the project name then the project name + Version number (This creates a folder with the same name containing the project file(s)), and have a text file in the main folder with notes of additions/tests/todo etc.

Yes, you are right, its the compilation time.
Adding a file to the project in its original folder is fine. The advantage of the code I added is in it being the last running version. I often have several files open, and not sure which one was loaded to the device. By pressing the reset key I get that information. It is also useful when the device is run on its final destination without the IDE or the source files, where any serial reader can show the version info.

Yes, very good :smiley:

Try this:

Serial.print(__DATE__ " " __TIME__);

That text can be placed in Flash.
Suppose there is a commonly used "buffer" in sram:

strlcpy_P( buffer, PSTR(__DATE__ " " __TIME__), sizeof( buffer));

The Arduino version is somewhere in a *.h file, but I can not find it at the moment.

That's not all. Many libraries have the same name. You need a comment-header that explains which libraries are used.

1 Like

I do something similar on every Arduino project. This way when I pick up a breadboard project that I want to resume working on, I don't have to search (guess) for the project files. Just plug in the USB, enable the console, then power or reset the board.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.