← Back to Projects
Project Featured

SPIMemory Docs

SPIMemory is an Arduino library for SPI Flash and SPI FRAM chips, with typed read/write APIs, erase controls, and diagnostics.

Published

What SPIMemory Is

SPIMemory is an Arduino library for external SPI memory chips (SPI Flash and SPI FRAM). It wraps low-level memory commands into direct APIs that are practical in production firmware.

Memory Types

SPI Flash + SPI FRAM

Primary API Surface

Typed read/write + erase + diagnostics

Quoted: “SPIMemory is an Arduino library for SPI Flash and SPI FRAM chips.”

Source: SPIMemory docs home

Core Capability Set

Identity and Setup

  • begin() initialization
  • Manufacturer and JEDEC identification
  • Capacity and page introspection

Typed Data IO

  • Primitives: byte, word, short, long, float
  • Buffers: byte/char arrays
  • Structured payloads via writeAnything / readAnything

Flash Operations

  • eraseSector
  • eraseBlock32K, eraseBlock64K
  • eraseChip

Reliability and Debugging

  • Write verification controls
  • error() and error(VERBOSE) diagnostics
  • Power and runtime helper functions

Where It Helps in Real Projects

In embedded projects, SPI command plumbing becomes repetitive quickly. SPIMemory keeps that out of your business logic.

Common use cases:

Persistent Settings

Store calibration, user prefs, and feature flags outside MCU internal EEPROM limits.

Telemetry and Logging

Log compact binary records with predictable address management for long-running nodes.

Field Firmware

Keep post-write checks enabled during bring-up to catch bus noise and wiring faults early.

External Memory Expansion

Add structured storage to boards where on-chip non-volatile memory is limited.

Hardware Coverage

From the upstream compatibility list, SPIMemory has been tested across common MCU families and boards including:

  • AVR (ATmega328P/32u4/2560)
  • SAMD21 / SAMD51
  • STM32
  • ESP8266 / ESP32
  • nRF52

It has also been tested with multiple flash families (Winbond, Microchip SST25/26, Cypress/Spansion S25FL, Macronix, Micron, and others), plus Cypress FM25W FRAM.

Quoted: “Should work with any flash memory that is compatible with the SFDP standard as defined in JESD216B”

Source: SPIMemory README

Docs and Source

https://chipsncode.com/SPIMemory/

Use the docs for quick start wiring, API lookup, and troubleshooting flow.

#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(VERBOSE), HEX);
    return;
  }

  Serial.print("JEDEC ID: 0x");
  Serial.println(flash.getJEDECID(), HEX);

  uint32_t addr = flash.getAddress(sizeof(uint32_t));
  flash.eraseSector(addr);

  flash.writeULong(addr, 123456789UL);      // typed write
  uint32_t out = flash.readULong(addr);     // typed read

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