SRAM TinyShield Tutorial

The SRAM TinyShield allows you to add Static Random Access Memory to your TinyDuino projects.
Learn more about the TinyDuino Platform
Description
This SRAM Tinyshield allows you to add memory to your TinyDuino projects that can read and write at a virtually instant rate. Built around the Microchip 23LC1024 SRAM Module, this board allows for some extra processing memory when your Arduino device is powered on. Since it doesn't hold information through power cycles, you don't have to worry about erasing anything.
The SRAM TinyShield is low power and works through the SPI interface. It has 1Mbit of storage. Example code is provided to make it simple to add SRAM support to your projects.
Technical Details
Microchip 23LC1024 SRAM Specs
- 128K x 8 (1 Mbit)
- Zero Write Time
- Unlimited read and write cycles
TinyDuino Power Requirements
- Voltage: 2.5V - 5.5V
- Current:
- Standby: 4uA
- Read: 3mA
- Write: 3mA
- 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 SRAM.
- 11 - MOSI: This signal is the serial SPI data out of the TinyDuino and into the SRAM.
- 12 - MISO: This signal is the serial SPI data out of the SRAM and into the TinyDuino.
- 13 - SCLK: This signal is the serial SPI clock out of the TinyDuino and into the SRAM.
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)
To see what other TinyShields this will work with or conflict with, check out the TinyShield Compatibility Matrix
Notes
- Resistor R5 can be swapped to R6 to change the Chip Select Pin to pin 6.
Materials

Hardware
- A TinyDuino Processor Board
- TinyDuino and USB TinyShield OR
- TinyZero OR
- TinyScreen+
- SRAM TinyShield
- Micro USB Cable
Software
Assembly (Hardware)
On top of your TinyZero, or processor board of choice, attach the SRAM TinyShield using the tan 32-pin connector. Connect your TinyDuino Stack to your computer using the microUSB cable. Make sure the processor is switched on.

Software (Setup and Downloads)
First, open the Arduino IDE. If you don't have it installed, check out a setup tutorial for the processor board you are using to make sure you have everything you need before proceeding. Download the SRAM Arduino Library. Under the Sketch tab, go to Include Library -> Add .ZIP Library. Find and select the SRAM library .ZIP folder in your downloads folder, and press "Open". The library should then be installed.

The Code
This program writes a string of text to a specific memory address and then reads back the text from the specified memory address. The text that is read back is then printed to the Serial Monitor. You can play around with the program by changing the text that is written to memory or by changing the memory address that the text is written to.
Code
/*
TinyCircuits SRAM Example Sketch
This sketch writes a string of text to a specifice memory address, reads the
text back from memory, then prints the text to demonstrates some functions of
the TinyCircuits SRAM Tinyshield, which uses the Microchip 23LC1024 SRAM
memory module.
Library written by ennui2342 on github https://github.com/ennui2342/arduino-sram
Written 02 July 2018
By Nick DiVitto
Modified 09 January 2019
By Hunter Hykes
https://TinyCircuits.com
*/
#include <SRAM.h>
#include <SPI.h>
#define SRAM_CS_PIN 5
#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif
SRAM sram(SRAM_CS_PIN, SRAM_1024);
void setup() {
SerialMonitorInterface.begin(9600);
// while (!SerialMonitorInterface); //This line will block until a serial monitor is opened with TinyScreen+!
SPI.begin();
SerialMonitorInterface.println("SRAM Test");
sram.begin();
}
void loop() {
char test [] = "hello, world";
sram.seek(1); //Goes to address '1' within SRAM
sram.write((byte *) test, sizeof(test)); //writes the contents of test to SRAM at the previously specified address
char buf[20];
sram.seek(1); //Goes to address '1' within SRAM
sram.readBytes((char *) buf, sizeof(buf)); //reads the contents of SRAM at the previously specified address to buf
SerialMonitorInterface.println(buf);
delay(500);
}
This example program is also available in the SRAM examples tab from the library as "SRAM_Test."

Once the upload is complete, open the Serial Monitor. You can do this by navigating to it under the Tools tab, or by selecting the magnifying glass icon at the top right of the Arduino window. Make sure the baud rate is set to 9600. You should see that text is continuously being printed to the serial monitor.

Downloads
Contact Us
If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.
Thanks for making with us!