I am working on a project that uses a DS3232. The hardware is a Wemos Lolin32 and a DS3232 RTC. The DS3232 is supposed to be addressed at 0x68 on I2C.
Although properly connected, the program returned "DS3232 not found".
So I started debugging by first using the WireScan demo of the Wire library. That showed the correct result as you can see in the below picture left side.
I then commented out the original code on the first program and copied and pasted EXACTLY the same code to my other program. As you can see in the picture below right, it detects the DS3232 at address 0x3C (well, that's what it returns), with EXACTLY the same hardware and EXACTLY the same code.
Does anyone have a plausible explanation and preferably a solution for this, to me unexplainable, issue?
To a possible solution. If it were another device, yes. But there's only one. It's the same hardware. And there is no 0x68 address further down below in the second output.
Then why aren't both detected?
The RTC is on soft-I2C (pins 4 and 5)
Output from the first one (which detects the 68);
Error 2 at address 0x3A
Error 2 at address 0x3B
Error 2 at address 0x3C <==
Error 2 at address 0x3D
Error 2 at address 0x3E
vs output from the second one (which detects the 3C):
Error 2 at address 0x66
Error 2 at address 0x67
Error 2 at address 0x68 <==
Error 2 at address 0x69
Error 2 at address 0x6A
For example, you might have an intermittently functional RTC, intermittent solder joints or other connections, or perhaps the required pullup resistors are too large, and communications are unreliable. To test the latter, try adding 4.7K pullups to Vcc from SDA and SCL.
The program I used was the home NTP server from Elektor.
That is normally based on a DS3231 board. I used a DS3232 board on which the pins SDA and SCL were reversed.
Hence I changed the soft-I2C wire.Begin(5,4) to wire.Begin(4,5), which worked fine for the scan.
However, in the main program, there was also this to initialize the display:
Normally I wouldn't. But the hardware part is a sandwich. And the SDA and SCL pins of the used DS3232 board are such that they coincide with pins 4 and 5, BUT in the wrong order. I can't change the SDA/SCL order of the RTC board, so I had to on the ESP32 side.