Arduino MKR WiFi 1010 - SD Card
Arduino MKR WiFi 1010 - SD Card
Need data storage with your Arduino MKR WiFi 1010? In this tutorial, you'll use a Micro SD card module to read and write files with the Arduino MKR WiFi 1010.
What you'll learn (Arduino MKR WiFi 1010 + Micro SD Card):
- Connecting a Micro SD card module to the Arduino MKR WiFi 1010
- Programming the Arduino MKR WiFi 1010 to create and open files on SD card
- Writing data to files on Arduino MKR WiFi 1010 SD card
- Reading files from SD card with Arduino MKR WiFi 1010
- Appending and overwriting files on Arduino MKR WiFi 1010
Real-world uses for Arduino MKR WiFi 1010 and Micro SD Card:
- Data logging (Arduino MKR WiFi 1010 saving sensor data)
- File storage (Arduino MKR WiFi 1010 for configurations)
- Media playback (Arduino MKR WiFi 1010 reading audio/files)
- Offline data collection on Arduino MKR WiFi 1010
You'll see the Arduino MKR WiFi 1010 perform various SD card operations like writing and reading files.

Hardware Preparation
| 1 | × | Arduino MKR WiFi 1010 | |
| 1 | × | Micro USB Cable | |
| 1 | × | Micro SD Card | |
| 1 | × | Micro SD Card Module | |
| 1 | × | Jumper Wires | |
| 1 | × | Breadboard | |
| 1 | × | Optionally, MicroSD to SD Memory Card Adapter |
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (30 sensors/displays) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of Micro SD Card Module
The Micro SD Card Module allows the Arduino MKR WiFi 1010 to read and write data to a Micro SD card using SPI communication.
Pinout
The Micro SD card module has these pins:
- VCC: Power pin (5V)
- GND: Ground pin
- MISO: SPI data from SD to Arduino MKR WiFi 1010
- MOSI: SPI data from Arduino MKR WiFi 1010 to SD
- SCK: SPI clock pin
- SS: Slave select pin

Preparation
- Insert the Micro SD card into a USB card reader and connect to your computer.
- Ensure the Micro SD card is formatted as FAT16 or FAT32.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
Arduino MKR WiFi 1010 - How to open a file on Micro SD Card and create if not existed
Arduino MKR WiFi 1010 Code
Detailed Instructions
New to Arduino MKR WiFi 1010? Complete our Getting Started with Arduino MKR WiFi 1010 tutorial first to set up your development environment.
- Insert the Micro SD Card into the module.
- Connect the module to the Arduino MKR WiFi 1010 as shown in the wiring diagram.
- Plug your Arduino MKR WiFi 1010 into your computer's USB port.
- Open the Arduino IDE.
- Select the Arduino MKR WiFi 1010 board and correct COM port.
- Copy the code and paste it into a new sketch.
- Click Upload to compile and upload to the Arduino MKR WiFi 1010.
- Open the Serial Monitor.
- View the SD card operation results.
- Upload the code again and check the Serial Monitor for the next test results.
※ NOTE THAT:
You might not see any output on the Serial Monitor the first time because you uploaded your code before opening it.
- Remove the Micro SD Card from the module.
- Insert the Micro SD Card into a USB SD Card reader.
- Connect the USB SD Card reader to your computer.
- Verify that the file was created on the SD card.
Arduino MKR WiFi 1010 - How to write/read data to/from a file on Micro SD Card
This code demonstrates:
- Writing data to a file on the Micro SD Card
- Opening the file and reading it character by character
- Displaying the file contents on the Serial Monitor
The Serial Monitor displays the file contents:
※ NOTE THAT:
By default, data is appended to the end of the file. If you restart the Arduino MKR WiFi 1010 with the code above, the text will be added again, and the Serial Monitor will show additional lines:
You can remove the Micro SD Card from the module and view it on your computer using a USB SD Card reader to verify the file contents.
Arduino MKR WiFi 1010 - How to read a file on Micro SD Card line-by-line
The Serial Monitor displays:
※ NOTE THAT:
If you haven't cleared the file contents first, you may see additional lines on the Serial Monitor from previous writes.
Arduino MKR WiFi 1010 - How to overwrite a file on Micro SD Card
Normally, new data is appended to the end of the file. To overwrite a file, the simplest approach is to delete the existing file and create a new one with the same name.
The Serial Monitor displays:
- Restart the Arduino MKR WiFi 1010 and verify the file content is replaced (not appended) in the Serial Monitor.
- You can remove the Micro SD Card from the module and view it on your computer using a USB SD Card reader to confirm the file was overwritten.
Troubleshooting
- SD card not initialized: Check SPI connections and SD card format (FAT16/FAT32).
- File not found: Ensure file exists or is created; check SD card.
- No data written: Verify write permissions and SD card space.
- Garbled data: Check baud rate and Serial Monitor settings.
Challenge Yourself - Creative Customizations
Once SD card works with your Arduino MKR WiFi 1010, try these extensions:
Quick Variations
- Log sensor data to SD card from Arduino MKR WiFi 1010.
- Read configuration files from SD card on Arduino MKR WiFi 1010.
Advanced Features to Try
- Implement file system navigation on Arduino MKR WiFi 1010.
- Compress data before writing to SD card with Arduino MKR WiFi 1010.
- Use SD card for firmware updates on Arduino MKR WiFi 1010.
- Create a data logger with timestamps using RTC and SD card on Arduino MKR WiFi 1010.