i2c Some general questions

Hi i have build a Pcb that has female pins to receive an Arduino pro mini. i am using an Ethernet port/terminal to connect my pcb with an other smaller pcb that has a small oled display.

the distance between them is very long and i understand that i2c communication protocol is not the best option about that so my question has to do to understand the reason about my "problems"

1st problem.. i am using a pro mini clone and i can achieve my oled display to work ... but if i use an other pro mini then the display cant work in that distance .
everything else is the same.. just replacing the pro mini (the same pro mini works fine in the short distance... so it has to do with the pull up resistors... but as i am using the same pcb with external pull up resistors what is the difference ? )

2nd problem... the pro mini that works ok with the oled display works fine but after some time stops connecting with oled ... i have made my program to reset every some time in order to make it work even longer time withour freezing... but after some time again it freezes (the arduino works ok from serial communication )

when that happens then the arduino cant connect with i2c protocol even with the short distance. it is like the sda scl pins are burned ...
if i burn again my code to the arduino then the pro mini works again fine.. it is like the sda scl start working like something was wrong

i know that the problem is the long distance... just want to know what is happening and the arduino stops function the sda scl after long freezing time and the only solution to make them work is to re burn my code

3d question... where is the best position to place the external pull up resistors for the i2c ?
near to the master device or near to the slave device ?

thanks in advance

ps : i know that the obvious reason is the long distance... but what is happening in each case of my problems...

When something is barely working, then the noise level becomes important.
The cheap clone boards have often the minimal amount of decoupling capacitors. They are already noisy by themself.

  1. It is possible that one board has better decoupling of the 5V or 3.3V. Or one board is running at a slightly higher voltage than the other.

  2. I don't know. The Wire library has no timeouts for certain bus errors, so it can halt a sketch. After a restart it should work again. Perhaps something else is in a wrong state. If you power everything off, and wait a minute, then it should work again.

  3. There is no "best" option for short wires. The most common way is pullup resistors at the Master.

Do you think that you can fix the I2C bus and make it reliable ? I think this will never be reliable.

Thanks for the help :slight_smile: make me understand the reason behind my problems

about :

  1. the weird about that is that stops working my oled i2c display but the sketch running fine (i tested several times with the serial communication that is running fine )

i tried to power it off for several minutes and start again but still after that no way to make it "see" the display..
the only solution is to re burn my sketch again and then sda ,scl pins start working again.. weird

about if i can fix the i2c bus to make it reliable for that distance... no i think i can't if i don't use some external i2c buffer ics

so i have to decide if i will use the i2c with buffers or should i use an isp protocol

thanks again for your help

Trouble with the I2C bus is often caused by:

  • Arduino Due (wrong onboard pullup resistors, no slew rate limit).
  • OLED displays (not 100% compatible).
  • Long wires.
  • Crosstalk between SDA and SCL.
  • Voltage level mismatch.
  • Wrong use of the Wire library.
  • Too much or too little pullup.

With long cables (longer than 50cm) there is extra capacitance between SDA and GND and between SCL and GND. You can lower the clock speed for that. Crosstalk between SDA and SCL is worse.

As far as I know, the OLED displays are 3.3V, and if the SDA and SCL have no level shifters, then they should be connected to a 3.3V I2C bus. The Adafruit OLED displays have level shifters. OLED displays are known to cause I2C bus troubles.

We use the term "upload" to write a new sketch in the Arduino and we use the term "burn" when writing a new bootloader in the Arduino.

Those OLED display can be a little glitchy.
They do not bring out the reset pin either normally.
Perhaps a transistor driving the power for the OLED would give a reset method.?

I would not be convinced it is bad I2C.
I have used crazy long cables in the past and my environment is always noisy.
Not say short cables are a bad thing but it could be something else.