Skip to content

EEPROM TinyShield

When you have a computer, you can turn it off without losing all of your files and documents. Without this ability to store information, a computer would be much less useful. However, microcontrollers often do not ship with the necessary hardware to store data when power is removed. That's where the EEPROM TinyShield comes in!

The EEPROM TinyShield gives you the ability to record data using your microcontroller, without the possibility of losing that data after power is disconnected.

Learn more about the TinyDuino Platform


Description

Add robust storage memory to your TinyDuino with this EEPROM TinyShield.  Built around the Microchip 24FC1025, this EEPROM is a simple way to store settings, logs, or any other data your project needs to keep through power cycles.

The EEPROM TinyShield is low power and works through the I2C interface. It has 1 Mbit (128KBytes) of storage and is byte addressable.  Example code is provided to make it simple to add EEPROM support to your projects.  

Technical Details

Microchip 24FC1025 EEPROM Specs

  • 128K x 8 (1 Mbit)
  • 128-Byte Page Write Buffer
  • Page Write Time 5 ms Max
  • Write Endurance: 1,000,000
  • Data Retention: 200 Years

TinyDuino Power Requirements

  • Voltage: 1.8V - 5.5V 
  • Current:
    • Standby: 5uA
    • Read: 450uA
    • Write: 5mA
    • Due to the low current, this board can be run using the TinyDuino coin cell option

Pins Used

  • A5/SCL - I2C Serial Clock line
  • A4/SDA - I2C Serial Data line

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


Materials

Hardware materials

Hardware

Software


Hardware Assembly

To assemble the hardware, you just need to stack the processor board of your choice with the EEPROM TinyShield.

Assembled TinyDuino stack

Make sure the power switch on the processor is flipped to ON.


Upload Program

There is no library necessary for this TinyShield, so all the necessary software is included in the main .ino program.

If you haven't already, download the .zip folder for the EEPROM example program found under Materials\Software, and then open it in the Arduino IDE.

In the IDE, we will make the Tools selections based on the processor board used in the project. Since I used the TinyZero, these are the selections:

  • Board: "TinyZero"
  • Build Options: "Default"
  • Port: "COM## (TinyScreen+)"

Tools Selections

EEPROM Example Sketch
/*
  TinyCircuits EEPROM TinyShield Example Sketch

  This is an example of how to write and read bytes to the 24FC1025 I2C EEPROM
  using the Wire library. Page write transactions are not used. The address
  resistors on the board are both low (0) by default.

  Written 03 May 2016
  By Ben Rose
  Modified 07 January 2019
  By Hunter Hykes

  https://TinyCircuits.com
*/

#include <Wire.h>

#define EEPROM_A0 0
#define EEPROM_A1 0
#define EEPROM_ADDR 0x50|(EEPROM_A1<<1)|(EEPROM_A0<<0)

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

void setup() {
  Wire.begin();
  SerialMonitor.begin(115200);
  while(!SerialMonitor); // Halts program until Serial Monitor is opened
  SerialMonitor.println("Writing..");
  char writeData[]="TinyCircuits!";
  EEPROMwrite(0,(uint8_t*)writeData,sizeof(writeData));
  char readData[]="If you see this, there's an error!";
  SerialMonitor.println("Reading..");
  EEPROMread(0,(uint8_t*)readData,sizeof(writeData));
  SerialMonitor.println(readData);
}

void loop() {
  // put your main code here, to run repeatedly:
//  SerialUSB.print("test");

}

void EEPROMread(unsigned long addr, uint8_t* buff, unsigned long count){
  for(unsigned long i=0;i<count;i++){
    buff[i]=EEPROMread(addr+i);
  }
}

void EEPROMwrite(unsigned long addr, uint8_t* buff, unsigned long count){
  for(unsigned long i=0;i<count;i++){
    EEPROMwrite(addr+i,buff[i]);
  }
}

byte EEPROMread(unsigned long addr){
  uint8_t val=255;
  uint8_t I2Caddr=EEPROM_ADDR;
  if(addr>0x0000FFFF){
    I2Caddr|=0x04;
  }
  Wire.beginTransmission(I2Caddr);
  Wire.write(addr>>8);
  Wire.write(addr);
  Wire.endTransmission();
  Wire.requestFrom(I2Caddr,(uint8_t)1);
  while(Wire.available()){
    val=Wire.read();
  }
  return val;
}

byte EEPROMwrite(unsigned long addr, byte val){
  uint8_t I2Caddr=EEPROM_ADDR;
  if(addr>0x0000FFFF){
    I2Caddr|=0x04;
  }
  Wire.beginTransmission(I2Caddr);
  Wire.write(addr>>8);
  Wire.write(addr);
  Wire.write(val);
  Wire.endTransmission();
  Wire.beginTransmission(I2Caddr);
  unsigned long timeout=millis();
  while(Wire.endTransmission() && millis()-timeout<10){
    Wire.beginTransmission(I2Caddr);
  }
}

You will need to open the Serial Monitor to allow the program to continue past the line:

while(!SerialMonitor);

You can access the Serial Monitor by selecting it under the Tools tab, or by pressing on the magnifying glass icon in the top right of the IDE.

Make sure the baud rate selected in the Serial Monitor is that same as the baud rate in the program (115200).


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!