SD memory cards are a great storage medium, as they have a large capacity at a low cost and small size. Also, you have some old unused units at home; As in the Arduino SD card moduleyou will only need a little memory. It will indeed work for you. On the other hand, they can be removed to upload data to a PC and quickly reconnected to data logging equipment. These types of storage are easy to access from Arduino.

If you prefer to use microSD cards, you should check out our SD card adaptor. It supports SD (SDSC, Standard Capacity) or SDHC (High Capacity) cards but not SDXC (Extended Capacity). The format used must be FAT16 or FAT32.

This Arduino SD card module incorporates an internal voltage regulator so that you can feed it at 5V without problems. Although this module also allows you to provide it at 3.3V through the corresponding pin (in this case, do not connect the 5V pin).

Is it easy to work with SD cards or SD card adaptors?

SD cards are the most used portable devices due to their large capacity and small size. Due to their great demand, they are easy to obtain in different degrees and prices. These characteristics give us a good storage alternative in Arduino, especially when we need to save a large amount of information. These come in three sizes, standard SD, Mini SD and Micro SD, the latter being the most common size, functionally, they are the same, and adapters can be used to use them in sockets of different sizes.

SD sizes: 

Regarding the format, we can find four types, SD or SDSC (Standard Capacity), SDHC (High Capacity), SDXC (Extended Capacity) and SDIO (Input/Output) cards, allowing Arduino SD card module to work with the first two types. We can use any of these two modules:

  1. Micro SD Module

    Allows us to insert a Micro SD memory that is the most common on the market. The module can be powered with 3.3V or 5V using the respective pins.

  1. SD card module

    This module has a large socket for standard-size SD memories, but we can use an SD card adapter to use micro SD memories. Arduino has a library to use these recollections, which works with any Arduino SD card module. The library already has the Arduino IDE, so we don’t need to install or download anything.

Functions of the SD library:

Below we explain the main functions of the SD library, which is a summary of the reference provided:

SD.begin (cspin)

Initializes the SD library and the card, the CS pin to which the module is connected is indicated as a parameter, if cspin is not specified, the default hardware CS value is used. The other pins must be connected to the SPI by the hardware of the Arduino.

SD.exists (filename)

Checks if the specified file exists, filename is the file’s name and directory on the SD card. If it exists, the function returns true. Otherwise, it returns false.

SD.mkdir (directory)

Creates the specified directory. If the sub directories do not exist, they will be produced as well. The function returns true if the directory creation was successful. Otherwise, it returns false.

SD.remove (filename)

Delete the file (filename) from the SD card. The directory must be included. It only deletes the file but not the directory. It returns true if it succeeds in deleting the file.

SD.rmdir (dirname)

Delete the directory (dirname) from the SD card. The directory must be empty. Returns true if the directory removal was successful, false otherwise.

SD.open (filepath, mode)

Opens the specified file and must include the directory if the file is in folders. If the file does not exist, a file with the specified name will be created, but it will not be possible to make the directory if it does not exist. A file can be opened as read-only (if the mode is FILE_READ) or as read-and-write (if the mode is FILE_WRITE). The default mode, if not specified, is FILE_READ.

Functions of the File class:

file.available()

It checks if bytes can read from the file and returns the number of bytes available.

file.read()

Read a byte from the File variable (file previously opened with SD.open())

file.write(data)

Writes a byte to the file. The file must be open in read-and-write mode. Using file. write (buf, len), you can write a byte array (buf), but you must specify the size (len).

file.print(data)

This function has the same characteristics as a Serial. Print (); data can be a variable or text, which will be sent as characters. If we want to add a break or a new line at the end, we use the file.println(data)

file.size()

Returns the size in bytes of the file

file.position()

Returns the current position where the next byte will be read or written.

file.seek(pos)

We are located in a specific position in the file. Pos must be a number between 0 and the file size in bytes.

file.close()

We close the file, and at this moment, we save the data in the SD, being able to extract our SD safely.

If you have any questions about the Arduino SD card module, get in touch.