Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I made a sketch, but then I lost it. However, I uploaded it to the Arduino before losing it. Is there any way I can get it back?

share|improve this question
electronics.stackexchange.com/questions/28211/… but as others say, this only spits out .hex files, not the originating C source. –  jippie Feb 14 '14 at 0:34
Cross site dupe: reverseengineering.stackexchange.com/q/125/189 –  AsheeshR Feb 14 '14 at 1:14

4 Answers 4

up vote 14 down vote accepted

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.

share|improve this answer

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 /var/folders by default, and on a Windows machine 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 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.

share|improve this answer

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.

share|improve this answer
There are no disassemblers for arduino, because it is not a MCU type. There are multiple ATmega disassemblers (google atmega disassembler). –  Connor Wolf Feb 24 '14 at 4:28
If you have the arduino envitonment, you already have avr-objdump as it comes with avr-gcc. –  Chris Stratton Jan 21 at 2:03

I think there is another way to do this, without extracting the code from the Arduino board. Remenber the date you create the sketch, and look for it in C:\Users\User\AppData\Local\Temp\ (For example : C:\Users\User\AppData\Local\Temp\untitled4390292704786567977.tmp\sketch_jan19a ). You could find your unsaved code unless it was deleted by some "freeing space program". Good luck!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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