LiquidCrystal on ESP32-S3

I've issues to run LiquidCrystal on BPI-Leaf-S3.
I read this and this issues. Still I cannot understand how to fix the problem.

Sample code:

// main.cpp
#include <LiquidCrystal.h>
#include "foo.h"

Foo foo;

void setup() 
{
  Serial.setDebugOutput(true);
  Serial.begin(115200);
  
  foo.Begin();
}

void loop()
{
}

// foo.h
class Foo
{
public:
    Foo();
    void Begin();

private:
    LiquidCrystal *_lcd;
}

// foo.cpp
#define PIN_LCD_RS  3
#define PIN_LCD_EN  13
#define PIN_LCD_D4  4
#define PIN_LCD_D5  30
#define PIN_LCD_D6  12
#define PIN_LCD_D7  6

void Foo::Begin()
{
    Serial.println("before");
    _lcd = new LiquidCrystal(PIN_LCD_RS, PIN_LCD_EN, PIN_LCD_D4, PIN_LCD_D5, PIN_LCD_D6, PIN_LCD_D7);
    Serial.println("after");
}

Since I init the LCD class in Begin function and NOT in the constructor it should not hang the ESP as stated in the issues above. Still my output is:

Reconnecting to /dev/ttyACM0 . Connected!
before
Disconnected (device reports readiness to read but returned no data (device disconnected or multiple access on port?))
Reconnecting to /dev/ttyACM0 . Connected!
before
Disconnected (device reports readiness to read but returned no data (device disconnected or multiple access on port?))
Reconnecting to /dev/ttyACM0 . Connected!
before
Disconnected (device reports readiness to read but returned no data (device disconnected or multiple access on port?))
Reconnecting to /dev/ttyACM0 . Connected!
before

I also added build_flags = -DCORE_DEBUG_LEVEL=5 in platfomio.ini but I don't see any crash log in the serial output.

What is the right way to use this library for ESP32-S3?

You don't use Arduinos way to setup the hardware. That is just calling for trouble.

Sorry, what is the "Arduinos way to setup the hardware"?

Oops, forget what I wrote: I just saw that you use GPIO6, which is used by SPI Flash - which will most likely the cause of your problem

1 Like

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