You're probably familiar with SRAM, DRAM, EEPROM and Flash but what about FRAM? FRAM is 'ferroelectric' RAM, which has some very interesting and useful properties. Unlike SRAM, FRAM does not lose the data when power is lost. In that sense it's a durable storage memory chip like Flash. However, it is much faster than Flash - and you don't have to deal with writing or erasing pages.
This particular FRAM chip has 64 Kbits (8 KBytes) of storage, interfaces using SPI, and can run at up to 20MHz SPI rates. Each byte can be read and written instantaneously (like SRAM) but will keep the memory for 95 years at room temperature. Each byte can be read/written 10,000,000,000,000 times so you don't have to worry too much about wear leveling.
With the best of SRAM and Flash combined, this chip can let you buffer fairly-high speed data without worrying about data-loss.


The FRAM chip is the little guy in the middle. On the bottom we have the power and interface pins

Power Pins:

  • VCC - this is the power pin. Since the chip uses 3-5VDC you should pick whatever the logic voltage you're using. For most Arduino's that's 5V.
  • GND - common ground for power and logic

SPI Logic pins:

All pins are 3-5V compliant and use whatever logic level is on VCC
  • HOLD - this is a 'wait' pin for the SPI bus. When pulled low, it puts the SPI bus on hold. This is different than the CS pin because it doesnt stop the current transaction. Its good if you want to talk to other SPI devices and stream data back and forth without stopping and starting transactions.
  • SCK - This is the SPI clock pin, its an input to the chip
  • MISO - this is the Master In Slave Out pin, for data sent from the FRAM to your processor
  • MOSI - this is the Master Out Slave In pin, for data sent from your processor to the FRAM
  • CS - this is the chip select pin, drop it low to start an SPI transaction. Its an input to the chip
  • WP - Write Protect pin. This is used to write protect the status register only! This pin does not directly affect write protection for the entire chip. Instead, it protects the block-protect register which is configured however you want (sometimes only half the FRAM is protected)


Prepare the header strip:

Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down

Add the breakout board:

Place the breakout board over the pins so that the short pins poke through the breakout pads

And Solder!

Be sure to solder all pins for reliable electrical contact.

(For tips on soldering, be sure to check out our Guide to Excellent Soldering).
You're done! Check your solder joints visually and continue onto the next steps

Arduino Test

Arduino Wiring

Woops, the above has VCC and GND both connected to ground - Instead, connect VCC to the red power rail!

You can easily wire this breakout to any microcontroller, we'll be using an Arduino
  • Connect Vcc to the power supply, 3V or 5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
  • Connect GND to common power/data ground
  • Connect the SCK pin to the SPI clock pin on your Arduino. We'll be using Digital #13 which is also the hardware SPI pin on an Uno
  • Connect the MISO pin to the SPI MISO pin on your Arduino. We'll be using Digital #12 which is also the hardware SPI pin on an Uno.
  • Connect the MOSI pin to the SPI MOSI pin on your Arduino. We'll be using Digital #11 which is also the hardware SPI pin on an Uno.
  • Connect the CS pin to the SPI CS pin on your Arduino. We'll be using Digital #10 but any pin can be used later

Download Adafruit_FRAM_SPI

To begin reading and writing data, you will need to download Adafruit_FRAM_SPI from our github repository. You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip
Rename the uncompressed folder Adafruit_FRAM_SPI and check that the Adafruit_FRAM_SPI folder contains Adafruit_FRAM_SPI.cpp and Adafruit_FRAM_SPI.h

Place the Adafruit_FRAM_SPI library folder your arduinosketchfolder/libraries/ folder.
You may need to create the libraries subfolder if its your first library. Restart the IDE.

We also have a great tutorial on Arduino library installation at:

Load Demo

Open up File->Examples->Adafruit_FRAM_SPI->MB85RS64V and upload to your Arduino wired up to the sensor
Thats it! Now open up the serial terminal window at 9600 speed to begin the test.

The test is fairly simple - It first verifies that the chip has been found. Then it reads the value written to location #0 in the memory, prints that out and write that value + 1 back to location #0. This acts like a restart-meter: every time the board is reset the value goes up one so you can keep track of how many times its been restarted.

Afterwards, the Arduino prints out the value in every location (all 8KB!)

Library Reference

The library we have is simple and easy to use

Hardware vs Software SPI

You can create the FRAM object using software-SPI (each pin can be any I/O) with
or use hardware SPI
Adafruit_FRAM_SPI fram = Adafruit_FRAM_SPI(FRAM_CS);
which means the other 3 pins are the hardware SPI defined pins for your chip. Check the SPI Reference page for details on which pins are which for your Arduino!

Hardware SPI is faster (the chip can handle up to 20MHz), but you have to use fixed pins. Software SPI is not as fast (maybe 1MHz max on an UNO), but you can switch pins around.


You can initialize the SPI interface and chip with begin()
It will return true or false depending on whether a valid FRAM chip was found


Then to write a value, call
fram.write8(address, byte-value);

to write an 8-bit value to the address location
Later on of course you can also read with
which returns a byte reading. For writing, you must enable writing before you send data to the chip, its for safety! However you can write as much as you want between the writeEnable calls

Block Protection

We dont cover how to protect subsections of the FRAM chip. It's covered a bit more inside the Datasheet.
For advanced users, we have two functions to set/get the Status Register. IF you want to set the status register dont forget that WP must be logical high!
uint8_t getStatusRegister();
setStatusRegister(uint8_t value);


It's easy to use the SPI FRAM Breakout with Python or CircuitPython and the Adafruit CircuitPython FRAM module.  This module allows you to easily write Python code that reads the humidity, temperature, pressure, and more from the sensor.

CircuitPython Microcontroller Wiring

First we'll wire up a SPI FRAM Breakout to a microcontroller, as was shown in the Arduino Test page.

Here is an example of wiring the breakout to a Feather M0 Basic:

  • Board 3V to sensor VIN
  • Board GND to sensor GND
  • Board SCK to sensor SCK
  • Board MOSI to sensor MOSI
  • Board MISO to sensor MISO
  • Board D5 to sensor CS

If you'd like to use the hardware write protection, connect another GPIO to the sensor's WP pad, like so:

  • Board 3V to sensor VIN
  • Board GND to sensor GND
  • Board SCK to sensor SCK
  • Board MOSI to sensor MOSI
  • Board MISO to sensor MISO
  • Board D5 to sensor CS
  • Board D6 to sensor WP
The CircuitPython library takes advantage of the software level write protection on the SPI FRAM chip, so using the hardware write protection isn't necessary. However, the hardware write protection could be useful with an external source of control, like a separate microcontroller.

CircuitPython Installation of FRAM Library

You'll need to install the Adafruit CircuitPython FRAM library on your CircuitPython board.

First make sure you are running the latest version of Adafruit CircuitPython for your board.

Next you'll need to install the necessary libraries to use the hardware--carefully follow the steps to find and install these libraries from Adafruit's CircuitPython library bundle.  Our CircuitPython starter guide has a great page on how to install the library bundle.

For non-express boards like the Trinket M0 or Gemma M0, you'll need to manually install the necessary libraries from the bundle:

  • adafruit_fram.mpy
  • adafruit_bus_device

Before continuing make sure your board's lib folder or root filesystem has the adafruit_fram.mpy, and adafruit_bus_device files and folders copied over.

Next connect to the board's serial REPL so you are at the CircuitPython >>> prompt.

CircuitPython Usage

To demonstrate the usage of the breakout we'll initialize it, write data to the FRAM, and read that data from the board's Python REPL.

Run the following code to import the necessary modules and initialize the SPI connection with the breakout:

Download: file
import board
import busio
import digitalio
import adafruit_fram
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D5)
fram = adafruit_fram.FRAM_SPI(spi, cs)

Or, if you're using the hardware write protection:

Download: file
import board
import busio
import digitalio
import adafruit_fram
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D5)
wp = digitalio.DigitalInOut(board.D6)
fram = adafruit_fram.FRAM_SPI(spi, cs, wp_pin=wp)

Now you can write or read to any address locations:

Download: file
fram[0] = 1


Reading the FRAM returns a bytearray. To get a "raw" value, use the index of the value's location. Some various ways to get values are as such:

Full Example Code

## Simple Example For CircuitPython/Python SPI FRAM Library

import board
import busio
import digitalio
import adafruit_fram

## Create a FRAM object.
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D5)
fram = adafruit_fram.FRAM_SPI(spi, cs)

## Write a single-byte value to register address '0'

fram[0] = 1

## Read that byte to ensure a proper write.
## Note: 'read()' returns a bytearray


## Or write a sequential value, then read the values back.
## Note: 'read()' returns a bytearray. It also allocates
##       a buffer the size of 'length', which may cause
##       problems on memory-constrained platforms.

#values = list(range(100)) # or bytearray or tuple
#fram[0] = values


This guide was first published on May 23, 2014. It was last updated on May 23, 2014.