Good day for you guys. I need help! Today i'm trying to fix a 'problem' who is ocurring in my project. I'm using a ESP32 connected to a LCD 16x2 (with a module I2C). But, instead of the text is appearing the most terrible thing i've seen in my whole life, the white squares. I checked the cables, the connection, the potentiometer, if the ESP32 has some problem, if the I2C is recognized (and it is), but nothing really resolves, cause all of this is right! I think the problem is in the program, but I really don't know cause' I have tested some many programs, and nothing resolve, or in the I2C cause' in the present moment, I don't weld. Can you help me, please?
Nope, can't help at all. Need schematic and code. To further improve your chances of getting any help, stop a moment and read this(hint: click on the link):
#include <LiquidCrystal_I2C.h>
// set the LCD number of columns and rows
int lcdColumns = 16;
int lcdRows = 2;
// set LCD address, number of columns and rows
// if you don't know your display address, run an I2C scanner sketch
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup(){
// initialize LCD
lcd.init();
// turn on LCD backlight
lcd.backlight();
}
void loop(){
// set cursor to first column, first row
lcd.setCursor(0, 0);
// print message
lcd.print("Hello, World!");
delay(1000);
// clears the display to print new message
lcd.clear();
// set cursor to first column, second row
lcd.setCursor(0,1);
lcd.print("Hello, World!");
delay(1000);
lcd.clear();
}
Here is the program
Shouldn't matter. If I read your posting correctly, you've never had success with this arrangement, but you're absolutely convinced your hookup is correct?
Then a schematic, and probably a clear photo of the wiring/layout with no overlapping, is needed.
C
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.
To 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 menus, 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.
On the ESP32 use the default I2C pins, SDA = pin 21, SCL = pin 22.
I bet the intensity of light is too high
Like @groundFungus said, I put the SDA to pin 21 and the SDL to pin 22.
Find the "contrast" potentiometer on the LCD screen and rotate it first to the end in one direction and after to another
Is the I2C backpack soldered to the LCD? It will not work if it is not soldered. There is no sense going any further till the backpack is soldered.
I just wired a 16x2 LCD to my ESP32 dev module and loaded the following code using the hd44780 library. The LCD displays the correct millis count and works fine.
Wired:
LCD Vcc to ESP Vin
LCD ground to ESP ground
LCD SDA to ESP pin 21
LCD SCL to ESP pin 22
// hd44780 library see https://github.com/duinoWitchery/hd44780
// thehd44780 library is available through the IDE library manager
#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
// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;
void setup()
{
lcd.begin(LCD_COLS, LCD_ROWS);
lcd.clear();
lcd.print("Hello World");
lcd.setCursor(0, 1);
lcd.print("Millis ");
}
void loop()
{
updateLCD();
}
void updateLCD()
{
static unsigned long lcdTimer = 0;
unsigned long lcdInterval = 500; // update 2 times per second
if (millis() - lcdTimer >= lcdInterval)
{
lcdTimer = millis();
lcd.setCursor(8, 1);
lcd.print(" "); // overwrite old data
lcd.setCursor(8, 1); // reset the cursor
lcd.print(millis());
}
}
Thank you, @groundFungus and everyone!!!
You are welcome.
Please mark the thread as solved so that other members do not waste their time opening the thread wanting to help only to find that the problem has been solved.
So what was the problem?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
