hello i write a program for esp32 and i need to control it with nextion HMI. baud rate must be 115200 for esp32 and nextion hmi i downloaded nextion library, but there is a communication error. i cant send text from esp32 to nextion hmi.. here is my code:
#include "Nextion.h"
#define RXD2 16
#define TXD2 17
NexText t0 = NexText(0, 2, "t0");
NexButton b0 = NexButton(0, 3, "b0");
NexPage p0 = NexPage(0, 0, "p0");
NexTouch *nexListenList[] =
{
&t0,
&b0,
&p0,
NULL
};
int montajButon = 25;
String msj = "merhaba";
void setup() {
Serial.begin(115200);
nexSerial.begin(115200);
pinMode(montajButon, INPUT); // set the button pin mode
digitalWrite(montajButon, LOW);
}
void loop() {
if (nexSerial.available()) {
Serial.print("Haberlesme OK");
delay(2000);
if (digitalRead(montajButon == true)){
Serial.print("buton geliyor");
nexSerial.print("t0.txt=");
nexSerial.write(0x22);
nexSerial.print(msj);
nexSerial.write(0x22);
nexSerial.write(0xff);
nexSerial.write(0xff);
nexSerial.write(0xff);
delay(2000);
}
}
}