16*2 LCD Display with NodeMCU ESP32-S (

Hello everyone, I am facing problems integrating my 16*2 LCD display with ESP32-S module.

When I upload the following code, backlight of my LCD display glows but nothing is displayed on it.
Sometimes some garbage values are visible but they also disappear after few seconds.

I have connected 10K-ohms potentiometer at VO pin and tried adjusting it to different values but it didn’t work. I have provided 3.3V to the supply of LCD display and R/W pin is connected to GND. I aslo tried using a different LCD display but same thing happened, what should I do?

Here Is my code:

#include <LiquidCrystal.h>
const int rs = 7, en = 23, d4 = 5, d5 = 18, d6 = 19, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void printMessage(){
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("----Welcome!----");
  lcd.setCursor(0, 1);
  lcd.print("Hello World!!");
}
void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  lcd.print("Power ON");
}

void loop() {
  // put your main code here, to run repeatedly:
  printMessage();
  delay(1000);
}

I have provided 3.3V to the supply of LCD display

do you have a 3.3V display? link the product you have bought and post a picture of the backside of your display

and an additional picture where we can see each and any wiring.

Hii, Thank you for your quick reply,

This is the Display I am using:

You are right, it is a 5V display. I tried supplying it 5V at the input but still nothing is printed.

I have attached the picture of backside of the display and connection diagram below.

Is there any way of using the 5V display with ESP32-S?

Also, if I am using a wrong display,
Do I have to use a 3.3V LCD display Like this one? : https://www.amazon.in/Basic-16X2-Character-LCD-Black/dp/B06ZZHVTJL

In general, the HD44780 displays should work perfectly well on 3.3 V (as long as you do not attempt to read back from the display).

A little hint here - do not connect the contrast potentiometer to 5 V, only to ground. (In fact, it works even better since a 10k pot is the wrong value but if that is what you are using, if you connect both ends to ground. :astonished: ) This is a really stupid mistake made back in the "early days" and slavishly copied from one amateur designer (and indeed, some purportedly "professional" ones) to another. :roll_eyes:

Now, you describe seeing "nothing" displayed. You should at least be able to see a row of "blocks" on the upper row. This is the default for a display which is not initialised by software. If you connect only pins 1 to 3, 15 and 16, that is to power and the contrast potentiometer, you should be able to adjust the potentiometer for this display of "blocks".

That is the first pre-requisite for using the LCD.

Hii Paul__B, Thank you for your suggestions.

Paul__B:
In general, the HD44780 displays should work perfectly well on 3.3 V (as long as you do not attempt to read back from the display).

Yes I am not reading anything back from the display.

Paul__B:
A little hint here - do not connect the contrast potentiometer to 5 V, only to ground. (In fact, it works even better since a 10k pot is the wrong value but if that is what you are using, if you connect both ends to ground. :astonished: ) This is a really stupid mistake made back in the "early days" and slavishly copied from one amateur designer (and indeed, some purportedly "professional" ones) to another. :roll_eyes:

I did this change in my circuit. I removed 5V and only GND is connected to the potentiometer and it is working fine.

Paul__B:
Now, you describe seeing "nothing" displayed. You should at least be able to see a row of "blocks" on the upper row. This is the default for a display which is not initialised by software. If you connect only pins 1 to 3, 15 and 16, that is to power and the contrast potentiometer, you should be able to adjust the potentiometer for this display of "blocks".

That is the first pre-requisite for using the LCD.

You are right, I can see the black blocks on LCD display in both the rows now but still nothing is printed on it.
I tried uploading the normal "Hello World!" code given in examples of Arduino IDE ( changing the pins accoriding to my connections) but I still see the black blocks instead of "Hello World!" printed on it.

Here's a thing, I tried changing my connections as follows:
RS - 22
R/W - GND
EN - 21
D4 - 5
D5 - 18
D6 - 23
D7 - 19
and now the code works!! But why? can you explain what was wrong with previous connections?
I want to use the previous connections because I am using some of these pins for another purpose and I cant change them.