LCD display does not work, still black boxes

Hi.

I have NodeMCU V1.0 and LCD display GDM1602A with I2C PCF8574T.

SDA => D2
SCL => D1

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  lcd.begin(16, 2);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(5, 0);
  lcd.print("LOL");
  lcd.setCursor(5, 1);
  lcd.print("LOL");
}

void loop() {
}

But I still have black boxes.

What is my problem?

How did you power the display ? If it requires 5V, you should connect the VCC to the Vin of the NodeMCU.

Another possibility is that the I2C address of the display is not 0x27. Sometimes, it's 0x3F. To find it, run an I2C scanner sketch.

And, also, there is the pin mapping between the I2C expander chip pins and the LCD pins. Not all are the same. If your LCD pin mapping is not the same as the default mapping in the library the LCD will not work. I would suggest that you look into the hd44780 library. That library will automatically determine the I2C address and pin mapping. Use the hd44780_I2Cexp class. The library is well documented in the Wiki accessible from the linked page. The hd44780 library is available for installation in the library manager. Just put "hd44780" in the filter box to find it.

Have you tried adjusting the contrast?

lesept:
How did you power the display ? If it requires 5V, you should connect the VCC to the Vin of the NodeMCU.

Another possibility is that the I2C address of the display is not 0x27. Sometimes, it's 0x3F. To find it, run an I2C scanner sketch.

I have VCC in Vin and I2C scanner says 0x27.

groundFungus:
And, also, there is the pin mapping between the I2C expander chip pins and the LCD pins. Not all are the same. If your LCD pin mapping is not the same as the default mapping in the library the LCD will not work. I would suggest that you look into the hd44780 library. That library will automatically determine the I2C address and pin mapping. Use the hd44780_I2Cexp class. The library is well documented in the Wiki accessible from the linked page. The hd44780 library is available for installation in the library manager. Just put "hd44780" in the filter box to find it.

Thanks, I tried change contrast with potentiometr on the I2C board and it works.

I tried I2Cexp => Diag and I got this:

********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.0.1
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.7
Arduino Board: ESP8266_NODEMCU
CPU ARCH: ESP8266 - F_CPU: 80000000
--------------------------------------------------------------------
SDA digital pin: 4 (GPIO4) D2
SCL digital pin: 5 (GPIO5) D1
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
Checking for I2C pins shorted together - Not Shorted
--------------------------------------------------------------------
Scanning i2c bus for devices..
 i2c device found at address 0x27
Total I2C devices found: 1
--------------------------------------------------------------------
Scanning i2c bus for all lcd displays
No working LCD devices

But why LCD does not work?

I don't know enough about the NodeMCU board to be of any more help. Are level shifters required on the SDA and SCL lines? I don't know. The author of the library, bperrybap, frequents this forum often and may know what to do to solve your issue.

If you do a Google search for "esp8266 nodemcu 1602 I2C lcd" you will see how others connect the I2C LCD to nodeMCU.

I tried many examples from Google, but no example works for me.

OK, thanks.

I just verified that the hd44780_I2Cexp class works with the NodeMCU using the same version of the IDE and hd44780 library you were using.
I always use level shifters when using the ESP8266 as the LCDs I have are 5v and the NodeMCU is 3v logic.
Using a level shifter allows the PCF8574 and the LCD to run at 5v and interface to the 3v NodeMCU.

Can you explain and show a photo of how you have things hooked up?

--- bill

Thanks for reply.

NodeMCU is connected to the classic USB and to the PC. I2C board is connected in LCD display. VCC on LCD is in Vin on NodeMCU. GND on LCD is in GND on NodeMCU. SCL on LCD is in D1 and SDA is in D2. I2C board is still connected as I bought it.

It could be a voltage issue.
The NodeMCU is a 3v device. That backpack has pullups to VCC which you connected to Vin of the Node MCU.
Vin is from USB which is about 4.8 to 5v so the pullups on the backpack are pulling up the idle SDA and SCL signals to 4.8 to 5v.

The LCD wants to run at 5v but that is too high to interface directly with 3v logic like the NodeMCU and could potentially damage it.

This is why I always use level converters.
It allows the LCD to run at 5v and the host (the ESP8266) to run at 3v.

You can get cheap level converters on Ebay.

--- bill

bperrybap:
You can get cheap level converters on Ebay.

Which is very true, but a couple of diodes on SDA and SCL with cathodes to 3.3 V would probably sort it out!

OK.

I am sorry, I do not understand.

So if the problem is Vin pin, can I use external power 5V to LCD and external power USB to NodeMCU?

JoeJoeJoeDoeDoeDoe:
So if the problem is Vin pin, can I use external power 5V to LCD and external power USB to NodeMCU?

I don't know what the problem is.
At this point I was merely pointing out that I don't think it is a s/w issue since I have run a NodeMCU with i2c backpack using the same version of IDE s/w and hd44780 library.

The way you have said you have hooked things up is running a single 5v i2c bus.
5v is too high of a voltage for the NodeMCU pins.
Using 5v signals with a 3v processor can cause issues or even damage the 3v processor.
I use voltage converters when using a 3v master and 5v slaves.
There are ways to wire things up without using a voltage converter as Paul suggested you could use 3v clamping diodes instead of the voltage converter shown in the photo.
Alternatively, you could also run the i2c bus with 3v pullups.
Either of these is running the i2c signals at 3v which is out of spec for the PCF8574 at 5v but usually works.
To run 3v pullups you have ensure that no 5v slave has pullups to 5v and add external pullups to 3v.
With the style of backpack you showed in your photo it requires modification to the backpack to remove the pullups.

This is why I choose to use level converters. They are inexpensive, easier to wire up and nothing is run out of spec.

All that said, it appears that the i2c bus appears to be "working" at least to some extent since the PCF8574 is responding at address 0x27.
Usually when that happens there is a soldering issue between the backpack and the LCD.

But we still have not seen your actual board & wiring and soldering to see if there are any issues beyond running the i2c bus at a voltage that is too high for the NodeMCU.
If I had to guess, in addition to the 5v issue, I'd guess that there is soldering issue either on the 16 pin header with the LCD or you were unlucky and got a backpack with a PCF8574 that has soldering issues on it.

With your current setup, you could be sitting on the edge of damaging the NodeMCU. i.e. it might "work" now due to the VCC voltage from using USB voltage and the 4.7k resistors on the backpack but it might tip things over and damage the ESP8266 if you start adding other i2c slaves that also have pullups on them.

IMO, I'd still be concerned about using 5v signals with the 3v NodeMCU even it appears to "work" or so far not caused damage, since the ESP8266 is a 3v part and is not spec'd to be 5v tolerant.


ARG!!!! I just smoked my NodeMCU.
Smoke, literally smoke came out of one of the components and now my office really stinks. It was my fault; some loose wires slipped and shorted together while I was trying to get some exact voltage readings to see how much current you are pulling on the 3v esp8266 pins by using 5v pullups with 4.7k resistors.

A great example of what can happen when messing about with this kind of stuff.

--- bill

Too bad!

Here is wiring:

Can you show an actual photo of what you are using?
So we can look at the actual backpack soldering of the PCF8574 chip to the PCB and the soldering of the 16 pin header to the LCD.
--- bill



The soldering if the PCF8574 chip and the 16 header pins looks good.

The i2c backpack has pullups to vcc which is wired to Vin (5v) on the NodeMCU.
The way it is wired up will put more than 3v on the ESP8266 D1 and D2 (i2c) pins.

Do you have a 5v Arduino (like an UNO) that you could use for testing?
It would allow testing the LCD and backpack with a 5v device to help isolate the issue.

--- bill

I tried to use resistor between D1, D2 & SCL, SDA.

JoeJoeJoeDoeDoeDoe:
I tried to use resistor between D1, D2 & SCL, SDA.

What does that mean?

If 5V is too much for D1 and D2 pin I tried to regulate it with resistor.

Is it possible that pin on NodeMCU does not response, because voltage is too high?

Is it possible that pin on NodeMCU does not response, because voltage is too high?

It is possible that the I2C pins are dead damaged from previous application of 5V. I suggest that you disconnect the LCD and test those pins for proper function as digital input and output.