Working sketch disappeared

I have a perfectly working sketch. I successfully compiled and saved it. I had a bad laptop battery and lost all power while the sketch was open. When I reopened the IDE on my laptop and opened the sketch, it appears blank with no lines of code. Using file manager, it shows the sketch to be 10K in size.

I then tried to open the file with the online Arduino editor. When I did, the sketch appeared as all periods (............).

Windows 10
IDE 1.8.16

There is data from your sketch in the AppData section of you Windows account. It is normally hidden.

I do not know if it is actually there or recoverable, however I'll guess if you continue to work with the IDE you may over right it.

Hopefully someone more versed in the IDE will chime in and give you better advice.

Can you look at it with something like "notepad"? Don't use a word processing program as it will attempt to modify it for you.
Paul

Yes I opened the .ino file in Notepad. Although the file appeared to be empty, when I select the space by left click and dragging the mouse to select the text, it actually selects something. Its almost like the font is invisible or something. For fun, I opened the file in MS Word and it had several pages of symbols (actually all square boxes) so it appears the file is not empty.

That's unfortunate. If you had come here first you would have found out that the IDE places the modified sketch in the TEMP directory. Copying that file followed by some fairly minor edits would have you back in business.

There is a slight chance the modified sketch is still in the TEMP directory.

As mentioned above, every time you compile your sketch, a copy is saved to a temporary build folder on your computer. This folder is removed when you close the Arduino IDE, but since the computer shut off it's likely the build folder was never removed. The folder will be something like this:

C:\Users\<user name>\AppData\Local\Temp\arduino_build_<build folder number>

Where <user name> is your Windows user name, and <build folder number> will be some random number.

Note that the C:\Users\<user name>\AppData folder is hidden by default. You will need to configure Windows File Explorer to show hidden files before it will be shown.

If there are multiple folders matching the temporary build folder format, you can sort them by "Date Modified" to narrow down the possibilities to the ones that were modified during the relevant time frame.

The sketch code will be in the sketch subfolder, in a file with the .ino.cpp file extension. You can open it up in a text editor. It will have a little bit of extra code added to it, but the sketch code will be easy enough to separate from it. We can help you out with that if needed.

Hi,
I hope you kept versions of you code as you developed it, so you at least have a almost properly working code to re-edit/develop with.

Tom.... :smiley: :+1: :coffee: :australia:

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