► Games

► Sound & Music

► Watches & Clocks


► Power Supplies

► Computers

► Graphics

► Thermometers

► Wearables

► Test Equipment

► Tutorials

► Libraries

► PCB-Based Projects

By processor

AVR ATtiny

► ATtiny10

► ATtiny2313

► ATtiny84

► ATtiny841

► ATtiny85

► ATtiny861

► ATtiny88

AVR ATmega

► ATmega328

► ATmega1284

AVR 0-series and 1-series

► ATmega4809

► ATtiny1604

► ATtiny1614

► ATtiny3216

► ATtiny3227

► ATtiny402

► ATtiny404

► ATtiny414

► ATtiny814

AVR DA/DB-series

► AVR128DA28

► AVR128DA32

► AVR128DA48

► AVR128DB28



► RP2040

► RA4M1

About me

  • About me
  • Twitter
  • Mastodon


RSS feed

Adding File Storage to an Arduino

4th June 2022

If you want to add a filing system to an Arduino Uno, here's a neat trick you can do with Adafruit's 512Mbyte SPI Flash SD Card board [1]:


Fitting Adafruit's 512Mbyte SPI Flash SD Card board directly to an Arduino Uno.

The pins happen to line up perfectly with the SPI pins on an Arduino Uno, so you can just plug the card in to the header without needing any wiring.


Adafruit's 512Mbyte SPI Flash SD Card board [2] provides an SD card filing system on a board that costs less than the cost of an SD Card socket and an SD card, and is more robust for permanently mounting in a project. Plug it into the Arduino header, making sure that the GND pin lines up with the GND socket on the Arduino. The four SPI pins will then line up with the SPI pins on the Arduino: SCK (13), (MISO) 12, MOSI (11) and CS (10).

What about 3V3 and VIN? The 3V3 output from the board lines up with the AREF input on Arduino boards which isn't a problem. The VIN pin of the SPI SD Card board lines up with the SDA pin on the Arduino, so we can use this to provide power to the board with a couple of statements in setup(). The board only draws about 5mA so this is well within the drive capability of the I/O line. The only downside is that you will not be able to use I2C when the board is in use.

This trick will also work with other microcontroller boards that have the SPI pins in these positions, including the Adafruit Metro 328 [3] and Arduino Uno clones.

If you'd prefer not to have the SPI SD Card board extending outside the area of the Arduino just solder the header pins the other way up, and mount the board the other way round with the components facing downwards.

Demo program

Here's a simple demo program:

#include <SD.h>

File myFile;

void setup() {
  // Provide power to module on SDA pin
  pinMode(SDA, OUTPUT);
  digitalWrite(SDA, HIGH);

void loop() {
  myFile ="JIMMY", O_RDWR | O_CREAT | O_TRUNC);
  myFile.write("Hello from Technoblogy");
  myFile ="JIMMY", O_READ);
  while (myFile.available()) {

You may wonder why I've opened the file with:

  myFile ="JIMMY", O_RDWR | O_CREAT | O_TRUNC);

The answer is that the usual option FILE_WRITE appends to the end of the file, which I think is less useful, so I've used the option that writes to a new file each time.

  1. ^ SPI Flash SD Card on Adafruit.
  2. ^ SPI Flash SD Card on Adafruit.
  3. ^ Adafruit Metro 328 on Adafruit.

blog comments powered by Disqus