Problems Writing and Reading I2C Data unknown chip

Recently I got a RX38130CE RTC module. Unfortunately there arent any libraries for it so I have to write and receive I2C data on my own.

In the data sheet I saw that there is an example of how to set the register to set a certain time.
image

However if I try to read the time values I get wierd numbers:

Here is my code:

void SetRTC()
{
  Wire.beginTransmission(RTC_ADDRESS);
  Wire.write(0x1E);
  Wire.write(0x00);
  
  Wire.write(0x10);
  Wire.write(Seconds);

  Wire.write(0x11);
  Wire.write(Minute);

  Wire.write(0x12);
  Wire.write(Hour);

  Wire.write(0x13);
  Wire.write(0x01);

  Wire.write(0x14);
  Wire.write(0x29);

  Wire.write(0x15);
  Wire.write(0x02);

  Wire.write(0x16);
  Wire.write(0x89);
  
  Wire.endTransmission();
  Wire.endTransmission();
}

void ReadRTC()                    
{
  Wire.beginTransmission(RTC_ADDRESS);
  
  Wire.write(0x10);
  Wire.requestFrom(RTC_ADDRESS, 1);
  byte s = Wire.read();

  Wire.write(0x11);
  Wire.requestFrom(RTC_ADDRESS, 1);
  byte m = Wire.read();

  Wire.write(0x12);
  Wire.requestFrom(RTC_ADDRESS, 1);
  byte h = Wire.read();

  Serial.println(h);
  Serial.println(m);
  Serial.println(s);
}

Is my code wrong or do you think I have to look for my problem somewhere else?

I'd try to address individual registers by only writing a register number and data in one transfer. For transfer of multiple registers, if ever implemented, I'd assume auto-increment and omit all register numbers but the very first.

That denotes a complete transfer of 1 byte. Either read multiple bytes in one requestFrom() or each byte in a single sequence:

  Wire.beginTransmission(RTC_ADDRESS);
  Wire.write(0x10);
Wire.endTransmission(); //write the register number

  Wire.requestFrom(RTC_ADDRESS, 1); //read the register content
  byte s = Wire.read();
1 Like

I have a feeling that you did not look very hard for it. I used duckduckgo and got several pages. This is the first hit using "RX38130CE RTC module." as the search term. RX8130CE | Real Time Clock | Product | Epson crystal device It should answer all of your questions.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.