I'm working on a Nextion (NX8048P050-011) and Arduino Mega project. I'm receiving data from a Honda ECU via RX and TX at a baud rate of 38,400 and sending it to my Arduino Mega. Each value coming from the ECU is stored in a variable, which is then sent to the Nextion display at a baud rate of 9,600.
Everything works perfectly, but unfortunately, the refresh speed is too slow. To improve it, I tried changing the baud rate in my Arduino code from 9,600 to 38,400. I also added baud=38400 in the Preinitialize Event of the Nextion. However, the screen no longer receives any data.
I'm not going to have access to my PC for a couple of weeks so I can't run any code or check your HMI file.
Have you tried putting the baud rate change in the post initialisation event? It's a long time since I've configured a Nextion and I can't remember exactly where it goes.
Have you tried other baud rates?
Have you tried the examples in my tutorial? Use one of those and try changing the baud rate, get that working then use what you learn on your code.
My advice is to write something simple that sends simple data to your Nextion at the baud rate you want.
I'm reluctant to ask for your complete code because I imagine it's complex making finding the problem difficult. Even if I could run it I can't simulate the ECU data.
Looking at the schematic you forgot to post it appears you have two serial ports in use. Looking at the non posted code you confused the consol with the target. If I am wrong post the needed information.
Hello, thank you for your responses. Below is the Arduino code used. For confidentiality reasons, I will only show you part of the code: #include "EasyNextionLibrary.h"
When I display only one variable on the Nextion with 9600 baudrate, the refresh rate of the variable is very good. Could it be due to the baud rate speed or the capacity of my Arduino?
Yes, I tried doing the different tests from this tutorial. In the Nextion Editor, under the 'Program' tab, I set the baud rate to the desired frequency. I tested at 115200 and 38400.
I also added a rule that changes the values only if the previous one is different. It improves things a bit, but it doesn't completely solve the problem.
I think you are writing to the Nextion every pass through loop. I think you need to slow this down even with the faster baud rate. What happens if you send data to the Nextion every 100 ms?
Yes, that's right. My mistake might have been setting 50 ms for all the variables. Knowing that for some variables like ECT or IAT, I can easily set 200 ms.