npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

arduino-db

v1.1.1

Published

little database library that makes use of the Arduino's EEPROM memory to store records in a table

Downloads

13

Readme

arduino-db

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.

Overview 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 db.open(address)
  • 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.

Download https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/arduino-dblib/DB.zip

Installing 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.

Example
//
// 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.begin(9600);
  Serial.println("EEPROM DB Library Demo");
  Serial.println();

  randomSeed(analogRead(0));

  Serial.print("Creating Table...");
  db.create(MY_TBL,sizeof(myrec));
  db.open(MY_TBL);
  Serial.println("DONE");

  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(myrec.date, "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(myrec.date);
    Serial.print("WRITING Time: "); Serial.println(myrec.time);
    Serial.print("WRITING Temperature: "); Serial.println(myrec.temperature);
    db.append(DB_REC myrec);
    Serial.println("DONE");
  }
  Serial.println();
  Serial.println("Reading records from EEPROM...");
  Serial.println();
  selectAll();
}

void loop()
{
}

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

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)