I want to build an embedded system that reads external data and logs it to a file saved in an SD card. However this system is accessed through a password and I want either the SD card or the file in it to use this password as well. How can I do it? About the file, I thought of saving it with a .CSV extension because it uses rows and columns. Can this type of files have password? Any suggestions?

To be more specific with the question: I will use a microcontroller, programmed with C language. What commands should I send to the SD card in order to be password-protected? Or, what is the format of a file in order to have an access password?

EDIT: I want to add a password so that only the user is able to open the file and read it using his/her PC.

  • \$\begingroup\$ Notably, the answer to this question really is 42. \$\endgroup\$ – Dmitry Grigoryev Aug 15 '17 at 9:58

The SD card has password protection built into the standards. Here you can read the standards for SD cards to learn how it works. Below is a link to a project for locking/unlocking a SD card with an Atmel microcontroller.


  • 4
    \$\begingroup\$ But note that most devices which interface with SD cards, including computer-based SD readers, do not support password protection. You will likely be unable to use the card while protection is enabled. \$\endgroup\$ – duskwuff -inactive- Sep 9 '14 at 5:17
  • \$\begingroup\$ @duskwuff I want to add a password so that only the user is able to open the file and read it (using his/her PC). So, according to your comment, this will not be possible if I use the solution provided above, is that what you mean? \$\endgroup\$ – esal26 Sep 10 '14 at 17:54
  • \$\begingroup\$ Correct. SD card passwords protect the entire card from being used, not individual files. \$\endgroup\$ – duskwuff -inactive- Sep 10 '14 at 18:02
  • \$\begingroup\$ @duskwuff Strictly speaking, this is only true when the SD reader is connected via USB Mass storage endpoint (or a similar interface) which doesn't support raw SD commands. Many internal card readers accept arbitrary SD commands. You still need software to send these commands though. \$\endgroup\$ – Dmitry Grigoryev Aug 15 '17 at 9:53
  • \$\begingroup\$ @DmitryGrigoryev Right, I mean from a practical perspective. Even if the hardware can technically send the commands to unlock the card, the drivers probably won't handle that case. Inserting a password-protected card will likely result in an error message or nothing at all -- not a password prompt. \$\endgroup\$ – duskwuff -inactive- Aug 15 '17 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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