Unofficial Nextion/TJC User Forum

Serial Communication

Good Morning:

I am new to Nextion and Arduino. Just received my board.
I have been able to write a serial command that changes the value of an “n0” on page 0.
n0.val=5

When I create another page, p1, how do I send data to that “n0” element via arduino serial command?

Thanks for your time.
Leon…

Hi Leon,

I’ll take piece from the explanation found here:

Nextion Page and Object IDs

Objects are referenced by page number (not page name) and object ID (not object name) as shown in the Nextion editor. The Nextion notation for each object is of the form p[1].b[2] meaning page number 1, object ID 2. Confusingly, button object names will start at b0 but it might be object ID 2, or 7, etc. Other objects will be named similarly with different letters. For example, the first text field on the page will be automatically named t0. Ignore these names. They have nothing to do with the object ID, and all objects regardless of type are still referenced as p[<page number>].b[<object id>]

An object will have multiple attributes, some of which can be changed. For example, a button named p[1].b[2] may have a “txt” attribute which we’d refer to as p[1].b[2].txt. Not all attributes can be changed at runtime, the ones which can are shown in a green font in the Nextion editor (see the right pane of the image above.)

In your case, assuming the page number 0 and object ID 1, you would write:

 p[0].b[1].val=5

For this to work while your are on a different page, set the vscope of the object to global instead of local.

Thank you so much!!!

This works perfectly.

I really appreciate your help.

Leon…


This forum is in no way affiliated with NEXTION®, ITEAD STUDIO®, TJC®, or anyone else really. All product names, logos, and brands are property of their respective owners. All company, product, and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement from the respective rights holder(s).