Using Nextion displays with Arduino

Has anyone got any information on the nextion Xfloat object and how to read/write to it.
Thanks.

x0.val=4567

Will write to it, so some something like:

  Serial1.print(F("x0.txt=\""));
  Serial1.print(4567);
  Serial1.print(F("\""));
  Serial1.write(0xff);
  Serial1.write(0xff);
  Serial1.write(0xff);

Will send the value 4567 to it. Note that the Xfloats take ints and split them with a decimal point. For example, if you want to display 456.7 you set ws0 (point right) to 3 and ws1 (point left) to 1 and send 4567 as in the example.

Ahh thanks.
:slight_smile:

Thanks for this thread :wink:

I was wondering how to declare that XFloat component.

The numeric component work like:
//Declare a number object [page id:0,component id:3, component name: "n0"]
NexNumber n0 = NexNumber(0, 3, "n0");

How does that work for the XFloat component?

Thanks for answering, I look forward using that component very much!

Hello Tsjompie,
Is your question aimed at me? If so, sorry, I can't help as I think you are talking about the Nextion libraries, which I don't use, sorry. Maybe someone else will see your question, there are a few people on here who do know about the libraries.

PerryBebbington:
Hello Tsjompie,
Is your question aimed at me? If so, sorry, I can’t help as I think you are talking about the Nextion libraries, which I don’t use, sorry. Maybe someone else will see your question, there are a few people on here who do know about the libraries.

Thanks Perry, I was aware of this :wink:

You seemed to have more background too, that was the reason for asking.

I’ll do some more searching on this.

For anyone interested....

This might help: https://nextion.tech/forums/topic/xfloat-declaration/