Hi!
I'm trying to make my NX4024T032 work with Mega 2560.
Connected the screen to a 5V/1A external power supply.
Nextion connected to Serial2 right now, but also tried 1 and 3.
(Mega TX2 -> Nex RX
Nex TX -> Mega RX2)
Problem:
- Nex sends data to Mega (RX2) correctly
- but if I send data from Mega (TX2) it arrives back to Mega (RX2), like it would be shorted on Nex side
I've tried Nex examples, but even nexInit() returns error (which means command was not confirmed by Nex)
So I made a simple code trying to test com:
void setup(void)
{
Serial2.begin(9600);
Serial.begin(9600);
}
bool datasent=false;
void loop(){
if(!datasent)
{
delay(3000);
setT0Text("Incoming");
datasent=true;
}
}
void serialEvent2()
{
while(Serial2.available())
{
char inChar = (char)Serial2.read();
if((byte)inChar == 0xFF)
{
Serial.println("");
Serial.println("---0xFF---");
}
else
{
Serial.print(inChar);
}
}
}
void setT0Text(String message)
{
while(Serial2.available())
{
Serial2.read();
}
Serial2.print("t0.txt=");
Serial2.print("\"");
Serial2.print(message);
Serial2.print("\"");
Serial2.write(0xFF);
Serial2.write(0xFF);
Serial2.write(0xFF);
}
My nextion sends a postinitialize message, that arrives to Mega fine.
But my setT0Text function is also returned by the SerialEvent2 and Nex does nothing meanwhile.
I would appreciate any suggestion.
Thanks,
Chris