user55541: Is there a way to "ask" the Arduino what sketch was compiled on it?
There are several versions of the sketch and I need to see which version the Arduino has been running.

user16780: First, you have to store the desired information in your sketch.
#define VERSION F("0.01 4-Apr-2019")

void setup() {
   Serial.begin(9600);
   Serial.print(F("Test Sketch V"));
   Serial.println(VERSION); 
}

void loop() { 
}

Of course any other way might work as well: 

Only print it, if at reset a test button is pressed
Check for a Serial command and respond the version info. 
Don't print it, but use avrdude and a programmer to read the FLASH memory and search it for the version string. (Similar to jot's comment above)


55541: <p>Is there a way to "ask" the Arduino what sketch was compiled on it?</p>

<p>There are several versions of the sketch and I need to see which version the Arduino has been running.</p>
 16780: <p>First, you have to store the desired information in your sketch.</p>

<pre><code>#define VERSION F("0.01 4-Apr-2019")

void setup() {
   Serial.begin(9600);
   Serial.print(F("Test Sketch V"));
   Serial.println(VERSION); 
}

void loop() { 
}
</code></pre>

<p>Of course any other way might work as well: </p>

<ul>
<li><p>Only print it, if at reset a test button is pressed</p></li>
<li><p>Check for a Serial command and respond the version info. </p></li>
<li><p>Don't print it, but use avrdude and a programmer to read the FLASH memory and search it for the version string. (Similar to jot's comment above)</p></li>
</ul>
