OLED hang on Arduino Nano

On my 6 Channel Remote Control project, I discovered it hang at random time within ~15 minutes. Accidentally I discovered that it will immediately hang when I touch the I2C line (SDA, SCK). Another observation is the OLED is glitching randomly. Initially I though it is separate issue but the solution for hang also solve the glitching.

(1) At first I though maybe because of noisy power supply causing the microcontroller to hang. So I add 100uF capacitor on the 5V. It does help, still hang

(2) Since it was immediately hang when I touch the SDA/SCK, maybe by touching I'm adding capacitive load, slowing down I2C signal and causing communication error to OLED. I add 4.7K pull-up resistor to increase rise time but it make it worst, the remote control hang immediately after displaying welcome message on OLED even without touching SDA/SCL 😱.

Not a clue what going on, I hook up oscilloscope and see something interesting. There are 2 clocks frequency during communication, 99kHz on the left and 397kHz on the right. The LCD maximum I2C interface speed is 400kHz. I read here, apparently it switch back to 100kHz after SSD1306 library call because other device may not compatible with high speed.

Rise time without pull up resistor.

Faster rise time with 4.7k pull up resistor, which is expected but it does not help the problem.

(3) Since pull-up does not help, I try the opposite direction, adding capacitor to slow down the rise time. I experiment with couple of different capacitor value and find something interesting.
  • 1uF on both SDA and SCK, it does not even boot up. I probe SDA and SCK totally flat πŸ˜‚. Too much capacitance, filtered the whole signal.
  • 1000pF on both SDA and SCK, does not boot up. However, it is able boot up if I only put 1000pF on the SCK πŸ€”. Surprisingly it does not hang even after ON for 30 minutes 😊. Even more interesting the OLED stop glitching 😲. I solved 2 issues πŸ‘. 
I observed only 1 frequency at lower clock 76kHz. Could it be the clock switching causing the issue? Also look like "Adafruit 1306" library somehow did calibration to see which frequency can work.
  • 100pF, same as above it does not boot up if put on both SDA and SCK. This time I observed 2 frequencies again but at lower speed, 99kHz on the left and 250kHz on the right. No glitching and not hang after ON for 3 hours and counting πŸ‘. This experiment prove that the clock switching is not the cause of the problem. Issue solve even though the clock switching still there.

I could try experiment further with smaller value to see when it start to fail but too lazy 😁.

Although the issue resolve, I'm not sure what causing it. Could it be EMC? I2C clock signal couple to the Arduino Nano PCBA trace and causing some issue. I could try wrap the LCD module and interface wire with aluminum foil but too lazy 😁. As you can see from the photo, I have soldered everything nicely, it is too troublesome to remove everything and put it back again.

After the fix, no more glitch

Edited (February 7, 2025):
I did couple experiment with different capacitor value, results are sumarrize on the table below. I do not know whether OLED glitch and hang due to I2C CLK coupled to the LCD module or to the Arduino Nano module. I also do not know whether the glitch and hang resolve if I reduce the CLK frequency (I do not know the command to reduce CLK frequency) but without decoupling cap. It fixed and I'm happy about it πŸ˜‰

Comments

Popular posts from this blog

Building RC Plane Under 250 grams (Part 1)

A2212/5T 2450KV

Arduino Nano clone (fake FT232RL)