I came across this stackoverflow response which points out to this paragraph of the DS3231 datasheet:
Then he gives an example of such function for the ESP8266, but his code doesn't seem to be compatible with the ESP32. I would assume that just using digitalRead and digitalWrite on those pins is not an option based on the example but I honestly don't know how else could I implement it.The I2C interface is accessible whenever either VCC or VBAT is at a valid level. If a microcontroller connected to the DS3231 resets because of a loss of VCC or other event, it is possible that the microcontroller and DS3231 I2C communications could become unsynchronized, e.g., the microcontroller resets while reading data from the DS3231. When the microcontroller resets, the DS3231 I2C interface may be placed into a known state by toggling SCL until SDA is observed to be at a high level. At that point the microcontroller should pull SDA low while SCL is high, generating a START condition.
Thank you.