Esp32 with nextion on Serial2

Hi all.
I try to connec t nextion lcd 2.4 with esp32-wroom-32u. It must had a Serial2 on pin 16 and 17.
If i use library nextion.h witch hardwareSerial , nextion not communicate with esp32. If i use the same pins 16 and 17 with a declaration of Softwareserial it works.
Other thing what it is strange , if i make a bypas between Serial and Serial2 i can upload nextion hmi files in my nextion, so, the nextion works and Serial2 works too.
Any advices please.
Thanks in advance

Help us help you.

i resolved , the command witch i sent was bad must added some characters after txt and txt values , like this:
Serial2.print(F("g0.txt=""));
Serial2.print(F("Nextion "));
Serial2.print(F("""));
Serial2.write(0xff);
Serial2.write(0xff);
Serial2.write(0xff);

That does not compile, and please use code tags when showing code. We do not see the same code as you have in your sketch.
If you want double quotes, then use \"
For example:

Serial.println( "He said: \"Hello\" when entering the room.");

I think your six lines will be this:

Serial2.print("g0.txt=\"Nextion\"\xFF\xFF\xFF");

Pin 16 is RX2 and pin 17 is TX2. Connect RX2 to the TX of the Nextion and TX2 to the RX of the Nextion.

In the sketch, nothing special is needed, you can use Serial2 in the same way as Serial.

void setup()
{
  Serial2.begin(9600);
  Serial2.println("Hello");
}

If i use like upstairs nothing happen on nextion, but not work like this directly must be declare where write Hello, witch text box.
must be something like i wrote in upstairs post
Strange.

Curious what you think the above line of code does? It's not what you probably think...

Try "above" instead of "upstairs" :wink:

My example was to show how to use the Serial2. The code Serial2.println("Hello"); is not for the Nextion display, but I did put your six lines of code into a single line: Serial2.print("g0.txt=\"Nextion\"\xFF\xFF\xFF");.

With this syntax works. Serial2.print("g0.txt=\"Nextion\"\xFF\xFF\xFF");. or with my 6 lines works too.
Other issue i put to change page in setup() , but after upload sketch not change the page , evenif i push the reset button. If i put the same command to change page in loop it works.
Any ideea please.

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