MicroSD card adapter module Arduino Uno
In this tutorial, we will introduce how to use the MicroSD card adapter module and the Arduino Uno development board to read and write SD cards. The main advantage of this module is that it can be used with the SD library that comes with the Arduino IDE. The SD library makes it very easy to initialize, read, and write to the card.
List of Materials Required:
– Arduino Uno development board
– Jumper wires
– MicroSD card adapter module
– MicroSD card
How to connect a MicroSD Card Adapter Module to an Arduino Uno?
The module has a voltage regulator onboard. Hence, the 5V and 3.3V pins of the Arduino can be used as a power source. The module communicates with the Arduino Uno via SPI (Serial Peripheral Interface). The following table shows the complete pin connections.
How do I program an SD card reader?
As mentioned before, reading and writing SD cards is very simple when using the standard SD library of the Arduino IDE. Make sure to use the latest version of the SD library ( Sketch-> Include Library-> Manage Libraries -> search for “SD”). For example, version 1.1.0 does not work with the module in this article. Fortunately, version 1.1.1 works fine. In addition, the SD card must be formatted as FAT16 or FAT32. If something does not work as expected, always upload the library’s CardInfo example (File -> Examples-> SD-> CardInfo) to the Arduino when debugging and read the messages of the serial monitor.
In the code for this article, a random number between 0 and 9 is written to the SD card. The number is written to a file called “file.txt”. Next, the contents of “file.txt” are read. At the end of the loop function, a 5 second delay is added. Note that when the Arduino is started, a check is made to see if a file called “file.txt” exists. If it does, the file is deleted.
If everything went well, the serial monitor should show similar output as shown in the following screenshot: