Problem with display (Nano - TCA9548A - i2C Sensor - i2C SH1106)

Hello, I'm new on arduino. I've created board to get distance and display it on OLED (SH1106).

First method, I'm using :
1 Arduino Nano - 1 TCA9548A (i2C) - 3 TOF10120 Sensors (on channel 4, 5, 6) and 3 1.3" OLED SH1106 (on channel 0, 1, 2) and a push button to switch display on each OLED. But this schematic consume high memory, about 83% - using U8g2 lib. And the result is sometimes OLED not display anything till I pressed reset button few times and lagging if I push the button for switch display result.

So I tried to split schematic into this :

  1. Arduino Nano 1 - multiplexer TCA9548A - 3 sensors (TOF10120)
  2. Arduino Nano 2 - multiplexer TCA9548A - 3 OLED SH1106

Arduino 1 send data from 3 sensors using i2C comm to Arduino 2 and Arduino 2 display the data on OLED, so each arduino have connection on pin A4 (SDA) and A5 (SCL) with Multiplexer and to another arduino.

The goal is to reduce each arduino memory, now I got about 50% memory only for each Arduino. But I'm facing a problem that sometimes OLED not display anything (black) - I dont know if there was error on bread board or not.

So, the questions :

  1. Is my scenario to split and communicate data-display between 2 arduino is visible? because I'm still using only 1 sensors to trial (2 sensors are dead because over voltage on another trial scenario)

  2. What factor do I must concern for displaying via OLED SH1106 via U8g2 lib because sometimes works well but if the arduino is turned off and on again, the display is black and not working even I pressed the reset button

Many thanks for helps

Most beginners go for a multi processor system when they run out of memory but there are many ways of reducing memory usage. The biggest one being is to use the U8g2 lib a bit more smartly, and split the display buffer into a quarter of the size and then have four writes to make a full screen display. Details of how to do this are in the library documentation and examples.

Next all literal strings, things in quote marks, take up program memory, look up the Arduino’s F macro to see how to cut down on the memory that takes.

Then see if you can save some bytes by making variables that only hold small numbers into byte types instead of ints.

1 Like

Thanks for reply, I used this constructor for reduce memory size :

U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE)

and choose font with "tr" and just a number "tn" for draw display result.

And so create some global function and variable to reduce memory size/sketch.

split the display buffer into a quarter of the size and then have four writes to make a full screen display

Can you help me about this method for u8g lib?

Click on the File Menu, select the Examples option, scroll down until you see the u8g2 folder, follow the link to "full buffer" and then again to UpdateArea. This example shows you how to use
U8g2lib Example Overview:

  1. Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption

  2. Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.

  3. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.

Many thanks for you guidance.