How to find what sketch is running?

I have quite a few UNOs with 328s on breadboards that I haven't worked on for months. Although I include sketch names in my setup() code, regrettably I lapsed in my routine of making an independent note. When I run one, is there any way to discover the sketch name please?

Do you mean the setup() code prints the sketch name to serial monitor? If so, I would think the answer to your problem is obvious.

If you mean you put the sketch names in comments in the sketch, then there may be no solution. Comments are not uploaded to the Arduino.

Not really, you could get the compiled code off the chip and compare it to compiled code on your computer, but this would be an issue if you have more than a dozen or so projects.

Just upload the code you think should be on them before hooking up the electronics (Just incase the existing code shorts something to ground or 5V!).

1 Like

Not that this idea will help you with the ones you already have, but what I did was edit the bareminimum file, which is the one that opens in the ide as file/new, and put this in setup():

Serial.println(__DATE__);
Serial.println(__FILE__);

Then you can't not do it :wink:

(bareminimum is read only; I saved it from notepad++ as admin.)

To display the serial monitor requires uploading the sketch - whose name I do not remember!

Thanks, sounds interesting. I have eight of these 'unkowns'. But how do I "...get the compiled code off the chip" to assess if it's a productive method?

To display the serial monitor does not require uploading a sketch. Just plug it in and open serial monitor

1 Like

Thanks, but although I share your apprehension about running an 'unknown' sketch, guessing the sketch name is a one-off event. After that the sketch is lost, recoverable only after the inevitable manual detective work. Essentially ploughing through scores of 'possibles', establishing what they were supposed to do (e.g. what happens if each of several buttons are pressed), then running each of them to see what actually happens.

Bottom line: faiing a tool that will extract the code (e.g in hex), I'll leave the eight aside for now and hope something jogs my memory. Then resume my handwritten log!

That's an unexpected but very welcome revelation, thanks so much!

I've always assumed that the serial monitor displays only the currently uploaded sketch.

@PaulRB: No wonder you were bemused!

1 Like

It does. (The sketch currently uploaded into the currently connected Arduino, that is.)

(Or by uploaded did you mean the one currently in the ide, even if it's not in the currently connected Arduino?)

When you plug your arduino (with unknown sketch on it) into your computer and open serial monitor your arduino will print whatever it has been told to by the sketch on it to the monitor. That is how the techniques above work and how you can identify the sketch

It does indeed solve my current problem of identifying sketches currently downloaded to the ATM328s on their UNOs.

Some of my projects get transferred to independent operation, usually on Veroboard. So far I’ve been more careful about recording the sketch for these externally. :slightly_smiling_face:

But as the 328s are always mounted on IC holders, it’s still relatively easy to get them back onto a UNO and their sketches identified.

I have a macro that I use to do it. A hotkey pastes the printable current sketch name at the text cursor position; e.g:

Serial.println("MB-12plus16-Toshiba16GB");

(Written with my invaluable Macro Express Pro application.)

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