Skip to content

Flash Memory TinyShield

This TinyShield lets you add robust, lightning-fast storage memory to your TinyDuino project. Built around the Winbond W25Q80DV, this board is a simple way to store settings, logs, or any other data your project needs to keep through power cycles.

To learn more about the TinyDuino Platform, click here


Description

The Flash Memory TinyShield is low power and works through the SPI interface. It has 1 MB of storage and is byte addressable.  Example code is provided to make it simple to add flash memory support to your projects.  

To learn more about the TinyDuino Platform, click here

Technical Details Winbond W25Q80DV Flash Specs
  • 1024K x 8 (8 Mbit)
  • 256-Byte Page Write Buffer
  • Page Write Time 0.8 ms typical
  • Write Endurance: 100,000
  • Data Retention: 20+ Years
TinyDuino Power Requirements
  • Voltage: 2.7V - 5.5V 
  • Current:
    • Standby: 10uA
    • Read: 7mA
    • Write: 20mA
    • Due to the low current, this board can be run using the TinyDuino coin cell option.
Pins Used
  • 05 - SPI_CS:This signal is the SPI chip select for the flash memory.
  • 11 - MOSI: This signal is the serial SPI data out of the TinyDuino and into the flash memory.
  • 12 - MISO: This signal is the serial SPI data out of the flash memory and into the TinyDuino.
  • 13 - SCLK: This signal is the serial SPI clock out of the TinyDuino and into the flash memory.
Dimensions
  • 20mm x 20mm (.787 inches x .787 inches)
  • Max Height (from lower bottom TinyShield Connector to upper top TinyShield Connector): 5.11mm (0.201 inches)
  • Weight: 1.11 grams (.039 ounces)

Notes

  • The "Write-Protect" feature has been permanently disabled for this chip. 

Materials

Hardware materials

Hardware

Software


Hardware Assembly

To assemble your TinyDuino stack, you just need to connect the Flash Memory TinyShield to the processor board of your choice using the tan 32-pin connector. Here, we use the TinyZero:

An assembled stack of a TinyZero and Flash Memory TinyShield


Software setup

You will need the SPI Memory library to use the example program included in this tutorial. Both the library and the example program are included under the Software section above in zip files.

The library (after it's unzipped) will need to be relocated under the \Arduino\libraries folder so that the example program can find and use the library when it is opened in the Arduino IDE. For Mac and Window users, the Arduino folder is automatically saved under your Documents folder.

Special Thanks to Marzogh for this well documented library!


Upload Program

Code
/*
  TinyCircuits Flash Memory TinyShield Example Sketch

  This is an example of how to write to and read data from the Winbond W25Q80DV
  I2C Flash Memory using the SPIFlash library. Whole page write functions are
  not used. This example will specifically be using the writeByte/readByte
  functions. Documentation on functions for other data types can be found on
  the library's Github page.
  SPIFlash is authored by Marzogh: https://github.com/Marzogh/SPIFlash
  Written 19 January 2017
  By Lilith Freed
  Modified 07 January 2019
  By Hunter Hykes
  https://TinyCircuits.com
*/

#include <SPIFlash.h>

// Decide what Serial port to use!
#ifdef ARDUINO_ARCH_SAMD
  #define SerialMonitor SerialUSB // Our TinyScreen+ is an SAMD board.
#else
  #define SerialMonitor Serial
#endif

const int flashCS = 5; // The chip/slave select pin is pin 5.

SPIFlash flash(flashCS); // The SPIFlash object for the chip. Passed the chip select pin in the constructor.
uint16_t page; // The page to be written to. (Page value MUST be type uint16_t)
uint8_t offset; // The specific location on the page. (Offset value MUST be type uint8_t)
uint32_t address; // The specific address in memory to be written to. (Address value MUST be type uint32_t)
const bool errorCheck = true; // A boolean parameter used to check for writing errors. Turned on by default.
const bool fastRead = false; // A boolean parameter used to implement a fast read function. Defaults to false.

void setup() {
  SerialMonitor.begin(115200);
  while(!SerialMonitor); // This will ensure the serial monitor is OPEN before writing to it on TinyScreen+.

  SerialMonitor.println("Initializing Flash Memory...");
  SerialMonitor.println();
  pinMode(flashCS, OUTPUT); // Ensure chip select pin is an output. This line is currently REQUIRED for proper operation.
  flash.begin(); // Boots the flash memory
  SerialMonitor.println(); 

  page = random(0, 4095); // The W25Q80DV has 4,096 writeable pages, referenced as 0-4095 in this library.
  offset = random(0, 255); // There are 256 individually addressable bytes per page, referenced 0-255.
  address = (page * 255) - (255 - offset); // Calculates the proper address given the page and offset.
  /* Writing/Reading a byte */
  SerialMonitor.println("Using writeByte...");
  uint8_t testByte = 8; // Byte data to be written to flash memory
  flash.eraseSector(address); // Must erase memory before writing per datasheet.
  // writeByte(address, testByte, errorCheck) - returns true if successful
  // address: int 0-(4095*255)
  // testByte: uint8_t or byte type data
  // errorCheck: bool
  if(flash.writeByte(address, testByte, errorCheck)) { 
    SerialMonitor.println("Write successful!");
  }
  else {
    SerialMonitor.println("Write failed!");
  }
  SerialMonitor.println("Using readByte...");
  char printBuffer[50]; // for formatting the random values, using sprintf
  sprintf(printBuffer, "The byte on page %d at position %d is: ", page, offset);
  SerialMonitor.print(printBuffer);
  // readByte(address, fastRead)
  SerialMonitor.println(flash.readByte(address, fastRead)); // This should read 8 on the serial monitor.

}

void loop() {
  // Code that runs repeatedly goes here.
}

This code should generate a random page and offset and store the specified byte (in this case, testByte = 8) in that memory address.

The primary characteristic of flash memory is that it retains data even when no power is present. So even if your project loses power, all data will remain as it was when the device was still powered.


Contact Us

If you have any questions or feedback, feel free to email us at info@tinycircuits.com or make a post on the forum.

Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it!

Thanks for making with us!


Downloads