Skip to content

microSD Memory Card Considerations

Cara Walter edited this page Aug 2, 2023 · 2 revisions

Jim Wagner Feb 14, 2023

The following notes are based on about 8 years of experience with my acceleration data logger. I have not reviewed manufacturer spec sheets on these devices recently so there may have been some changes.

  1. Power consumption varies greatly by manufacturer and even between product families for a given manufacturer. Power consumption does seem to be very consistent for a particular product.

  2. Manufacturer specification sheets say very little or nothing about power requirements except for supply voltage. This may be due to the fact that power consumption depends strongly on the interface software (e.g. the “library”).

  3. The highest consumption appears to happen during a physical write. This does not necessarily happen when your code writes. Memory libraries typically collect data in a buffer (in the microcontroller memory) and only transfers it to the memory card when certain (sometimes unspecified) conditions are met.

  4. The least power consumption appears to happen when the memory card is idle (neither write nor read). In the library that I use, this does not seem to depend on whether or not a file is open.

  5. Powering down a memory card does not seem to help power consumption much unless the intervals between writes is fairly long. This is because power down requires that the file system be closed, and re-opening the fie system on power-up tends to be slow and take a lot of power.

  6. Some, maybe all, file system libraries allow you to set the write buffer size. This is often done in a header file associated with the library. It is really important that the buffer size match the memory card page size. Failure to do this will result in very inefficient writes. Page size will vary with the storage capacity of the memory card. Some libraries may be able to query the memory card to determine buffer size; you need to read library headers, code preambles, and documentation carefully to determine the best strategy, here.

  7. Memory cards come in various storage capacities and speed grades. Power consumption MAY vary with both. For example, there are HS (High Speed) and UHS (ultra-high speed) grades.The higher speed grades are optimized for storing real-time video and similar applications; power consumption appears to go up with speed grade. Speed grade and storage capacity are usually printed on the memory card.

  8. For a given product line, power consumption appears to go up with capacity. Some capacity steps may ALSO involve page size changes. It may be desirable to specify the preferred storage capacity in user documentation.

  9. There may also be other categorizations of memory cards than capacity and speed grade. It could pay to look at several manufacturer product sheets,

  10. Use the “card detect” switch built into many SD/uSD card sockets. Detecting whether or not a card is present is challenging, otherwise. What I had to do with a vertical socket (that does not have a card detect switch) is to try to write to it. At least with the ElmChan FATfs library, one can open a file even if there is no card present. It is only when you attempt to write that adverse things happen. So, I open a “junk” file (I named mine “test.txt”) in “overwrite” mode and attempt to write just a few characters. NB: I have to flush the library’s write buffer to force it to write with just a few characters. THEN, the library returns an appropriate message that says that the write has failed. If you try this for a regular data event, It can take a fairly long time to return the failure message and power consumption is high while this happens. Plus, execution of other code MAY be blocked while waiting for the returned message. To avoid all of this, just use the card detect switch, if there is one. A side note: the switch can be a source of spurious power consumption; you will probably use an internal pull-up resistor in the MCU that will make the associated GPIO pin high when the switch is open and low when it is closed. Because of this, it CAN be advantageous to disable the pull-up most of the time and enable it only when the program needs to know that the SD/uSD card is present.

Resources:

https://forum.arduino.cc/t/power-consumption-to-write-to-sd-card/129434

https://thecavepearlproject.org/2017/05/21/switching-off-sd-cards-for-low-power-data-logging/

https://goughlui.com/2021/02/27/experiment-microsd-card-power-consumption-spi-performance/

Clone this wiki locally