Module 3.5: SD Cards

In Module 3.5, we begin with the basics of SD cards in all their wonderful form factors and flavors. We discuss the technology that makes SD cards possible, the types of memory cards, the form factors, their reliability, and power consumption. We also discuss what all those little numbers you normally ignore on your SD card mean, like read speed, card type, speed class, UHS speed class, and bus speed.

Once that’s done, we talk about file systems and why they’re needed. We go into how a file system fits on top of SD cards, how it organizes the bulk storage on an SD card, and the different types of file systems including FAT32 and exFAT.

In the lab portion, we’ll learn how we access the SD card on the WildLogger, installing the Arduino library to control our SD cards, and how easy it is to implement a system that can access multiple SD cards. We learn how to create and open files for reading, writing, or appending, how to read and write to a file, and things to watch out for to prevent file corruption. We implement a mini DOS system (Wild-DOS?) with commands to list files in a directory, and read, write, and delete files. Finally we finish off by implementing a command to write timestamped sensor data and files to our SD card.

Click here for video slides, terminology, downloads and additional references

 

3.5.1  Reading and Writing to the SD Card

In this video we cover:

  • differences between common memory cards
    • Secure Digital (SD) versus Multimedia Cards (MMC) versus CompactFlash (CF)
  • selecting a memory card
    • application requirements
    • deployment conditions
    • card features including power consumption and endurance
    • budget
  • what the symbols mean including
    • storage
    • card types – SD, SDHC, SDXC, SDUX
    • sizes – Full SD, miniSD, microSD
    • read speed
    • video speed class
    • UHS Bus speed
    • speed class,
    • UHS speed class
  • Endurance or number of program / erase cycles and their impact on the life-span of the SD card
  • SLC, MLC and TLC flash types and how they impact life-span of the memory card
  • consumer versus industrial SD cards

3.5.1 – Reading and Writing to the SD Card (PDF)

 

 

3.5.2  The FAT File System and Reading / Writing Our First Files – Lab 1

In this video we cover:

  • file systems and how they work
  • differences between FAT 12, FAT 16, FAT32 and exFAT file systems
  • memory segments and clusters
  • file naming

In the Lab, we’ll install the sdFat library and initialise an sdFat object. Then we’ll create and open a file, save data to the file, and read the data via the serial monitor.

3.5.2: The FAT File System and Reading / Writing Our First Files – Lab 1 (PDF)

 

 

3.5.3 Did I Just Create MS-DOS? – Lab 2

In this video we dive straight into Lab 2. We’ll create commands to write and read a sensor reading to a file, delete a file, and list all the files in a directory.

3.5.3: Did I Just Create MS-DOS? – Lab 2 (PDF)

 

 

3.5.4 Did I Just Create A Data Logger? – Lab 3

In this video we dive straight into Lab 3. We’ll add date and time stamps to our files and sensor readings. We’ll also add an LED warning indicator to tell us if the SD card isn’t inserted, or isn’t initialising properly.

3.5.4: Did I Just Create a Data Logger? – Lab 3 (PDF)

 

 

Supporting Materials

Terminology Sheet

Module 3.5 Terminology Cheatsheet (PDF)

 

Video Slides

3.5.1 – Reading and Writing to the SD Card (PDF)

3.5.2: The FAT File System and Reading / Writing Our First Files – Lab 1 (PDF)

3.5.3: Did I Just Create MS-DOS? – Lab 2 (PDF)

3.5.4: Did I Just Create a Data Logger? – Lab 3 (PDF)

 

Reformatting an SD Card

Formatting a microSD card to FAT32 – Windows

Formatting a microSD card to FAT32 – Mac

 

Conversations & Troubleshooting

Module 3.5 Discussion (forum thread)

 

Useful References

SD Card Symbols Meanings – Reference 1

SD Card Symbols Meanings – Reference 2

Choose The Right SD Card

Explanation of Different Kinds of Flash Memory

Flash Memory Guide (from Kingston Manufacturer – PDF)

Physical Structure of Flash

How It works – NAND Flash Technology Basics

microSD Card Power Consumption Comparison

Tech Republic – FAT File System

FAT explained

FAT File Systems – Clusters

Unsigned Integers


Copy link