I2C LCD Freezes UNO board

I've used a lot of LCD displays with the I2C backpack without issues.

Today I was starting on a new project and connected a generic 16X2 LCD with an I2C backpack on to an UNO board and loaded a basic sketch to get started. IDE successfully loaded the sketch. When I looked at the LCD there was nothing on the screen. I thought maybe the contrast pot on the back needed adjustment but still nothing.

Thinking either the LCD or the I2C was bad I swapped it with another LCD and I2C from another working project and the one I though was bad worked fine on the other project.

I connected the known working LCD and I2C from the other project board to this new one and nothing.

I swapped UNO boards and reloaded the basic LCD sketch and still nothing.

I added code to the sketch that blinks the onboard LED on pin 13 and a print line to the serial monitor.

What I found is that while the I2C's SDA (Connected to the UNO's SDA pin) and the I2C's SCL (Connected to the UNO's SCL pin) are connected the UNO sketch is frozen. As soon as I disconnect them the LED on pin 13 starts blinking and I can see the text messages come across the serial monitor.

I also tried alternating the I2C's connection between the UNO's SDA/SCL pins and A4 and A5 and it made no difference.

I tried using a sketch to scan for I2C address and it also freezes until I unplug the I2C from the UNO board.

What am I missing?

Here is the basic LCD script:

#include <Wire.h>                        // Invlude library to communicate to I2C
#include <LiquidCrystal_I2C.h>           // Include LCD with I2C backpack

LiquidCrystal_I2C lcd(0x27, 16, 2);      // Initialize LCD on address 2x27 with a 16 x 2 display

void setup() {
  lcd.init();                            // Initialize I2C LCD display
  lcd.backlight();                       // Turn on LCD back light
  lcd.clear();                           // Clear the LCD screen
  lcd.setCursor(0, 0);                   // Set LCD cursor to 1st position on first line
  lcd.print("TEST Line 1     ");         // Send text to LCD
  lcd.setCursor(0, 1);                   // Set LCD cursonr to 1st position on 2nd line
  lcd.print("TEST Line 2     ");         // Send text to LCD
}

void loop(){}

This sketch will not blink a LED on pin 13.

Please show pictures of your devices in "non working condition". We should be able to see each cable - each module including the power source if not powered by USB.

PS: imho your topic is better suited for the area "Displays". You can move the topic when you edit your topic title in post #1.

1 Like

HI noiasca, thanks for the reply.
I am not trying to blink an LED, I am trying to get the LCD to work. I only temporarily added the LED blink and Serial print to see if the Sketch was running and it wasn't.

@essejcds
You should post the code you are actually using to get the results you are experiencing.


The hd44780 library supports this type of LCD device and includes a diagnostic example that will perform various tests and report any issues it discovers.
Here is a link to the hd44780 library hd44780_I2Cexp i/o class that has more information:

The hd44780 library can be installed using the IDE library manager.

--- bill

1 Like

This is the actual code. I'm starting a new project and I can't get passed the LCD.

The library I'm using is the same library I've used over and over without issues. Besides no matter what library I use the sketch stops running until I disconnect the I2C. After the I2C is disconnected I don't know what kind of diagnostic I could run since it is no longer connected...

Not its not. You said:

I added code to the sketch that blinks the onboard LED on pin 13 and a print line to the serial monitor.

But the code posted does not do this.
You have not posted the code you are actually running.

This was also pointed out by @noiasca in post #2

We also have not seen your wiring.
Hangs can be caused by wiring issues.

Again, the hd44780 library I2Cexp diagnostic sketch will do some testing, including on the I2C signals, and report any issues it discovers.
It may still hang but it might also be able to detect some issues on the i2c signals.

--- bill

@bperrybap,

If you look at post #3

It is not part of my code, nor do I need it in my code. I only used it to test if the sketch was freezing. The code posted is the only thing that is in the sketch and the only thing connected to the UNO board is Vcc, Gnd, SDA and SCL from the I2C.

Do you have a link to the library? Your link seems to only link to other examples but not the actual library.

I'll try the driver you suggested and let you know what if any results.

Use the IDE library manager to install it. Easy Peasy.

While you can get in zip form from github on the hd4480 repository on the same repository where the wiki is, it is better to use the IDE library manager.
If you use the zip file for the library not only is it more work, but it will not be installed properly unless you rename the top level directory.

It sounds like it is not a library issue but some sort of h/w issue.
The diagnostic tool will look for shorts or missing pullups on the I2C bus.

In the mean time can you post a few photos of your setup?
photos that include the cabling/wiring between the LCD and the UNO.

--- bill

It sounds like you have a wiring problem that is shorting out the power and shutting down the Arduino. Show the wiring that people have been asking for.

1 Like

Wiring in the photo seems ok.
I'll be curious if I2CexpDiag reports any issues.

The Wire library can lock up under certain situations.
But that normally takes some kind of noise on the signals or multiple masters.
There are some Wire library options available in the newer AVR Wire library that enable timeouts so that lockup will not occur.
Unfortunately it is AVR Wire library specific and the timeout is not enabled by default.

--- bill

@oldcurmudgeon, @bperrybap,

Never mind, I figured it out while taking the picture for the wiring...
I had the GND and SDA cables inverted.

I have been staring at this for two or three days and never noticed it looking for every other possible problem. I am stupid I know. :smile:

Bummer.
Often it is the simplest goofy stuff that trips us up.

--- bill

I got tired of having my own wiring issues.
In my case not all the backpacks I test have the i2c pins in the same order.

To resolve it I typically use either a shield that has 4 pin i2c headers or some clone boards that have 4 pin i2c headers.
All these have the same pinout.

I then just flip the wires on the LCD backpack side if necessary.

--- bill

1 Like

I thought I was going crazy. I was looking for every possible culprit no matter how complicated it could be. And I was staring at it the entire time and completely blind to it as somewhere in the back of my mind it refused to even bother looking at the wiring as "I" couldn't possibly do something so stupid.

Thank you all (@noiasca, @bperrybap and @oldcurmudgeon) for pointing me in the direction that solved the issue.

Sometimes with bad wiring and bad code we see what we meant - not what we actually did :slightly_smiling_face: . That is why having someone else look at it can help.

You are 100% and I am proof! :wink: :+1:

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