HELP! I2C LCD 16x2 display not working!

Hello guys!
I have an 16x2 lcd whit i2c adaptor.
In 1-2 day after arrived working corrently.
I check wiring s correct.
But now the lcd,not work correct.





So i don't know wahts the problem :frowning:
PLZ! help i need this modul for my project!
Oh, this is my code:


#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h> // F Malpartida's NewLiquidCrystal library
#define I2C_ADDR 0x27 // Define I2C Address for controller
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define BACKLIGHT 3

LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);

byte batt1[8] = {
0b01110,
0b11011,
0b10001,
0b10001,
0b10001,
0b10001,
0b10001,
0b11111
};
byte batt2[8] = {
0b01110,
0b11011,
0b10001,
0b10001,
0b10001,
0b10001,
0b11111,
0b11111
};
byte batt3[8] = {
0b01110,
0b11011,
0b10001,
0b10001,
0b10001,
0b11111,
0b11111,
0b11111
};
byte batt4[8] = {
0b01110,
0b11011,
0b10001,
0b10001,
0b11111,
0b11111,
0b11111,
0b11111
};
byte batt5[8] = {
0b01110,
0b11011,
0b10001,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte batt6[8] = {
0b01110,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte gsm[8] = {
0b00000,
0b00000,
0b00000,
0b00001,
0b00011,
0b00111,
0b01111,
0b11111
};
byte down[8] = {
0b00000,
0b00000,
0b00000,
0b11111,
0b01110,
0b00100,
0b00000,
0b00000
};
byte up[8] = {
0b00000,
0b00000,
0b00000,
0b00100,
0b01110,
0b11111,
0b00000,
0b00000
};
byte ctlogo1[8] = {
0b00000,
0b01110,
0b11110,
0b11000,
0b11000,
0b11110,
0b01110,
0b00000
};
byte ctlogo2[8] = {
0b00000,
0b11111,
0b11111,
0b01110,
0b01110,
0b01110,
0b01110,
0b00000
};
byte sim1[8] = {
0b00000,
0b00000,
0b00000,
0b11111,
0b11111,
0b00000,
0b00000,
0b00000
};

void setup()
{
lcd.begin (20, 4); // initialize the lcd

// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT, POSITIVE);
lcd.setBacklight(HIGH);
lcd.createChar(10, batt1);
lcd.createChar(1, batt2);
lcd.createChar(2, batt3);
lcd.createChar(3, batt4);
lcd.createChar(4, batt5);
lcd.createChar(5, batt6);
lcd.createChar(6, gsm);
lcd.createChar(7, down);
lcd.createChar(8, up);
lcd.createChar(9, ctlogo1);
lcd.createChar(10, ctlogo2);
lcd.createChar(11, sim1);
}

void loop()
{
lcd.setCursor(4, 1);
lcd.print("Security");
lcd.setCursor(2, 1);
lcd.print(char(7));
lcd.setCursor(13, 1);
lcd.print(char(8));
lcd.setCursor(6, 0);
lcd.print(char(9));
lcd.setCursor(7, 0);
lcd.print(char(10));
lcd.setCursor(8, 0);
lcd.print("OS");
lcd.setCursor(10, 0);
lcd.print(char(11));
lcd.setCursor(11, 0);
lcd.print(char(11));
lcd.setCursor(12, 0);
lcd.print(char(11));
lcd.setCursor(13, 0);
lcd.print(char(11));
}


Anyone know whats the problem reply!

Have already tried adjusting the contrast pot?

lcd.begin (20, 4); // initialize the lcd

You said you have (and the pictures show) a 16,2 LCD.

oh thanks wait i edit code and i view

i edited the code but did not work

In 1-2 day after arrived working corrently.
I check wiring s correct.
But now the lcd,not work correct.

Are you running the same code which worked correctly when the device was first used?

If that is the case, start by changing all 4 wires going to the lcd.

Does this i2c scanner find the device?

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

yes i2c find the adress is: 0x27

and yeah i runned whit this code from begining

I would suggest that you install my hd44780 library and run the included diagnostic sketch.
It will test your i2c lines and the RAM inside the LCD.
You can install it from the IDE using the library manager.
You do not have to modify or uninstall any existing library.
You can read more about the hd44780 library here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
The i/o class you will use is called hd44780_I2Cexp and the diagnostic sketch is called I2CexpDiag

Note that any existing sketches you have will have to be modified to use the hd44780_I2Cexp class if you want to use this library to run your lcd.
IMO, hd44780 is easier to use as it will automatically locate the i2c address and determine the pin mappings.

--- bill

bperrybap:
I would suggest that you install my hd44780 library and run the included diagnostic sketch.
It will test your i2c lines and the RAM inside the LCD.
You can install it from the IDE using the library manager.
You do not have to modify or uninstall any existing library.
You can read more about the hd44780 library here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
The i/o class you will use is called hd44780_I2Cexp and the diagnostic sketch is called I2CexpDiag

Note that any existing sketches you have will have to be modified to use the hd44780_I2Cexp class if you want to use this library to run your lcd.
IMO, hd44780 is easier to use as it will automatically locate the i2c address and determine the pin mappings.

--- bill

I installed the hd44780 library and ran the HelloWorld example.... to no avail :-(. I have been trying to get this I2C LCD display working for a few days now with many different example programs but without success. The backlight works and I have been able to switch it on and off via the I2C interface. But no text is displayed! What can I try now?

Thanks!
Michiel

Which hd44780 class example did you try? The class to use for your display is the hd44780_I2Cexp class. If you look at the examples in that class you will see the I2Cexpdiag example. Load and run that example. Please post the results as shown on the serial monitor. Select (CTRL_A) the text, copy (CTRL_C) the text and paste the text into a post. That will provide information that we can use to help you get your display to work.

michielper:
I installed the hd44780 library and ran the HelloWorld example.... to no avail :frowning:

Why did you choose to not run the diagnostic sketch, I2CexpDiag as recommended?

--- bill

michielper:
The backlight works and I have been able to switch it on and off via the I2C interface. But no text is displayed! What can I try now?

Do you understand the operation of the contrast potentiometer?

You say "no text is displayed"; you do not say what is displayed. :roll_eyes:

groundFungus:
Have already tried adjusting the contrast pot?

lcd.begin (20, 4); // initialize the lcd

You said you have (and the pictures show) a 16,2 LCD.

That's not a serious problem: it just gives the driver the wrong info, so text may be displayed incorrectly. And setting a 2004 to 1602 gets it to use only part of the display.

The image in #0 looks like the contrast pot needs some attention.

wvmarle:
The image in #0 looks like the contrast pot needs some attention.

The 2 images in the first post that show the display do not look a contrast issue to me.
If the contrast was way off you would either see no pixels at all or both text lines with all pixels on.
The photo(s) in the original post show a single text line with all the pixels on which is the default state on power up before initialization. Note that the 2nd line of text has no pixels lit. This indicates a proper contrast setting.

The most common causes of this are:

  • incorrect/bad/poor wiring.
    In this case the soldering on a few pins like RS and D3 do look a little suspect.

  • the pin mapping/wiring between the PCF8574 to the LCD is different from what the library is using.
    This can be avoiding by using the hd44780 library which probes the i2c backpack & LCD to figure out the proper pin mapping.

I'll repeat again, the first thing to run when using the hd44780 library with that type of LCD, which uses the hd44780_I2Cexp i/o class is the I2CexpDiag sketch which runs diagnostics to verify that the library and h/w are working properly.
The output of this can be used to help determine any issues.
After that, then you can move to using the other hd44780_I2Cexp i/o class examples and start using the library with you own sketches.

--- bill

try connecting lcd sda -> arduino sda(near pin 13)
lcd scl -> arduino scl(next to sda)

gtsol:
try connecting lcd sda -> arduino sda(near pin 13)
lcd scl -> arduino scl(next to sda)

I2CexpDiag prints out which pins are SDA and SCL as part of the diagnostic output and then tests them for pullups and connectivity.

bperrybap:
The 2 images in the first post that show the display do not look a contrast issue to me.

But we are no longer talking about the first post at all. :astonished:

michielper has introduced a quite new problem. We need to know what he is seeing and I suspect the contrast is the problem.

Paul__B:
But we are no longer talking about the first post at all. :astonished:

I was responding to wvmarle who sounded like he was talking about the images/photos in the first post:

The image in #0 looks like the contrast pot needs some attention.

--- bill

bperrybap:
I was responding to wvmarle who sounded like he was talking about the images/photos in the first post:

Well he is a trifle late. That's all I can say!

I found the same problem, then I tried I2Cexpdiag the result as attached files,