20x4 LCD Displays Gargled Characters When Powering Up (Due)

I've attached an I2C 20x4 LCD to an I2C multiplexer, then to my Arduino Due. It works fine, but only once the Arduino has been reset at least once after being powered up.

This is what it looks like when you plug in the board and do nothing:

This is what it's meant to look like (and does after restarting the board):

This can't be an error related to code as it only happens once after powering up. I've already checked all connections, nothing appears to be out of the ordinary.

Does anyone know what could be wrong with this?

This is the code that initializes the LCD:

// main.cpp
  Init();
  setIcons(icons, num); // Icons are defined in another file

// Display.cpp
    void Init()
    {
        selectLCD(); // Selects the channel for the LCD on the multiplexer
        Serial.println("Starting I2C LCD");
        lcd.init();
        Serial.println("Setting backlight value");
        lcd.backlight();
        lcd.cursor_off();
    }

    void setIcons(const byte ico[][8], byte numIcons)
    {
        selectLCD();
        for (byte i = 0; i < numIcons; i++)
        {
            byte tc[8];
            for (byte j = 0; j < 8; j++)
                tc[j] = pgm_read_byte(&(ico[i][j]));

            lcd.createChar(i, tc);
        }
    }

It's like the power up reset on the LCD controller isn't done housekeeping when you start to work with it. Have you tried a simple delay in init(), before you do anything with the LCD?

Not in the init function, but earlier in the setup function.

I'll try that though.


I added a two-second delay but got the same result on startup. I really thought that was the issue for a second because it makes sense.

It's about the only thing I can think of that would be different between a reset and a power up; reset doesn't generally hammer the LCD at all, it's up to the programmer to get the LCD sorted after a reset, but the LCD chip does have it's own power up sequence.

@bperrybap might be able to help you better, he's the resident LCD guru.

Hi,
Have you considered that the DUE is 3V3 I/O and the LCD is basically a 5V device.

Tom.. :smiley: :+1: :coffee: :australia:

1 Like

Wouldn't that affect the functionality all the time rather than just when it's running for the first time?

Hi,
Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Im not sure how to make a schematic.
I will say that the only power supply is directly from the 5v and 3.3v pins on the Arduino.
I'm using the I2C pins for the multiplexer, and the LCD is connected to SD0 and SC0 of the multiplexer.

It is impossible to say what could be happening without some additional information.

  • What LCD h/w are you using?
    All you said is you have "an I2C 20x4 LCD"
    We need more details on the exact h/w you have.
    i.e. is it a PCF8574 based i2c backpack or is it a LCD with a native i2c interface?

  • What LCD library are you using?
    Even better, post all your code so we can see everything.
    You have a somewhat complex environment so we to need see all the code.

  • a schematic
    we need to see exactly how you have everything wired up especially since this is more than just connecting an LCD device directly to the Arduino.

If you have a 5v LCD using a PCF8574 backpack running at 5v, you really should be using a level shifter to create 2 i2c buses that are bridge together.
(I ALWAYS use them when connecting 3v masters and 5v slave I2C devices)
A 3v bus for the 3v Arduino that is bridged to the 5v bus for the i2c backpack with the LCD. (in your case between the 3v Arduino and the TCA9548A)
While you can sometimes get away not using a level shifter, I would not recommend doing it since it often has issues because you can't directly connect 3v masters to 5v slaves without violating the i2c specs.
And to do this 3v/5v mixing without a level shifter you will have to modify the backpack to eliminate pullup resistors to 5v.
In your case you would also need to modify the multiplexer board to disconnect the pullup resistors on SDA and SCL that connect to VIN/VCC.
And then I'm not sure if it would work since I have no experience using that multiplexer to know if it will operate when violating its specs by running it at 5v when connected to the 3v master.

The most common issue when attempting to mix 3v masters and 5v slaves without using a level shifter is communication glitches that eventually causes a loss of nibble sync between the Arduino and the LCD. Loss of nibble sync will cause the LCD to display garbage.

--- bill

Hi,

Why do you need a I2C Multiplexer?

Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

The power on self test is an alternating row of boxes, sorta what you've got on the top less the tearing.
This looks like an internal timing error on the LCD itself. Dollars to donuts, the issue will not show up with a different LCD.
Since it is a transient issue at power up, mask it with a lcd.clear as soon as you can, and throw a copyright or splash screen to cover the glitch.

That worked!
Thank you!

For the startup screen, I used a block of code found here.

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