I would like to change the baudrate from the default 9600 to 115200 on my 7 inch enhanced screen. So I wrote on the preinitialization field: bauds = 115200. Now the following problem occurs. After this change, my screen stops responding to my sketch. If I put everything back to 9600 then everything will work again. Should I have done something more? If so, what? I did not find anything in the ITEAD instruction set.
thanks in advance
Users are responsible to read
Thanks you for your response, Patrick!
My English is obviously very bad or my explanation is less. Each time you point to the rule you underlined.
When you read my question again, you'll see that I know the default baud rate is 9600. I want and have changed this with the command, Bauds = 115200 on the right place. Wich is, btw, nowhere mentioned. So far so good.
But probably something more has to happen to get this effective. And that was the question; What?
I agree that readers should read the instructions, but maybe there is the problem; the instruction is not complete?
Thanks in advance,
Again, the right place is "when you need it", not before, not too late.
More reading on TTL Serial
But also the other side not just Nextion needs to be at the same timing.
A serial device (hardware) will normally recognize start of byte when the
voltage drops from high to low on the falling edge and start the process.
Software serial not as good will have to replicate what hardware does.
If both device are not the same baudrate they will not understand each other
115200 baud is 12x faster than 9600, as such,
a byte at 115200 is already over before the 9600 start bit is ready to read.
There are books worth of information available for Serial communications
- not just the theory of toggling a wire electrically high or low for 1/baud second per bit
- but also on all the behaviours, troubles and solutions.
TTL Serial is the simplest of the Serial protocols
- the least learning required, the easiest to get a rudimentary working prototype.
But again too many other resources exist to replicate them here on Itead's resources
With an understanding of Serial (because you spend some time to read about)
You will understand they need to be in synchronization.
A bauds=115200 in Nextion HMI also has to be in a SerialX.begin(115200);
If you are using the Iteadlib Arduino Nextion Library
- you will have read through all the code of the library.
- you will have noticed that in examples (because you played with them)
that the setup() function includes nexInit(), and you will know (because you
read the library code) that nexInit() was in files NexHardware.cpp and NexHardware.h
- you will have noticed the nexSerial and dbSerial defines in NexConfig.h
So you will know where to change serial to use port RX2/TX2 (or other)
and where to set its baudrate sketch side.
Well, this makes some things clear, at least for me ...Thanks!
You will have also read your MCU datasheet and seen that there is some
error rates that are inherent with higher baud rates
You will have read about timing issues as MCU clock is not divisible
evenly with 115200 - and such there is an error rate
You will have also examined your wires used
you will have read about Electro Magnetic Interference
you will have read about how to protect and isolate from EMI
You will have read about how your MCU reacts to serial timing
how it processes, where the registers are for configurations
and where the registers are for incoming/outgoing byte
You will have read about the hardware limited buffers
You will have read about software buffers (good place to put incoming)
You will have read about underflow/overflow
You will have formulated a strategy to prevent
You will have spent the time to ponder ALL of the moving parts of your code
so that your project works in unison of all of these moving parts.
But as you might understand, MCU side is not covered by Nextion Instruction
I posted both baud and bauds for a reason.
sending baud=115200ÿÿÿ over serial can be done from MCU side
As stated in the Nextion Instruction Set
bauds changes the default power on baud rate, not baud.
Therefore, the "when to change" can be done at the same time
(command to change has to be in the speed that Nextion is at)
There are many ways to use tools and materials.
Thank you, Patrick for your clear explanation.
To clarify the purpose of all my questions; I built an Aquarium controller with various setup options.
To use these setting possibilities I use buttons. Although it works I have to press these buttons very often for a response. I thought to fix this, among other things, with an increase of baud rate from 9600 to 115200.
I'm using, btw., an Arduino Mega and a 7 inch Nextion Enchanted. As a clock, I use an RTC 3231 so not the Nextion clock.
Sorry, but a button press on Nextion sends to the MCU
only 8 bytes of 0x65 Nextion Return Data
at 9600 baud and 10 bits per byte (1 start, 8 data, 1 stop)
your line is capable of 960 bytes per second
This means that the eight bytes of button press
at 9600 is done in 8.333ms
at 115200 is done in 0.694ms
Your code is responsible for your delays
the additional 7.639ms of the baud change will not fix this
indev2 went over loop counters
- and on a Mega with button press I can still count 101288
- this means that most of the time Mega has nothing to do.
indev2 and I also went over debugging messages via Serial monitor
and we went over timing your functions will millis() or micros()
and triggering code in conditional timed intervals.
Without more exacting controls in your code,
7.639ms wont be as much help as you think
In my code, I use exclusive delays according to the Arduino blinck without delay principle, so millis.
With another delay form I would get into trouble with my clock. Furthermore, as far as my knowledge is concerned, I have looked at the possibilities and minimized these possibilities. I did that, as said, with timers. But it has indeed become a rather big sketch that I would like to show, if it may. Of course with HMI file. The whole covers five pages. Anyway, I would like to thank you for your help. It has to be difficult to provide assistance without having all the data.
Thank you for the effort!
yes, upload HMI, ino and libraries used (rtc, etc) in a ZIP file and I'll take a peek for you
Thank you in advance, Patrick!