How can i write ONE byte on the MCU serial?

I tried with print (depreciated);
Prints ,1,
printh
get.
Best results obtained with prints <> <>.

The mcu serial on wich i’m testing, is arduino mega serial port 1.

On the simulation of nextion ide, when i send 64 (hex 40)
i obtain a sort of bytes that seem errors code return, but most probably a “completion” in 4 bytes of the byte i “trasmit”.

On the other side, i actually receive in arduino serial port, yes, the byte i’ve sent from nextion, but sometimes (not ever) other unexpected bytes, that seem to close a nextion command (FF FF FF).

I think that must be something written by nextion itself to complete some kind of command.

After 3 or 4 of all that, Nextion transmit correctly one byte at a time.

I think i firstly must write somenting like a nextion command, and after the single bytes.

To be clear, the transmitted byte from nextion to arduino must be the index of an array
contained in arduino code, so, what i need is one byte, at an interval of a timer in nextion.

The byte value change non sequentially at each timeout, it’s a stream triggered by the timer.

If you do it right, prints will send single bytes correctly. If you consider
int myval=0xA1B2C3D4
prints myval,1
Then the Nextion will only send 0xD4, because it handles the 32bit int in little Endian and will thus send the LSB first.
If you still see additional bytes, make sure that „Send component ID“ is not enabled.

1 Like

I send (prints) the content (.val) of a “number” visual component (n0.val).
The value is always something WELL fitting in ONE byte(0 to 127) .
The parameter of prints is alwas 1 (prints n0.val,1).
The value is indicated, of course, in decimal.

I wonder if the error is due to the fact that “number” component" is always “natively” a 4 bytes value.

I wonder if , when i send 64(hex 40), the value “returned” is in reality 40 00 00 00 (flag positive).
But in this case the return value should be always 40 00 00 00, but it’s not.

Sendig 10 times the same value (64, 0x40) , the debug simulator, in nexiont ide, returns
40
40 1A FF FF FF
40 1A FF FF FF
40 1A FF FF FF
40
40
40
40
40
40.
Something happens the 2nd, 3th, 4th tome that i sent, where Nextion seems to “join” to 40
other 4 bytes.

1A FF FF FF is an error message. This can be caused by other elements of your HMI, for example some timer code running in the background, and is rather not related to your prints command. But without seeing your complete HMI file, nobody can help with debugging but you.

Now, to avoid to copy and paste all code, that is in different event handlers windows code
(that could be confusing), i don’t use timer at all.
So, in press event of n0 component, i simply write “prints n0.val,1”.
I “press” n0 component 10 times.
The simulator returns this:
40 1A FF FF FF
40 1A FF FF FF
40 1A FF FF FF
40
40
40
40
40
40
40

As I said, 99,99% that this does not come from the prints code. Why not attach the hmi file so that someone can load it into the editor and will perhaps better see from where it comes?

OK.
It’s 5.10 MB.
I try to send to you.

By the way, i tried with a new empty project, i used only one number component, and now the return is correct.
Wait, i’m searchin for the attach to msg button :hot_face:

No, is not authorized directly attach someting that’not a graphic file.
I try something to bypass this.

The test with the empty project confirms already that the problem is elsewhere. :grinning:

If you can’t attach it here, you might send it by email to fjodorgondor(at)yandex(dot)ru

I’ll look then into it tonight.

Good found. Now it works correctly.
Some graphical command interferenced.

Good you found it.

About your further proposal: That’s something which probably should not be discussed in open forums, but using PM.

ops, sorry, ok…

What is the solution?, I have the same problem and it is not clear to me

Every case could be different. Best is to attach a code snippet which allows others to reproduce your problem. That’s much more efficient than guessing around.