Unexplainable results from I2C (Wire library)

Hi all,

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?

Please do not post pictures of code or Serial monitor output

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

That could be some other I2C device. Try removing the DS3232 and running the program again.

When posting code, please post ALL of it, using code tags.

I know, it was just to show the windows side by side. Thx for the remark.

Accidentally deleted the post.

Here it is again.

Unfortunately not.
Exactly the same hardware (physically), just flashed with the first or the second code.

To what does "Unfortunately not" refer?

The Wemos Lolin32 has an I2C display, with address 0x3C.


  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C, false, false)) {

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

Good question, with many possible answers.

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.

Thx .
It's not THE solution, but it leads to the solution, :wink: .

When you determine the real problem, please post that, and the solution.

Solution:

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:

U8G2_SSD1306_128X64_NONAME_F_HW_I2C oled_left(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 4, /* data=*/ 5);

U8G2_SSD1306_128X64_NONAME_F_HW_I2C oled_right(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 4, /* data=*/ 5);

And those pin assignments also needed reversing.

Why not just wire the correct signals to the module? Reversing using software seems odd, as you have found it made necessary other software changes.

a7

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.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.