Is there any way to download a sketch from an Arduino?

It should be possible as long as the security bit isn't set. This question was asked on EE a while back.

Is it possible to extract code from an arduino board?

But you won't get the Arduino code you wrote back. The code is compiled into assembly and you'll have to convert that back to C yourself.


This answer doesn't directly answer the question, but still will result in the same end result.

The Arduino IDE uses temporary directories to store build files, including the original sketch as well as the HEX and intermediate files.

On a Mac, these are in /var/folders by default, and on a Windows machine they are in …\Local Settings\Temp\ (which depending on the version of Windows could be in several places).

I've found that especially in Windows, these build files don't get deleted when you close the sketch or IDE, so they may exist on your machine for far longer than you would think.

Also, by default, Crashplan, Backblaze and Time Machine back-up these locations, so even if they have been deleted, they may still be in a backup.

The advantage here is that you will recover C code rather than ASM.


You can download the hex dump of the file, but there is no easy way to get all the C++ code and comments. If you can understand assembly, you could recreate the program, but that would take a while. There are dissasemblers available for some devices, i don't know about arduino.

Tags:

Sketch