Code Monkey home page Code Monkey logo

arduino-i2c-eeprom-library's Introduction

I2C EEPROMs library for Arduino

Build Status Codacy Badge License: MIT Donate

What is it

This library (with examples) is designed to be integrated in projects using I2C EEPROM. It can read and write data from I2C EEPROMs. It has been fully tested with 24LC256 device but should work with others.

It should be compatible with 24LCxxx and CAT24Cxxx EEPROMs:

  • 24LC512, 24LC256, 24LC128, ...
  • CAT24C01, CAT24C02, CAT24C04, CAT24C08, CAT24C16, ...

How to install

  1. Download latest release (zip file, not the source code)

  2. On your Arduino IDE, click "Sketch" menu and then "Include Library > Add .ZIP Libraries"

  3. You can now use the library for your project or launch an example ("File > Examples")

How to connect I2C EEPROM to arduino

Most of I2C EEPROMs are connected the same way.

Here are the pin connections for 24LC256 device:

24LC256 Arduino Source
VCC 5V
GND GND
SCL SCL (A5)
SDA SDA (A4)
Others GND (-> I2C address = 0x50)

How to use the EEPROM (CAT24Cxx & 24LCxxx & others) ?

  • If you use a 24LCxxx EEPROM, you can initialize the EEPROM this way:
#define CHIP_ADDRESS 0x50 // Address of EEPROM chip

I2CEEPROM i2c_eeprom(CHIP_ADDRESS);

// Read and write the same value from EEPROM
i2c_eeprom.write(0 /* value address */, 15 /* value to write */);
unsigned int read_value = i2c_eeprom.read(0 /* value address */);
  • If you use a CAT24Cxx EEPROM, you need to initialize the EEPROM this way:
#define CHIP_ADDRESS 0x50 // Address of EEPROM chip
#define CAT_EEPROM_DEVICE EEPROM_DEVICE_CAT24C01 // You can use one of those elements: EEPROM_DEVICE_CAT24C01, EEPROM_DEVICE_CAT24C02, EEPROM_DEVICE_CAT24C04, EEPROM_DEVICE_CAT24C08, EEPROM_DEVICE_CAT24C16

I2CEEPROM i2c_eeprom(CHIP_ADDRESS, CAT_EEPROM_DEVICE);

// Read and write the same value from EEPROM
i2c_eeprom.write(0 /* value address */, 15 /* value to write */);
unsigned int read_value = i2c_eeprom.read(0 /* value address */);
  • If you use an other EEPROM, it should work the same way as 24LCxxx EEPROM (maybe not the same I2C address)

Examples

Three examples are provided with this library:

Simple Read through all EEPROM

Link to source code

Simple Write though all EEPROM

Link to source code

Simple Update though all EEPROM

Link to source code

Check consistency of the EEPROM

Link to source code

License

This project is under MIT license. This means you can use it as you want (just don't delete the library header).

Contribute

If you want to add more examples or improve the library, just create a pull request with proper commit message and right wrapping.

Contributors

  • Thank you Bu-Gee for your help on adding CAT24Cxx compatibility from this fork.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.