DS3231 AT24C32 IIC Module guidance

Hi guys :)

Any guidance on using AT24C32 memory without clashing with arduino's? Example code would be very much appreciated ;)

TIA, Pedro

http://playground.arduino.cc/Code/I2CEEPROM24C1024#.UxMweON5PoE

I have one of those modules. For the DS3231 I used the example code meant for the DS1307 (maybe comes with the IDE) as the connections and protocol are the same.

I haven't tried communicating with the memory chip.

Oops... sorry forgot about this post :blush:

It was a simple matter of addressing the device. In this case for the DS3231+AT24C32 :

// the address for the eeprom
#define I2C_EEPROM_ADDR 0x57

and then perform reads/writes :

uint8_t i2c_eeprom_read_byte( uint16_t deviceaddress, uint16_t eeaddress ) {
    uint8_t 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;
}

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

Thank you, Pedro