In my Arduino sketch I use a RTC DS3231 clock which is printing the time and date on my Nextion screen. I want this clock to be adjustable. That seems to work although I have a problem which I can't solve sofar. The buttons react very slowly and needs to be pressed several times before decreasing or increasing with one. There is of course the possibility from having to much traffic on my Serial port or can there be another reason for this problem?
Thanks in advance for your reactions
There is also possibilities
- any delay type statements in code
- lower baudrate
- T series basic models not as fast as K series Enhanced
- task assigned to Nextion over serial needs to be accounted for
- timers Nextion side are interpretive
meaning trigger, code execution time + timer counter
- count down to next trigger
- Sequential processing
all assigned tasks must complete until the next one starts again.
Task related to text/numbers - size of font is measured in pixels
more pixel in size takes longer to redraw, background then font data
cropping takes longer than solid colors as pixels need to be compared
But Nextion can handle 115200 baud, and very successfully.
A button press/release when using Send Component ID is
going to send a 0x65 Return Data
this will be read from a hardware port and placed in the buffer
But depending on your code and your MCU you are using
(such as the Iteadlib and an Arduino MCU, assuming)
most commands are sequential in each line of your code,
not multitasking and multithreaded.
The Arduino loop() is meant to iterate 100,000s of times per second
- I can toss a counter in and unless an event calls a jump to a function
and get near 193,000 to 215,000 loop iterations per second.
serial2event() which reads from a serial register into the buffer is called
at the end of the loop() after the last line, whether implied or explicitly called.
So within the loop() there is usually one call to nexLoop() which also empties
the registers into the buffer and nexLoop() is where any action on a press
or released event is going to occur, when matched by Iterate to call the
function that was associated in attachPush or attachPressed.
If this loop() is then filled with other code, especially unbridled unconditional code,
the loop() can become sluggish with less responsiveness to the buffer. If overloaded,
then indeed commands can be lost.
In any use of a command such as delay() is used, code execution is halted on that
code line and will remain on that code line for the duration of the delay. This too
can affect serial and retrieving from the port data.
Without more code details, the answer is mostly common pitfalls.
Thanks for your reply!
I own a seven inch enhanced screen. In my sketch there are no delays. The baudrate is the default; 9600.
The first thing I would like to try is to change that to baudrate 115200 but I don't know how it is done. There must be a simple way? In my Arduino sketch I use "Serial.begin(115200);" I doubt if that works. (nexSerial.begin is not accepted in my sketch?) In de Debug window from my editor I found a possibility under user MCU input. If I change 9600, which is as I mention before the defaultsetting, to 112500 but it will not be held. So, I need your help here...
I'm sorry, I forgot to mention that I have read the System Variables list. It tells me this:
when you set bauds=115200 to Nextion, it means you have set the baud as 115200, and saved it as default. Next time you power the Nextion, the value of baud will be 115200 by default.
But where do I put those instructions? In my arduino sketch it does not accept: set bauds=115200.
Thanks for your time!
If Iteadlib as library,
NexHardware,cpp :: nexInit() function
make change to line so that
from Arduino sendCommand("bauds=115200"); or
in first page Preinitialize Event in HMI
When a baudrate changes, it will for a moment not be in sync.
one probably uses one serial to send the command, but once change
a reset with the new baudrate is required.
1. Go to > Page 0 Nextion Editor- click page
2. User Input Panel (Tab) Send Command).
3. type in- bauds-115200
4. download to Nextion Device
Its in the instruction set
Thanks for your reactions!
It will take some time for me to find an answer for this problem. Changing the baudspeed doesn't solve it. So I need to find an other solution....
Thanks anyway sofar!
If your Serial Monitor is indeed through a USB connection
pump up the baudrate to 250000 for dbSerial, or higher if your MCU will accept
you want debug info to clear as quickly as possible - in case it is the cause
(once project is complete debug is usually disabled)
So put your baud rate back to 9600 for Nextion
- until you find your answer, a slower Nextion baud may help locate when the behaviour begins.
put a loop() counter in your loop() function
- how many loop iterations per second?