problem in I2C communication with DS3231 RTC

Hi guys, I need help with my DS3231 RTC module. I have it on my arduino (I am using Uno and Mega) desk, connected to i2c ports (SDA, SCL; 20 & 21 on MEGA) and power. But RTC is not working. Red power diode is on (and I have changed battery for new), and when I use examples from DS3231.h and wire.h, they are not working. Thanks a lot for help

PS: In attachment is code I use, it takes time from serial, write is on RTC, and then reads it back

Zkou_ka_asu.ino (4.63 KB)

Hi guys, I need help with my DS3231 RTC module. I have it on my arduino (I am using Uno and Mega) desk, connected to i2c ports (SDA, SCL; 20 & 21 on MEGA) and power. But RTC is not working. Red power diode is on (and I have changed battery for new), and when I use examples from DS3231.h and wire.h, they are not working. It only returns 45:165:85 165/165/165.
Thanks a lot for help

PS: In attachment is code I use, it takes time from serial, write in on RTC, and then reads it back

Zkou_ka_asu.ino (4.63 KB)

Use an I2C scanner to check if your wiring is OK.

when I use examples from DS3231.h and wire.h, they are not working.

Have you verified that the module is seen on the i2c bus? Please run the following scanner code and report back.

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

Do a search on this forum for 165-165 or 165/165. It has been mentioned numerous times.I'll leave the digging to you.

I have read once or twice that this is / can be a power issue (the LED on the board does not mean much from that perpsective). I suggest that you check the wiring and pay attention to bad contacts.

Yep, use I2C scanner first to check device is accessible.

Then, if its responding on its correct I2C address, try one of the examples from the Time-Master DS3231 library first, making no changes of course.

Then if that works, you have proven the DS3231 is working so you and try your own code .......

I uploaded your sketch in my MEGA. This is what I have got on my Serial Monitor as return values. Note: I randomly entered number>0 from the InputBox of SM in response to queries.
smz.png

smz.png

@Dejf, do not cross-post. Threads merged.

Thanks a lot. I now know, that i2c on my MEGA doesnt work correctly, but I can use Uno. RTC are working now. I just dont know what happened to mega, it was working few months before fine...

EDIT: Most likely it is damaged SDA or SCL pin on Mega board. Thanks for help once more!