_SKU__DFR0117__Gravity__I2C_EEPROM_I2C数据存储模块 - jimaobian/DFRobotWikiCn GitHub Wiki

Gravity EEPROM Data Storage Moudle

概述

Arduion自身带了少量的数据存储空间,像UNO只有32K,但是如果你想要存储大量数据的话,其存储空间肯定是不够用的,因此我们就需要加入EEPROM模块来增大存储空间。EEPROM存储模块使用I2C总线来与Arduion进行连接,此模块所采用的是Microchip公司所生产的24LC256芯片,其存储空间为256Kbit,即32kB字节;模块可以和interface shield接口扩展板和I2C专用连接线配合使用,支持热插拔。

技术规格

  • 供电电压:2.5 ~5.5V
  • 写最大电流:3mA at 5.5V
  • 读最大电流:400uA at 5.5V
  • 待机电流:100nA at 5.5V
  • 接口:Gravity-I2C
  • 容量:32k bytes
  • 模块尺寸:30.00*21.05(mm)
  • 安装孔直径:3.5mm
  • 工作温度:-40℃~+125℃
  • 重量:10g

引脚定义

| | | | ------------------------------------------------------------------------------ | | | :DFR0117 EEPROM数据存储模块引脚图 | |

标号 名称 功能描述
+ vcc 供电正极引脚
- GND 供电负极引脚
C SCL I2C时钟线
D SDA I2C数据线

引脚说明

模块地址真值表

Gravity-I2C EEPROM存储模块真值表

与Arduion接线图

Arduino_EEPROM_I2C

示例代码


/*
  *  Use the I2C bus with EEPROM 24LC64
  *  Sketch:    eeprom.pde
  *
  *  Author: hkhijhe
  *  Date: 01/10/2010
  *
  *
  */

  #include <Wire.h> //I2C library



  void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data ) {
    int rdata = data;
    Wire.beginTransmission(deviceaddress);
    Wire.write((int)(eeaddress >> 8)); // MSB
    Wire.write((int)(eeaddress & 0xFF)); // LSB
    Wire.write(rdata);
    Wire.endTransmission();
  }

  // WARNING: address is a page address, 6-bit end will wrap around
  // also, data can be maximum of about 30 bytes, because the Wire library has a buffer of 32 bytes
  void i2c_eeprom_write_page( int deviceaddress, unsigned int eeaddresspage, byte* data, byte length ) {
    Wire.beginTransmission(deviceaddress);
    Wire.write((int)(eeaddresspage >> 8)); // MSB
    Wire.write((int)(eeaddresspage & 0xFF)); // LSB
    byte c;
    for ( c = 0; c < length; c++)
      Wire.write(data[c]);
    Wire.endTransmission();
  }

  byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) {
    byte rdata = 0xFF;
    Wire.beginTransmission(deviceaddress);
    Wire.write((int)(eeaddress >> 8)); // MSB
    Wire.write((int)(eeaddress & 0xFF)); // LSB
    Wire.endTransmission();
    Wire.requestFrom(deviceaddress,1);
    if (Wire.available()) rdata = Wire.read();
    return rdata;
  }

  // maybe let's not read more than 30 or 32 bytes at a time!
  void i2c_eeprom_read_buffer( int deviceaddress, unsigned int eeaddress, byte *buffer, int length ) {
    Wire.beginTransmission(deviceaddress);
    Wire.write((int)(eeaddress >> 8)); // MSB
    Wire.write((int)(eeaddress & 0xFF)); // LSB
    Wire.endTransmission();
    Wire.requestFrom(deviceaddress,length);
    int c = 0;
    for ( c = 0; c < length; c++ )
      if (Wire.available()) buffer[c] = Wire.read();
  }




  void setup()
  {
    char somedata[] = "this is data from the eeprom"; // data to write
    Wire.begin(); // initialise the connection
    Serial.begin(9600);
    i2c_eeprom_write_page(0x50, 0, (byte *)somedata, sizeof(somedata)); // write to EEPROM

    delay(10); //add a small delay

    Serial.println("Memory written");
  }

  void loop()
  {
    int addr=0; //first address
    byte b = i2c_eeprom_read_byte(0x50, 0); // access the first address from the memory

    while (b!=0)
    {
      Serial.print((char)b); //print content to serial port
      addr++; //increase address
      b = i2c_eeprom_read_byte(0x50, addr); //access an address from the memory
    }
    Serial.println(" ");
    delay(2000);

  }

例程测试结果

Gravity I2C EEPROM例程测试结果(win7 64位 Arduion 1.8.5)

常见问题

还没有客户对此产品有任何问题,欢迎通过qq或者论坛联系我们!

| 更多问题及有趣的应用,可以 访问论坛 进行查阅或发帖。 |

更多

File:DFshopping_car1.png购买 Gravity-I2C EEPROM Data Storage Module For Arduino (SKU:DFR0117)

⚠️ **GitHub.com Fallback** ⚠️