[Solved] Problem with I2C components, conflict ?

Hi guys,

I've posted the same question in the French section (in case some french people read this before the other):
https://forum.arduino.cc/index.php?topic=663085.0

I'm currently working on a home automation controller project. I upgrade it sometimes with some new features.

To summarize, it is a box with a keypad and a LCD screen who display temperature of few sensors, store the measure history and compute the trend for each sensor. In addition, the box is connected with another module (radio, not Arduino) who send some orders to the box through digital inputs. These orders are interpreted by the box who will activate some relays. Also, the box will send/receive some data from another Arduino card (Uno) who is managing a touch screen (located in another room of the house).

Situation 1.0 (working fine)
I got an Arduino Mega on which the following stuff is connected:

  • LCD screen 4x20 (I2C)
  • Keypad
  • 3 digital temperature sensors (OneWire)
  • 4 digital inputs coming from the radio module
  • One 8 relays card
  • One buzzer piezzo
  • A serial line sending and receiving data from the second Arduino

All this is powered by a computer power supply. 12v for Mega card and 5v for the relays.

Situation 2.0 (not working)
I've done a little POC on a backup Arduino (Uno) card, it's a simple clock using a DS3231 and a small OLED screen who displays the time and date. Both running through I2C protocol.

The problem is, if I test this little clock alone, all is working fine. But when I integrate my clock in my box, it is not working anymore.
Symptoms:

  • My LCD screen doesn't work (even the backlight)
  • The program doesn't finish its initialisation phase (I don't hear the little BEEP from the buzzer, it normally happen at the end of the setup loop).
  • My OLED screen stay black
  • The DS3231's LED is blinking

So I've tried this:

  • If I cut the power of the DS3231 and I reboot the system, the box is working fine but the OLED screen stay black
  • If I cut the power of the OLED screen, nothing change
  • If I cut the power of the LCD screen, the program start properly and the DS3231's LED stay alight (not blinking)

Analysis attempt
According to the symptoms, I've think about an I2C address conflict. Unfortunately, every I2C component have a different address. So maybe it can be a conflict at components registers level, or a conflict in the libraries I use.

What do you think ?
PS1: I don't use native Arduino IDE, but VSCode with PlatformIO plugin
PS2: The libraries I use are:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <math.h>
//#include <Wire.h> // Deja defini dans le LiquidCrystal_I2C.h
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#include <DS3232RTC.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

The Adafruit GFX library uses a lot of memory and then you have so many more libraries. I think you are using far too much ram. Perhaps you are using the String object as well :o

You're right. I use the GFX library only to drive my OLED screen, I will check if I can do something lighter.

Btw another guy told me that it could be a power supply problem. And I discovered a bad contact on the power bus I've made myself. It could be also an option.

I will check that and revert to you guys.

Thanks for the lead.

You're right. I use the GFX library only to drive my OLED screen, I will check if I can do something lighter.

It's not the GFX library but the SSD1306 driver that uses more than half the RAM the UNO has. So either limit yourself extremely if you want to use the UNO or use the OLED only with the Mega (which has 4 times the RAM of an UNO).

Thanks for your informations ! Yes this code is running on the Mega card (not the Uno), that's why I wasn't really taking care of memory consumption when I wrote the program. But it is not a clean approach.

Btw I solved the problem. It was due to the bad contact in the power bus. The power wasn't stable and was going from 5v to 200mv.
I replaced it and now it is working fine. I was searching to a more complicated issue instead of checking the basics.

Thanks a lot for your help guys.