Problem with LiquidCrystal and latest esp32 core

Hello, the 'LiquidCrystal' currently provided in the arduino (1.8.15 but the same happens with previous releases) library folder is not compatible with the latest esp32 core (v4.4-dev-2313-gc69f0ec32).

Calling 'begin(16,1)' at the end of the constructor leads to an endless delay because -it seems that- the 'delayMicroseconds()' function does not work yet at that point of the initialization.

The program gets halted even before being able to output anything on the Serial.

Commenting out the 'begin(16,1)' call from the 'LiquidCrystal::init' function in 'LiquidCrystal.cpp' and placing it in the sketch (where it should be already, with proper display size) solves the issue, because the 'delayMicroseconds()' function will work.

Alessandro, Italy

You are right, begin should not be called in the constructor, I have no idea why it's there. You should report this issue on github, it seems related to this issue LiquidCrystal causing ESP32-S2-Wrover-I to crash. · Issue #41 · arduino-libraries/LiquidCrystal · GitHub

One possible way to solve this problem without modifying the library or waiting an update, is to use a global pointer and create the LiquidCrystal object inside setup()

So instead of LiquidCrystal lcd( ... ); you do LiquidCrystal * lcd; and in setup

lcd = new LiquidCrystal( ... );
lcd->begin( ... );
2 Likes

Yes, thanks!

You could switch to the hd44780 library and use the hd44780_pinIO i/o class.
It shouldn't have this issue and the hd44780 library is faster and has additional capabilities.
The only changes to your sketch to use it over LiquidCrystal is a change to the included header files and the class name on the constructor.
It is available in the library manager.
It includes many examples and documentation can be found in the "Documentation" sketch.

--- bill

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.