Skip to content

Quick Start

Who this is for

If you are new to Arduino external memory chips, start here.

For a step-by-step first session, use First Hour Setup.

1. Install the library

Arduino Library Manager

  1. Open Arduino IDE.
  2. Go to Sketch > Include Library > Manage Libraries.
  3. Search for SPIMemory.
  4. Install latest version.

ZIP install

  1. Download repository ZIP.
  2. Rename extracted folder to SPIMemory.
  3. Move it to your Arduino libraries folder.

2. Wire the chip

Connect at minimum:

  • SCK
  • MISO
  • MOSI
  • CS (chip select)
  • VCC
  • GND

For flash chips, ensure HOLD and WP pins are pulled to valid logic levels as required by datasheet.

3. First flash sketch

#include <SPIMemory.h>

SPIFlash flash(10); // CS pin

void setup() {
  Serial.begin(115200);

  if (!flash.begin()) {
    Serial.print("begin failed, err=0x");
    Serial.println(flash.error(), HEX);
    return;
  }

  uint32_t addr = 0;
  flash.eraseSector(addr);

  flash.writeULong(addr, 123456789UL);
  uint32_t out = flash.readULong(addr);

  Serial.print("Read: ");
  Serial.println(out);
}

void loop() {}

4. Validate using bundled examples

Recommended beginner order:

  1. examples/FlashDiagnostics/FlashDiagnostics.ino
  2. examples/readWriteString/readWriteString.ino
  3. examples/getAddressEx/getAddressEx.ino
  4. examples/Struct_writer/Struct_writer.ino

Use Example Sketches Guide for a full breakdown of what each sketch tests, what success looks like, and how to use failures for troubleshooting.

5. If it fails