Unable to communicate to LCD

I am trying to send integer data to a DWIN LCD.

I am using the LCD with ESP32 developmental board.

I am unable to communicate with the LCD and send data to it. I don't know where I am going wrong.

Here is the link to the docs. Not being computers engineer, I am very bad at reading these things. Can someone please help find the correct doc and find in it the reason my below code is not transmitting data to the LCD?

#include <SoftwareSerial.h>
const byte rxPin = 16;
const byte txPin = 17;
SoftwareSerial dwinSerial(rxPin, txPin);

unsigned char Buffer[9];
#define some_value_add 0x50
unsigned char HMI_some_value[8] = {0x5A, 0xA5, 0x05, 0x82, some_value_add, 0x00, 0x31, 0x32};

void setup()
{
  Serial.begin(115200);
  dwinSerial.begin(115200);
}

void loop()
{
  Data_Display();
  delay(1000);
}

void Data_Display()
{
  delay(100);
  int t = 20;
  HMI_some_value[6] = highByte(t);
  HMI_some_value[7] = lowByte(t);
  dwinSerial.write(HMI_some_value, 8);
  delay(2000);
}



Below are the setting I have for the LCD UI

Why did you decided that?

Please show your connection diagram.

The LCD is just reading 00.

The connections are simple.
Rx pin of the LCD is soldered to Tx pin of ESP32 board.
The Tx pin of the LCD is soldered to the Rx pin of the ESP32 board.
The LCD is powered externally via a 5V adaptor.
LCD and ESP32 have common ground.

Your serial setup is no sense. You are using software serial on board that has multiple hardware serials on pins that default to Serial2

I didn't get that.

What do I need to do differently?

This is the board I am using.


and this is the board settings.

delete first 4 lines of your code

substitute dwinSerial.begin(115200);
with
Serial2.begin(115200, SERIAL_8N1, 16, 17);

and in Data_Display code substitute dwinSerial.write with Serial2.write

1 Like

You might have errors in your display code, but I don't know that display..

Why you selected board wroom-da module? Just select "esp32 dev module"

Also, what is this unsigned char Buffer[9]; doing?
Also, there is a lot of delay in your loop and Data_Display...

1 Like

changed my code, still nothing.

const byte rxPin = 16;
const byte txPin = 17;


#define some_value_add 0x50
unsigned char HMI_some_value[8] = {0x5A, 0xA5, 0x05, 0x82, some_value_add, 0x00, 0x00, 0x00};

void setup() {
  Serial.begin(115200); // Debugging on Serial
  Serial2.begin(115200, SERIAL_8N1, rxPin, txPin); // Initialize Serial2 on pins 16 and 17
}

void loop() {
  Data_Display();
  delay(1000);
}

void Data_Display() {
  delay(100);
  int t = 20;
  HMI_some_value[6] = highByte(t);
  HMI_some_value[7] = lowByte(t);
  Serial2.write(HMI_some_value, 8); // Use Serial2 instead of SoftwareSerial
  delay(2000);
}

Do you have a manual that described the format of display messages?

Serial looks ok now.
Don't you have some demo-code offered from vendor?

No demo code or manual given by the vendor. The documents detailing the communication protocol (In the link shared in my original post) are too technical for me.
I found the code I first used here, but its for the resistive LCD version. It works fine in the video, but on my capacitive LCD no response.

I don't found anything about the protocol in document in the link. It contains a module datasheet only.
Please let me know in which file and what page range you saw the protocol description?

Quite complex device.. :open_mouth:
For sure you didn't find this in arduino starter kit.

check this document, chapter 4.

All the documents are found here.

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