LCD 16x2 with I2C not working

Hello everyone , first of all im sorry if i didnt posted in the right place , im new with arduino , and i need to make a project but my LCD it s not working at all with simple s programs that i found on internet , like "Hello World" program , i runned that sketch for I2C scanner and the the result was "The i2C was found and the adress is 0x27"
I don t know what to do anymore , if someone can help me i would be very grateful :slight_smile:
I will leave a photo here with the problem , even i move a little the I2C from that position the display is blue and that s all

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

Install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.

In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results.

Also there is the contrast adjustment, usually a small blue trimpot on the I2C expander backpack. If that is not adjusted properly the display will show nothing or just boxes.

Hi , so im not sure if i did the right thing here , it s my second time using Arduino but i hope this is what you wanted me to do

Hi , so im not sure if i did the right thing here , it s my second time using Arduino but i hope this is what you wanted me to do

Yes that is good except it would be better if you copy the text from the serial monitor window and paste the text to a new post (in quote tags) instead of a screen shot. It would be easier to read.


How to post an image.

I have not seen that error before (LCD stuck BUSY status). Bill Perry, the author of the library, is often on this forum and probably knows just what that means and what to do.

In the meantime, can you post close up photos of the I2C backpack wiring? We would like to see the solder joints on the I2C expander chip and the soldering of the header between the backpack and the LCD? There have been bad solder joints spotted there in the past.

Oh , sorry and thank you , so i used that library example with hellow world , and somehow it printed the message . But becouse im newby i have another question: i need to make a coin sorter , and on this display will need to show me the total coin s the sensor s detected (i have a bad english sorry for that ).
The question is i would need to use all those 3 libray s so the display would work ?

#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
hd44780_I2Cexp lcd2(0x27);
// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;

void setup()
{
int status;

// initialize LCD with number of columns and rows:
// hd44780 returns a status from begin() that can be used
// to determine if initalization failed.
// the actual status codes are defined in <hd44780.h>
// See the values RV_XXXX
//
// looking at the return status from begin() is optional
// it is being done here to provide feedback should there be an issue
//
// note:
// begin() will automatically turn on the backlight
//
status = lcd.begin(LCD_COLS, LCD_ROWS);
if(status) // non zero status means it was unsuccesful
{
status = -status; // convert negative status value to positive number

// begin() failed so blink error code using the onboard LED if possible
hd44780::fatalError(status); // does not return
}
// initalization was successful, the backlight should be on now

// Print a message to the LCD
lcd.print("Hello, World!");
}

void loop() {}

groundFungus:
Yes that is good except it would be better if you copy the text from the serial monitor window and paste the text to a new post (in quote tags) instead of a screen shot. It would be easier to read.

Aarrgh!

In "code" tags, not "quote" tags! :astonished:

Common1995:
Hi , so im not sure if i did the right thing here , it s my second time using Arduino but i hope this is what you wanted me to do

That error means that the library was looking for the LCD to be ready to accept commands but it is seeing a BUSY status that means it is unable to accept a command, and that BUSY status is remaining busy much longer than is normal.
Essentially, the diag sketch is thinking that there is a h/w issue.

Can you post some clear photos of your backpack, and LCD so we can see the backpack and the soldering?
Specifically what I want to see is the soldering of the 16 pins to the LCD module and the backpack itself including with enough detail to see the soldering of the PCF8574 pins to the backpack PCB.

I would highly recommend getting the diagnostic sketch working before moving on to other sketches/things as there is definitely some sort of issue.

--- bill

Also, while it shouldn't matter for this type of issue, you may want to update the hd44780 library to the most recent version.
--- bill

Common1995:
The question is i would need to use all those 3 libray s so the display would work ?

While there are 3 header files being included, there are only two libraries. Wire and hd44780

Why did you modify the example code to add this line?:

hd44780_I2Cexp lcd2(0x27);

It is declaring a 2nd hd44780_I2Cexp object called lcd2 that is not used or needed.

But before anything else with the hd44780 library, lets get the diagnostic sketch working with your lcd device.
Post the photos so we can take a look at what you have.

--- bill

Hi , i didnt soldering them yet , becouse i tried at the begin 2-3 codes it didnt work so i just hold it in the right position and when i modified that it worked , until then it didnt work.

1.jpg 2.jpg

3.jpg 4.jpg

Common1995:
Hi , i didnt soldering them yet , becouse i tried at the begin 2-3 codes it didnt work so i just hold it in the right position and when i modified that it worked , until then it didnt work.

You do not realise how often we have heard that story!

Unless you actually connect the parts - by soldering - they will not work. :roll_eyes:

I need to soldering it in the right position no ? i mean when i see those square s right ?

Ok , im so sorry guy s , thank you so much , i will soldering them tomorrow , and comeback with a reply and even a photo to see if it s ok :slight_smile: . Thank you again for your time guy s .

Aarrgh!
In "code" tags, not "quote" tags!r

I thought that the output of the diagnostic sketch, copied from the serial monitor window, should go into quote tags. If it is more proper to post that in code tags, I will do it that way.

groundFungus,
The only reason I think of for using code tags over quote tags for serial output is that code tags uses a fixed width font which, depending on the output, might look better.
Also, if a fixed width font is desired, the Teletype tag will provide that.

There are cases where I use either the code tag or the Teletype tag for posting serial output but often it it doesn't matter as there are no aliment issues.

--- bill

There are three very good reasons for using "code" tags, exactly the same as for posting code. :sunglasses:

  • "Quote" puts it in all italic, which is actually harder to read. Italic is only appropriate for emphasis.
  • Unless you use "code" (or "Teletype"), anything that resembles markup such as bold or smileys, will be translated. And conversely, italic markup will not be translated. (This causes array indexes using "i" to vanish and "8" to grin!)
  • "Code" tags "box" the code - but in an extensible box - so that longer extracts are manageable (easier to pass over) on a display.
  • The fixed width font facilitates indentation and matches - of course - "teletype" display as on the Serial Monitor or status window.