Using a SPI flash breakout board with Arduino involves wiring up the flash chip to your Arduino-compatible microcontroller, installing the Adafruit_SPIFlash library and running the provided example code.


Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the flash breakout VIN.

Here is an Adafruit Metro wired up to the flash breakout using a solderless breadboard.

  • Board 5V to breakout VIN (red wire)
  • Board GND to breakout GND (black wire)
  • Board pin 10 to breakout CS (orange wire)
  • Board pin 11 to breakout MOSI (blue wire)
  • Board pin 12 to breakout MISO (green wire)
  • Board pin 13 to breakout SCK (yellow wire)

Library Installation

You can install the Adafruit SPIFlash library for Arduino using the Library Manager in the Arduino IDE.

Click the Manage Libraries ... menu item, search for Adafruit SPIFlash, and select the Adafruit SPIFlash library:

If asked about dependencies, click "Install all".

If the "Dependencies" window does not come up, then you already have the dependencies installed. 

If the dependencies are already installed, you must make sure you update them through the Arduino Library Manager before loading the example!

Example Code

// SPDX-FileCopyrightText: 2019 Ha Thach for Adafruit Industries
// SPDX-License-Identifier: MIT

// The MIT License (MIT)
// Copyright (c) 2019 Ha Thach for Adafruit Industries

#include <SPI.h>
#include <SdFat.h>

#include <Adafruit_SPIFlash.h>

#define CS_PIN 10

Adafruit_FlashTransport_SPI flashTransport(CS_PIN, SPI);
Adafruit_SPIFlash flash(&flashTransport);

// the setup function runs once when you press reset or power the board
void setup() {
  while (!Serial) {
    delay(100); // wait for native usb

  Serial.println("Adafruit Serial Flash Info example");

  Serial.print("JEDEC ID: 0x");
  Serial.println(flash.getJEDECID(), HEX);
  Serial.print("Flash size: ");
  Serial.print(flash.size() / 1024);
  Serial.println(" KB");

void loop() {
  // nothing to do

Upload the read/write sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the flash ID and size printed to the Serial Monitor.

This guide was first published on Nov 16, 2022. It was last updated on 2023-09-06 15:28:29 -0400.

This page (Arduino) was last updated on Sep 06, 2023.

Text editor powered by tinymce.