I have an esp32 and Nextion 7" connected. Connection is OK. (I can run HMI editor and it send commands to Nextion 7")
I send simple commands to Nextion from esp32 and get no respond.
need HELP a simple code on arduing to send a Nextion command to print "Hello word" and draw line.
And second command to get back receive from Nextion the confirmation text "Commands correct" or "command error".
my code.
#include "Nextion.h"
#include "EEPROM.h"
// #include "HardwareSerial.h"
String endChar;
void setup() {
Serial.begin(115200);
Serial2.begin(9600,SERIAL_8N1,02,04);
Serial.println("Loopback program started");
endChar= "\xFF\xFF\xFF";
Serial2.print("sys0="+String(0));
Serial2.write(0xff);
Serial2.write(0xff);
Serial2.write(0xff);
delay(2000);
}
void loop()
{
int i, b;
Serial2.print("page 0");
Serial2.write(0xff);
Serial2.write(0xff);
Serial2.write(0xff);
delay(5);
String sendThis = ""; //Declare and initialise the string we will send
sendThis = "t1.txt=\"Test\""; //Build the part of the string that we know
Serial2.print(sendThis); // gives you an error due to a datatype mismatch*/
Serial2.print("Test");
Serial2.write(0xff); Serial2.write(0xff); Serial2.write(0xff);
delay(5);
Serial2.print("Test");
Serial2.write(0xff); Serial2.write(0xff); Serial2.write(0xff);
delay(5);
for ( i=0; i<100; i++) {
b=i*10;
Serial2.print("line 20,37,270,300,BLUE");
Serial2.write(0xff); Serial2.write(0xff); Serial2.write(0xff);
delay(5);
Serial2.print("t1.txt="Test"");
Serial2.write(0xff); Serial2.write(0xff); Serial2.write(0xff);
Serial.print("Serial-Done="+String(i)+"\r\n"); // this to monitor what is send
delay (1000);
}