will be read-only starting December 31st, 2018. For more info please look at this Forum Post

Here's a little database library that makes use of the Arduino's EEPROM memory to store records in a table. It is very simple to keep the memory footprint small. You will have to spin your own record locate and other functions like validation, but this is relatively easy to do.


How to use in a nutshell:

- include Db.h and EEPROM.h
- declare an instance of DB, db
- define a structure for your records
- pick an address in EEPROM for the table to start
- make a little sketch that creates the table by calling db.create(address,sizeof(myRecStruct))
- in your application's sketch open the table with
- use the define DB_REC to cast your structure as a byte pointer when passing it as a parameter
for write and read operations, this helps make the code more readable.



Install like any other Arduino library. Unzip the download into your Arduino-00xx/hardware/libraries directory. If the Arduino IDE is already running then exit and restart the Arduino IDE. This will compile and build the library files.


// EEPROM DB example
// This example creates a database, adds 10 records, and reads the 10 records
// displaying the results.  
#include "WProgram.h"
#include <EEPROM.h>
#include <DB.h>
#include <string.h>

DB db;

#define MY_TBL 1

struct MyRec {
  char date[11];
  char time[9];
  int temperature;
} myrec;

void setup()
  Serial.println("EEPROM DB Library Demo");


  Serial.print("Creating Table...");

  Serial.print("Creating records...");
  for (int recno = 1; recno <= 5; recno++)
    int m = random(1, 12);
    int d = random(1, 31);
    int h = random(1, 12);
    int i = random(59);
    int s = random(59);

    sprintf(, "2009-%02d-%02d", m, d);
    sprintf(myrec.time, "%02d:%02d:%02d", h, i, s);
    myrec.temperature = random(-100, 100);
    Serial.print("CREATING RECNUM: "); Serial.println(recno);
    Serial.print("WRITING Date: "); Serial.println(;
    Serial.print("WRITING Time: "); Serial.println(myrec.time);
    Serial.print("WRITING Temperature: "); Serial.println(myrec.temperature);
    db.append(DB_REC myrec);
  Serial.println("Reading records from EEPROM...");

void loop()

void selectAll()
  if (db.nRecs()) Serial.println("-----");
  for (int i = 1; i <= db.nRecs(); i++)
  {, DB_REC myrec);
    Serial.print("Recnum: "); Serial.println(i); 
    Serial.print("Date: "); Serial.println(; 
    Serial.print("Time: "); Serial.println(myrec.time);
    Serial.print("Temperature: "); Serial.println(myrec.temperature);

Known Issues

  • Tables are limited to a maximum of 255 records
  • Tables are limited to the amount of EEPROM on your Arduino
  • Maximum number of records: (EEPROM size / record size = max records)