DS3231 driving me crazy

Hello this is my first post,

i am frustrated and need help with my DS3231 RTC.

I have a project where battery power is really important. I use a DS3231 RTC to wakeup my ESP32 microcontroller. My ESP32 has some sensors. It reads it and goes back to sleep, until the RTC wakes him up. To minimize power consumption, I cut down the power of my sensors AND the RTC via a MOSFET switch. The RTC has a battery which keeps the time even when the power from VCC is gone. I want to wake the ESP32 via the RTC in battery mode.

So far so good...

I read in this thread

that the Alarm from the DS3231 in battery mode is just possible, if you remove one resistor block, which I did. I also removed that one resistor which charges the battery.
My DS3231 now looks exactly like this:

Now I am getting the 165.85.165 glitch. This glitch happens if
a) there is a wiring error of the SDA and SCL Pins
b) that you need pullup-resistors of 4.7K Ohm on SDA and SCL

My SDA and SCL Pins are wired correctly. I know that. Seems like I f*** up by removing the resistor block for nothing. I cant write to the RTC properly anymore.
Now I am really confused, regarding the removal of the resistor block. Why would you remove the resistor block just to add them externally again?

Is there really NO way with the resistors on the RTC to get the alarm signal via battery mode?

What options do I have to make this work? I am ready to buy another module of the DS3231 to start over again.

BTW: My ESP32 has also internal pull up resistors for the GPIO-Pins but I read on another thread that these are to weak/not fast enough.

Kazuya91:
Now I am getting the 165.85.165 glitch. This glitch happens if
a) there is a wiring error of the SDA and SCL Pins
b) that you need pullup-resistors of 4.7K Ohm on SDA and SCL

My SDA and SCL Pins are wired correctly. I know that.

You absolutely sure? Have you checked that there are no solder bridges that could be shorting out the connections on the board (a magnifying glass is useful)? You’ve checked the external pull-ups with a meter to make sure they have the correct value? Is the battery correctly installed on the RTC board?

Kazuya91:
Seems like I f*** up by removing the resistor block for nothing. I cant write to the RTC properly anymore.
Now I am really confused, regarding the removal of the resistor block. Why would you remove the resistor block just to add them externally again?

My understanding from the linked thread is that you are only wanting to disconnect the interrupt pin from VCC, the other disconnections and work-arounds are just a side effect of removing the whole resistor block.
If it were me, I might try to remove one or both of the pins from the resistor block that correspond with the interrupt, and just solder the block back in place.

Kazuya91:
Is there really NO way with the resistors on the RTC to get the alarm signal via battery mode?

Snip the trace, as stated in the linked thread. Sounds a little tricky, but why not.

It would also be interesting to measure the power draw of the unit with just the battery charge circuit disconnected.

You absolutely sure? Have you checked that there are no solder bridges that could be shorting out the connections on the board (a magnifying glass is useful)? You've checked the external pull-ups with a meter to make sure they have the correct value? Is the battery correctly installed on the RTC board?

The battery is a fresh new VARTA CR2032 and is inserted properly.
With "My SDA and SCL Pins are wired correctly" I just meant the corresponding Pins with my ESP32 are connected right to the RTC.
If I am getting this right, the point I was missing is, that the SDA and SCL pins need the pullup resistors. Either on the RTC itself or (if I removed it) external ones. Thats why I cant read/write the time properly and get the 165.85.165 time reading, because i removed the resistor block and dont have external pull-up resistors.

On this site i found a picture with the trace cut:
https://www.davidpilling.com/wiki/index.php/Logger
Its the third picture in the section "RTC clock".

Is it enough to unsolder that specific pin from the resistor block on one side?

Kazuya91:
i ... dont have external pull-up resistors.

Ok, right. Well, then it's not going to work then.

Kazuya91:
On this site i found a picture with the trace cut:
Logger | David Pilling
Its the third picture in the section "RTC clock".

Ugh. Yes, well, as demonstrated, a jack hammer probably isn't the right tool for doing that job.

You could have better luck with a sharp craft knife or scalpel. A couple of short slits across the trace and then pick the copper island off the board.

Kazuya91:
Is it enough to unsolder that specific pin from the resistor block on one side?

If you are able to do that, then that's the best way.

What you could try with your current configuration is just to run with the ESP32's internal pull-ups (45k I believe) and reduce the I2C bus speed (Wire.setClock()) to 10000 and see if that works. I think slower bus speed are supported by both pieces of hardware.

The resistors removed were there to provide pull-ups on several of the clocks pins: SQW/INT, SCL, SDA, 32K. They connected those pins to the board's VCC pin. When you set the Arduino pin connected to to the board's VCC to LOW, they become pull-down resistors. That would prevent the SQW/INT output from creating a falling edge on the interrupt line.

I think you need to cut the trace between the SQW/INT pin (pin 3) of the clock chip and the on-board pull-up (not all four) and add a 4.7k pull-up from Arduino power to the SQW/INT pin (pin 3) of the clock chip. That gives the SQW/INT something to pull down even when power to the clock board is turned off.

excellent tutorial on DS3231 modifications at Using a $1 DS3231 Real-time Clock Module with Arduino | Underwater Arduino Data Loggers

Yes, you DO need to remove that resistor block, AND you need a pullup resistor from SQW/INT to the Arduino Vcc in order for an interrupt to be recognized.

First, i want to thank you all for helping me out here. I appreciate that.

What you could try with your current configuration is just to run with the ESP32’s internal pull-ups (45k I believe) and reduce the I2C bus speed (Wire.setClock()) to 10000 and see if that works. I think slower bus speed are supported by both pieces of hardware.

I did exactly what you said. Before I do a “Wire.begin()” I set the following settings:

pinMode(SDA_PIN, INPUT_PULLUP);
pinMode(SCL_PIN, INPUT_PULLUP); 
Wire.setClock(10000);

It did improve the situation a little bit. On 2 of 3 reading-processes I got the right time. On the third reading I got garbage again. So I cant rely on the internal pullup-resistors for SDA and SCL.

The resistors removed were there to provide pull-ups on several of the clocks pins: SQW/INT, SCL, SDA, 32K. They connected those pins to the board’s VCC pin. When you set the Arduino pin connected to to the board’s VCC to LOW, they become pull-down resistors. That would prevent the SQW/INT output from creating a falling edge on the interrupt line.

Thanks for the detailed explanation. I think I got that now.

Yes, you DO need to remove that resistor block, AND you need a pullup resistor from SQW/INT to the Arduino Vcc in order for an interrupt to be recognized.

Ok, understood. But if i remove the resistor block i also need pullup resistors on SDA and SCL right?
I quote you from another thread:

You need 4.7K resistors from Vcc to A4 and A5 (the I2C pins). If those resistors are not on the RTC module, you have to add them externally.

The thread I quoted you is this one: https://forum.arduino.cc/index.php?topic=369838.0

So let me summarize this just to be sure:

Case 1: I remove the entire block.

If I remove the entire block, which is the most easy way I need to add external pull-up resistors for SDA, SCL and SQW. Not just for the SQW pin. Because otherwise I cant read/write to the RTC properly. Is that right?

Case 2: I cut the trace.
If i cut the trace, I dont need to remove the resistor block. Because I didnt remove the block I can still properly read/write to the RTC. But I need to add an external pull-up resistor to get the SQW-Interrupt in Battery mode. If i am lucky and my ESP32 internal pull-up resistors are good enough I can set the interrupt pin from the ESP32 via

pinMode(RTC_INT_PIN, INPUT_PULLUP);

…and dont need to add an external pull-up resistor for the SQW-Pin. If not, I need to add an external one.

Case 3: Instead of cutting the trace I unsolder the corresponding pin from the resistor for SQW.
The rest is the same like Case 2 except I dont cut the trace.

Which pin for case 3 would that be? I marked 2 pins of the resistor on the picture. Are these the right ones? If yes, is unsoldering just one of them enough?
The picture is in the attachment

RTC_resistor.png

Kazuya91:
I did exactly what you said. Before I do a "Wire.begin()" I set the following settings:

pinMode(SDA_PIN, INPUT_PULLUP);

pinMode(SCL_PIN, INPUT_PULLUP);
Wire.setClock(10000);




It did improve the situation a little bit. On 2 of 3 reading-processes I got the right time. On the third reading I got garbage again. So I cant rely on the internal pullup-resistors for SDA and SCL.

Hmm, interesting, thanks. It was meant more as a workaround until you get the right components; sometimes I just want to make a little progress in a project with just what I have in front of me.
As an additional extreme hack, you could also connect up another one or two idle digital pins in pull-up mode to each of the SDA and SCL pins to bring the pull-up resistance down, but it would be pretty dirty.

Kazuya91:
Case 1: I remove the entire block.

If I remove the entire block, which is the most easy way I need to add external pull-up resistors for SDA, SCL and SQW. Not just for the SQW pin. Because otherwise I cant read/write to the RTC properly. Is that right?

Case 2: I cut the trace.
If i cut the trace, I dont need to remove the resistor block. Because I didnt remove the block I can still properly read/write to the RTC. But I need to add an external pull-up resistor to get the SQW-Interrupt in Battery mode. If i am lucky and my ESP32 internal pull-up resistors are good enough I can set the interrupt pin from the ESP32 via

pinMode(RTC_INT_PIN, INPUT_PULLUP);

..and dont need to add an external pull-up resistor for the SQW-Pin. If not, I need to add an external one.

Case 3: Instead of cutting the trace I unsolder the corresponding pin from the resistor for SQW.
The rest is the same like Case 2 except I dont cut the trace.

That's my understanding.

Kazuya91:
Which pin for case 3 would that be? I marked 2 pins of the resistor on the picture. Are these the right ones? If yes, is unsoldering just one of them enough?

Unsoldering one is enough if you make sure the connection is broken.
You could check which pins do what by powering everything up and using a multimeter to check the voltage drop across each pair of pins when a pin is driven low, then measure again with the pin driven high.

Are you unable to solder the original resistor block back on with a pin snipped?

Yes, to program the RTC you need external pullups on SDA and SCL. That may need to be done only rarely.

For an alarm or 1Hz interrupt while the RTC is keeping time on battery power, you need a pullup to Arduino Vcc on SWQ/INT, with resistor pack removed or connections to it cut

Unsoldering one is enough if you make sure the connection is broken.
...

Are you unable to solder the original resistor block back on with a pin snipped?

Good to know. Unfortunately, i lost the resistor block. But it doesnt matter, they are not expensive. I am going to buy a new one.

Can someone provide a picture, where the trace is painted on the RTC? I know that there is a picture with the trace already cut which I uploaded, but it would still help when i got the trace highlighted.

Thanks, guys!

Kazuya91:
Case 2: I cut the trace.

Caution: What happens next depends on what trace you cut and where.
There are three things connected by that trace. The "SQW" connection to the board. The pull-up resistor pack, and the SQW/INT pin (pin 3) of the clock chip. You have to 'cut' between the resistor pack and the rest of the trace. If you cut between the SQW connector and the other two your Arduino signal won't go anywhere. If you cut between pin 3 and the other two, the chip pin won't be connected to your Arduino.
I can't find a picture that shows the traces well enough to tell if that is possible. I'm not even sure which of the four resistors is going to pin 3! If you are going to scrap your board and buy a new one, try removing all the components and taking clear pictures of both sides. Then we can say where to cut (if it is possible to cut).
You can avoid the issue by lifting pin 3 (3rd one from the corner marked with a dot) and connecting your Arduino pin directly to it.