When an Arduino project needs to store data over a long period, the board's internal memory quickly becomes a limitation. A weather station, for example, may need to record temperature and humidity every few seconds. A soil-monitoring system might need to keep readings for several days.
A MicroSD card is a simple way to add external storage to such projects. With a small MicroSD card module, an Arduino UNO can read and write files on a memory card using the SPI interface.
In this tutorial, we'll connect a MicroSD card module to an Arduino UNO and use it to access files on the card. An I2C LCD is also used to display information from the card.
What You Need
For this project, you'll need:
- Arduino UNO R3
- MicroSD card module
- MicroSD card
- 16x2 LCD with I2C interface
- Jumper wires
- USB cable for Arduino UNO
- Arduino IDE
- 5V power supply, if required
Understanding the MicroSD Card Module
A typical Arduino MicroSD card module contains more than just the card socket.
It generally includes a 3.3V voltage regulator and a logic-level conversion circuit so that it can be used with 5V Arduino boards.
The MicroSD card itself operates at approximately 3.3V. The regulator on compatible modules converts the incoming supply to the required voltage for the card.
The logic-level circuitry is used to translate the SPI signals between the Arduino's 5V logic and the SD card's lower-voltage logic.
Because different MicroSD modules are available, it's worth checking the schematic or markings of your particular module before applying power.
MicroSD Module Pins
Most of the common SPI-based MicroSD modules provide these pins:
| Module Pin | Function |
|---|---|
| VCC | Power supply |
| GND | Ground |
| MISO | Data from SD card to Arduino |
| MOSI | Data from Arduino to SD card |
| SCK | SPI clock |
| CS | Chip Select |
The SD card communicates with the Arduino through the SPI bus. On an Arduino UNO, the hardware SPI pins are:
- MOSI — D11
- MISO — D12
- SCK — D13
The CS pin can be assigned to a suitable digital pin. In this example, we'll use D10.
Connecting the MicroSD Module to Arduino UNO
Connect the module as follows:
| MicroSD Module | Arduino UNO |
|---|---|
| CS | D10 |
| SCK | D13 |
| MOSI | D11 |
| MISO | D12 |
| VCC | 5V* |
| GND | GND |
*The 5V connection assumes you are using a MicroSD module specifically designed with the appropriate regulator/level shifting for 5V Arduino boards. Do not connect 5V directly to a bare MicroSD card.
The SPI connections are straightforward because the Arduino UNO has dedicated hardware SPI pins.
Adding the I2C LCD
The LCD is connected through the Arduino UNO's I2C interface.
For an UNO:
| I2C LCD | Arduino UNO |
|---|---|
| VCC | 5V |
| GND | GND |
| SDA | A4 |
| SCL | A5 |
Many 16x2 I2C LCD modules use 0x27 as their default address, but this isn't universal. If the LCD doesn't respond, scanning the I2C bus is a good way to find its actual address.
Also check the address-selection jumpers on your LCD backpack if your particular module provides them.
Arduino Libraries
You can use the built-in SD and SPI libraries for the MicroSD card.
For the LCD, install the LiquidCrystal_I2C library.
In Arduino IDE:
- Open Library Manager.
- Search for
LiquidCrystal I2C. - Install the library you intend to use.
- The SD and SPI libraries are normally included with the Arduino AVR core.
Using a MicroSD Card for Data Logging
This is where the MicroSD module becomes particularly useful.
Suppose you're building an environmental monitoring system with a temperature and humidity sensor. Instead of keeping only the latest measurement in RAM, the Arduino can periodically append each measurement to a file.
A typical workflow would be:
Sensor
↓
Arduino UNO
↓
SPI
↓
MicroSD Module
↓
Data File
The file could contain one measurement per line, making it relatively easy to process later on a computer.
The same approach can be used for:
- Weather stations
- Soil-moisture monitoring
- Energy monitoring
- GPS data logging
- Industrial sensor logging
- Temperature monitoring
- Motion/event recording
- IoT prototypes with offline data storage
A Few Things to Check When the SD Card Doesn't Work
MicroSD modules can sometimes be surprisingly sensitive during initial setup. If the Arduino reports that the card initialization failed, check these points before changing the code.
Check the CS pin first. The pin defined in the program must match the physical connection. In this example, it is D10.
Check the SPI wiring. On an Arduino UNO, MOSI is D11, MISO is D12 and SCK is D13.
Check the card format. An incorrectly formatted or incompatible card can prevent initialization.
Try another MicroSD card. Some cards work more reliably than others with older Arduino libraries and hardware.
Check the module's voltage arrangement. Not every MicroSD breakout is designed to accept 5V directly. Verify that your particular board includes the required regulator and level shifting.
Keep the SPI wires short. Long jumper wires can introduce communication problems, especially on breadboards.
Final Thoughts
Adding a MicroSD card gives an Arduino project a practical way to store much more data than the microcontroller's internal memory can hold.
The SPI interface keeps the wiring simple, and the Arduino SD library provides the basic functions needed to initialize the card, create files, read data, and write new records.
Once the basic interface is working, you can extend the project into a complete data logger by connecting sensors and periodically saving their readings to the SD card.
If you want to follow the complete project and source-code implementation, you can find the detailed tutorial on Play with Circuit.

Top comments (0)