Hey all, I’m new to Nextion so I’m hoping this is simply user error.
I have an NX4024T032 interfaced with an Elegoo Uno. I can change on-screen elements using print statements from my Uno, but ‘get’ commands return nothing at all.
I cannot connect to the MCU in debug mode of the Nextion Editor, so debugging is a bit more difficult.
From what I can, tell this is due to limitations put in place by my IT admin since I am using my work PC as it is the only Windows machine I have access to. (Feel free to make suggestions on this matter if you have any). The debugger shows the expected command on the return side.
It’s worth mentioning that, as soon as I press a button on the display that executes its own print statement, I then see the response to my original ‘get’ request and the button’s print statement.
Anyways, this is what I have. Executed directly in the loop function
if (Serial2.available() > 0) {
String input = "";
delay(30);
while (Serial2.available()) {
input += char(Serial2.read());
}
Serial.println("Serial2 input: " + input);
if (input.substring(0,9) == "Whatismy ") {
String requestRx = input.substring(9);
Serial.println(requestRx);
String requestTx = "";
if (requestRx == "mode") {
Serial.println("mode");
requestTx = "get Globals2.motorStatus.txt";
} else if (requestRx == "position") {
requestTx = "get Globals2.motorPosTxt.txt";
Serial.println("position");
} else if (requestRx == "speed") {
requestTx = "get Settings.motorSpeedRead.txt";
Serial.println("speed");
}
String stage = "Get Request";
if (stage == "Get Request") {
Serial.print(requestTx);
Serial.print(0xff);
Serial.print(0xff);
Serial.print(0xff);
stage = "Get Response";
}
if (stage == "Get Response") {
if (Serial.available() > 0) {
String response = "";
delay(30);
while (Serial.available()) {
Serial.print(response);
response += char(Serial.read());
}
Serial.println(response);
Serial2.println(response);
}
stage = "Get Request";
}
}
}
I know none of these should have worked, but I tried including these anyways:
- Serial.print(“code_c”);
- Serial.print(“sleep=0ÿÿÿ”);
- Serial.print(“com_star”);
What am I missing? Any other ideas? TIA!
UPDATE: SoftwareSerial cannot send and recieve at the same time, so I moved the print statements to after “if (Serial2.available())” and I now get a response from the Nextion, but it looks to just be a space or carriage return maybe?