Choosing a microSD for your Raspberry Pi IoT Project

The Raspberry Pi is a small ARM based single board computer (SBC), which runs variations of Linux, and can be used in IoT sensor projects. Because of its low cost, small size and robust operating system, the Raspberry Pi is a popular choice for burgeoning developers. It is often used for verification of IoT technology and, in some cases, actual IoT deployments.

In order to use a Raspberry Pi as an IoT device, you’ll need more than the SBC itself. You’ll also need a microSD card to store the operating system, as well as other necessary device software and drivers. Of course, with the countless manufacturers, sizes, and specifications available at online retailers, it can be difficult to choose the right components for your project.

Here are some of the factors you need to consider when choosing a microSD for the Raspberry Pi.

How to Choose the Proper MicroSD Card For Your Raspberry Pi

You probably know microSD as a recording medium used in devices such as cameras and smartphones. It can also be used to expand the often limited memory of IoT devices enough to operate mission-critical programs.

When shopping for a microSD online, you will find a wide variety of specifications, though the two you’ll want to pay the most attention to are capacity and read/write speed. Capacity is how much you can store on the card, while read/write speed is how fast you can read and or write to the device’s memory.
thales-silva-hA04ltCQugs-unsplash-768x1024

For general Raspberry Pi IoT applications, a microSD with a capacity of 16-32GB and a speed class of C10 is sufficient. The device’s operating system requires a minimum capacity of 8GB for storage and a read/write speed of 10MB/s C10. A microSD of this size and rating more than meets these requirements, and can be easily found at a reasonable cost.

For burning the OS image onto the microSD card, you can do it easily with either Balena etcher or the Raspberry Pi imager. They are available for Windows, macOS and Linux, and can easily handle the installation on microSD cards sized 8GB and beyond.

Understanding Speed Classes on a MicroSD

Currently there are three standards for microSD speed classification

  1. Speed Class
  2. UHS Speed Class
  3. Video Speed Class

Each microSD has a marking that identifies the speed it can write to the device.

Table 1 below shows the maximum sequential write speed per class.

  • Speed Class HC, the C10 marking signifies that you can write up to 10MB/s. This is the optimum speed for a Raspberry Pi IoT application because higher read/write speeds are not needed.
  • The UHS speed class XC I, U10, U30 can read and write at 10 MB/s or as high as 30 MB/s respectively.
  • The Video Speed Class XC II, V90 can go up to 90MB/s, which is optimal for recording video, but not necessary for most IoT deployments.

Though these specifications can be confusing, if you pay attention to the number that follows the C, U or V in the description, you should be able to choose the right speed for your device.

The speed class not only affects the read/write speed, but also the operational rate of the device. While a speed class UHS U3 has faster writing speed, speed class HC C1 is perfectly usable in your Raspberry Pi IoT application – provided it is not capturing video. We don’t recommend HC CLASS 4 or CLASS 6, which were more common in older microSDs, because they are slower than optimal. You’ll want to stick to HC speed class C10 or higher for normal, non-video use.

The Hard Truth about MicroSDs

It’s important to note that MicroSDs have a limited usage life. The two most common failures you may experience with microSD cards are unexpected power failures and the threshold of rewrites as directed by the OS or device updates.

How to Deal with unexpected power failures in your MicroSD

An unexpected power failure could potentially damage or cause inconsistencies in the microSD. Fortunately, there are several ways you can configure the device to shut down normally when it detects a power failure. One way is by using a battery backup power supply or UPS, and another is by making the microSD a read-only RAM disk.

Threshold limitation of rewrites on microSDs

There is an upper limit to the number of times data can be accurately rewritten to NAND flash memory, the technology used to record data in MicroSD’s. As such, frequent writes will drastically shorten the lifespan of a microSD. One way to extend its life is to suppress the number of write cycles performed on the Raspberry Pi, a tactic commonly used in fleet deployments. Design techniques such as disabling swap, disabling journaling on the filesystem, the noatime mount flag, and having directories in RAM, will help reduce the number of write cycles to the SD card.

Sometimes when you deploy an IoT device, you may not be able to avoid writing to the permanent storage. In cases that require large amounts of data recording, you may want to consider using a more durable device for permanent storage such as an industrial eMMC. There are Raspberry Pi compatible boards that have an integrated eMMC such as the balenaFin, which allows users to deploy the Raspberry Pi Compute module, in their carrier board for industrial fleet deployments. The balenaFin provides additional storage and interface capabilities over that of a standard Raspberry Pi with a microSD.

Example Raspberry Pi Project

A great example of a project that utilizes Raspberry Pi, a microSD, and Soracom services, is the River monitoring flow meter (you can find the project details and code in the link), an internet-connected flow meter that continuously measures a river’s flow rate and makes real-time data available to users online.

This system can be deployed to remote rivers with a one-time setup and can be left to run on its own to automatically collect data without the need for users to be present. Multiple meters can be placed throughout a river to collect many points of data.

The Raspberry Pi IoT device collects measurements and that data is pushed to the cloud through the system’s cellular network connectivity, enabled by a Soracom Global SIM card and our LTE dongle. This data can be viewed online through Soracom Harvest, Soracom’s built-in data storage service. The data is also forked to AWS IoT by Soracom Funnel and then to CloudWatch services so that the system can send email notifications to users when the river’s flow rate reaches a critical level. All enabled by the microSD-empowered Raspberry Pi.

Raspberry Pi and MicroSDs Working Together

You may have been a little surprised by just how many factors are at play when trying to find the right microSD for your Raspberry PI IoT project. Reviewing microSD card manufacturers’ specifications, such as read/write cycles, speed class, and device storage size is important for your IoT project to work reliably.

1 Like

In my experience and extensive testing, and that of the engineers at Raspberry Pi Ltd., getting a application rated card gives the best longevity.

All cards without the “A” rating die much more frequently than any SanDisk “A” rated card.

Thank you for your input and experience in testing the Raspberry Pi using the newer A ratings. As the applications become more intense and requiring faster speeds, I’m sure it will all make the apps perform better. I’ll test out a few A1 and A1 cards to verify how they work with IoT.