Adding an 24LC256 EEPROM to the Arduino Due





The arduino due lacks an eeprom. This instructable adds one and allows you to store values in non volatile memory that will survive an arduino firmware update.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Breadboarding

There are some really good instructions here:

I just followed them.

The photo shows the breadboarded circuit. pins 1 to 4 and pin 7 are grounded. pin 8 is connected to the 3.3V supply on the due board.

The yellow (pin 6) and white (pin 5) wires connected to the i2c SDA (data) and SCL (clock) pins on the due board (numbered 21 and 20).

Step 2: Code Time.

Here are some snippets of code that I use in my sketches.

Firstly, include the Wire library headers somewhere near the top of your sketch:

/* Use 24LC256 EEPROM to save settings */
#include <Wire.h>

Then add some functions to read and write bytes from the EEPROM (I only care about individual bytes but there is a page write feature in the chip too). Note there is a macro definition of 0x50.. this is the address of the chip on the i2c bus (you can connect more than one i2c thingies on an i2c bus and select which one you want to talk to by changing the address).

/* These two functions help us write to the 24LC256 EEPROM chip */
#define EEPROM_ADDR 0x50
void EEPROM_write(unsigned int addr,byte data) {
  int rdata = data;
  Wire.write((int)(addr >> 8));       // MSB
  Wire.write((int)(addr & 0xFF));     // LSB
  //Serial.print("EEPROM write: addr: ");
  //Serial.print(" ");

byte EEPROM_read(unsigned int addr) {
  byte data = 0xFF;
  Wire.write((int)(addr >> 8));       // MSB
  Wire.write((int)(addr & 0xFF));     // LSB
  if (Wire.available()) data =;
  //Serial.print("EEPROM read: addr: ");
  //Serial.print(" ");
  return data;

You can uncomment the Serial.print(...) lines if you want to see some debug output.

In arduinos setup() function you start the wire library and can read in initial values.
Here I read in two bytes (flags and max_cc), two words (lean_min and lean_max) and an array of words sd_max[3]:

    // read values saved in the EEPROM
    for(int j=0;j<3;j ) {
      sd_max[j]=word(EEPROM_read(7 j*2),EEPROM_read(6 j*2));

Here's the bit of code that writes them into the EEPROM:

         for(int j=0;j<3;j ) {
           EEPROM_write(6 j*2,lowByte(sd_max[j]));
           EEPROM_write(7 j*2,highByte(sd_max[j]));

Thats about it really.

Step 3: Wire It Up

Wire it onto some veroboard to screw into an enclosure and the jobs done.

2 People Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

6 Discussions


4 years ago

Would it be possible to show the underside of the vero board, if it has any additional wires?

2 replies

Reply 4 years ago

I've put it inside something now. Sorry. From what I remember though the wiring is exactly the same as the breadboard picture but adapted for veroboard. Best wishes. Martin.


5 years ago on Introduction

G'Day, - it is reccomended that i2c buses have pullup resistors (typically 2k2 - 10k range) installed on SDA and SCL. If anyone is having issues with copying the cabling shown in this instructable, the absence of pullup resistors could be one of the causes.

1 reply

Reply 5 years ago on Introduction

Hi, yes I didn't wire any pull ups in. This is because I understood some pull ups to be built into the due board. However, there seems to be some controversy on if they are of the right value.