Thursday, 27 September 2012

Recover Arduino Sketch

How to recover an Arduino sketch from after a program crash or system crash.

I was working on some code today then after making a heap of code changes and uploading to boards I walked away from my computer without saving my Sketch. 

Due to some other things I was doing at the time Windows crashed and I had not saved my code yet. After a reboot I confirmed that my code was gone but I did not like the idea of that so went digging for it. I know the Hex file is compiled to the %temp% folder so the Sketch must be there too.

So Start>Run>%temp%

which took me to C:\Users\remote\AppData\Local\Temp\

Then I sorted the folders by date modified and then found this one was timestamped about the same time I last compiled my code.

Opening the folder I see a few C++ files and one of them had the same name as my sketch but with a C++ extension. It was my Aduino Sketch it did have a few things added to it to make it C++ compatible (void's) but is was the code I thought I had lost. 


  1. Also is a way to convert you project into a C++ project so you can use AVR-GCC

  2. Thanks for this life-saver, Robert.
    See my account of rescuing code and saving typing at:

    1. Good to see my post helped you and thanks for the link back.