DS3231 interrupt triggered flags issue

We are using ds3231 and esp8266 but we are getting some issues.

We are not getting proper data (Please check the attached image), we are getting only 2000/1/1 0:0:0
I followed instructions and libraries as per the below link

https://techtutorialsx.com/2016/05/22/e … s3231-rtc/

Initially i used direct power 3.3v from usb to ds3231 module. As per suggestions i brought the new one and given the power with coin battery.

Module Link : https://potentiallabs.com/cart/buy-ds32 … rch=ds3231

At first it was working fine then it started getting issues in eeprom then completely stopped working. Kindly requesting everyone to help me to solve the issue.

//This is the code:
#include <Wire.h>
#include <RtcDS3231.h>

const byte interruptPin = 13;
volatile bool alarm = 0;

RtcDS3231 rtcObject(Wire);

void setup()
{
char somedata = {‘r’,‘a’,‘m’,‘r’,‘a’,‘m’}; // data to write
Wire.begin(); // initialise the connection
Serial.begin(115200);
Serial.println(“Writing into memory…”);
rtcObject.Begin();
// write to EEPROM
i2c_eeprom_write_page(0x57, 0, (byte *)somedata, sizeof(somedata));

delay(100); //add a small delay
Serial.println(" ");
RtcDateTime currentTime=RtcDateTime(somedata[0], somedata[1], somedata[2],somedata[3],somedata[4],somedata[5]);
rtcObject.SetDateTime(currentTime);
}

void loop()
{
Serial.print("Reading memory: ");
int addr=0; //first address

// access the first address from the memory
byte b = i2c_eeprom_read_byte(0x57, 0);

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

RtcDateTime currentTime = rtcObject.GetDateTime();
char str[20];
sprintf(str, “%d/%d/%d %d:%d:%d”, //%d allows to print an integer to the string
currentTime.Year(), //get year method
currentTime.Month(), //get month method
currentTime.Day(), //get day method
currentTime.Hour(), //get hour method
currentTime.Minute(), //get minute method
currentTime.Second() //get second method
);

Serial.println(str); //print the string to the serial port
delay(1000);
}

void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data ) {
int rdata = data;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 0x08)); // 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 >> 0x08); // MSB
Wire.write((int)(eeaddresspage & 0xFF)); // LSB
byte c;
for ( c = 0; c < length; c++)
Wire.write(data

);
Wire.endTransmission();
}

byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) {
byte rdata = 0xFF;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >>  0x08)); // 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 >>  0x08)); // 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();
}

output which i am getting :
2000/1/1 0:0:0
Reading memory: ⸮
⸮
⸮
⸮
⸮
⸮
2000/1/1 0:0:0
Reading memory: ⸮
⸮
⸮
⸮
⸮
⸮
2000/1/1 0:0:0

Thanks in advance.

![Capture1ds3231.JPG|510x384](upload://7BpRzWJTuPfx4Ygtuh11KVr8sE6.jpeg)

Hey, lots of smileys in that code! What do they do?

I suggest you read the forum guide, then modify your post above and fix it.

PaulRB:
Hey, lots of smileys in that code! What do they do?

I suggest you read the forum guide, then modify your post above and fix it.

It does shifts right side 8 time. I added single quote to avoid that.

Does momentarily shorting GPIO13 to ground wake the ESP8266 ?

You must use code tags here when posting code to avoid it being corrupted when displayed.

6v6gt:
Does momentarily shorting GPIO13 to ground wake the ESP8266 ?

I have tested with GPIO13 before i connected to CH_PD. INT/SQW pin is showing LOW whenever seconds matches.

So i assumed that esp8266 will wake up from deepsleep when we can connect INT/SQW directly to the CH_PD. but it is not happening as expected.

INT/SQW pin is not getting HIGH.

My suggestion is that you separate the 2 issues:

Issue #1 is getting the ESP8266 to wake from sleep (using anything to wake it). Some pins may have to be jumpered to achieve this.

Issue #2 is the behaviour of the DS3231 module SQW output. This has an open drain which does not, by itself, "get HIGH".

Try to find tutorials where these issues are addressed.

ramkumar_d_d:
It does shifts right side 8 time. I added single quote to avoid that.

No, smileys don't do anything, they're not legal C. And putting quotes around the 8 will stop your code working because you are shifting by the number of bits corresponding to the ASCII code for 8, not the value 8. You completely missed my point. Read the forum guide as I suggested.

PaulRB:
No, smileys don't do anything, they're not legal C. And putting quotes around the 8 will stop your code working because you are shifting by the number of bits corresponding to the ASCII code for 8, not the value 8. You completely missed my point. Read the forum guide as I suggested.

Yeah thanks for the suggestions. Could you check and now and let me know where i am doing wrong.

6v6gt:
Does momentarily shorting GPIO13 to ground wake the ESP8266 ?

You must use code tags here when posting code to avoid it being corrupted when displayed.

No, It wont. I did pulled up CH_PD and connected 100uf cap in series to SQW pin of ds3231 to reset esp8266. It worked well and it got reset at expected times.

Now i am just writing some data in eeprom and printing in LOOP. Please see the attached image to the post.

6v6gt:
My suggestion is that you separate the 2 issues:

Issue #1 is getting the ESP8266 to wake from sleep (using anything to wake it). Some pins may have to be jumpered to achieve this.

Issue #2 is the behaviour of the DS3231 module SQW output. This has an open drain which does not, by itself, "get HIGH".

Try to find tutorials where these issues are addressed.

Issue #1 : Yes i have done explained in the comments. But ds3231 is completely in non responsive state.

Issue #2 : Correct. SQW is by default high and by using the i woke up esp8266 from sleep.

ramkumar_d_d:
Yeah thanks for the suggestions. Could you check and now and let me know where i am doing wrong.

Still wrong. I have told you twice where you are going wrong. You refuse to read the forum guide. Why do you refuse?

PaulRB:
Still wrong. I have told you twice where you are going wrong. You refuse to read the forum guide. Why do you refuse?

Actually i did not refuse. I didnt find any guide to check :frowning:

ramkumar_d_d:
Actually i did not refuse. I didnt find any guide to check :frowning:

Did you actually look?

PaulRB:
Did you actually look?

Why should i lie?

thanks for the suggestions to everyone. I resolved all the issues. It is working fine now. There are some loose connections and programming issues. that’s it.

ramkumar_d_d:
Why should i lie?

Pride? Lazyness? It would take 2 minutes, yet still your original post is not fixed.