I was having a sketch but I accidentally downloaded a file which was containing a virus. That virus deleted all my Arduino sketches. I uploaded a sketch into my Arduino UNO and it is still in there. Is there any way to get it back?

  • 1
    No. The sketch is not on the Arduino. The compiled binary code is on the Arduino. The sketch is gone. Don't you have a backup?!
    – Majenko
    Oct 29, 2021 at 10:34
  • 1
    As Majenko said you can never get the original sketch back from the Arduino, since it is compiled first to assembler and then to binary machine code. You can only get back that binary machine code. Then you can use a decompiler to get a corresponding assembler code. Though that won't be anything like a sketch. Especially the symbols (variable names etc) are totally gone. And it sounds like getting the machine code won't help you.
    – chrisl
    Oct 29, 2021 at 10:37
  • 1
    Like the others said. If you lost something you put a lot of effort into, it may be worth taking the time to run something like TestDisk to scrape the drive for chunks of text and then and grep the results for Arduino-related substrings, e.g. "Serial.print". This assumes they haven't been overwritten. If you try that and have questions about it, it's probably in the domain of superuser. If you had a complex project, the odds of success and required effort might be worth it. It wouldn't be particularly fun to do though.
    – timemage
    Oct 29, 2021 at 17:11


Browse other questions tagged or ask your own question.