I have an arduino code with an SD card where I save some data. When I load a new code, The SD must update with the new data that I put in the code, but if I reset the Arduino by the reset button, I don´t want the SD data to change.

To sum up, I want to reload SD data only when I update the code, and not with hardware reset

Any ideas?

  • Which Arduino do you have?
    – Majenko
    Commented Jul 5, 2021 at 14:36
  • I´m trying with Arduino Uno, but the code should work for Nano and Mega too
    – AlexSp3
    Commented Jul 5, 2021 at 14:37
  • Then I'm sorry, you can't. There is no "software reset". Uploading code triggers a hardware reset through "pressing" the reset for you.
    – Majenko
    Commented Jul 5, 2021 at 14:37
  • Ah, so there isn´t real difference between both reset
    – AlexSp3
    Commented Jul 5, 2021 at 14:39

1 Answer 1


You can't. There is no "software" reset. When you upload new code a hardware reset is triggered by the DTR pin of the USB interface chip.

Instead I would suggest maintaining a "data version number" on the SD card. Read it on startup and, if it differs from the expected version number (which you update in your code manually) it creates the data for you and sets the version number.

  • 1
    Well, I didn´t think about that, sounds like a good solution. Thanks!
    – AlexSp3
    Commented Jul 5, 2021 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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