Start a new topic

How to use continuously send data on different pages

Hi Experts!

How to use continuously send data on different pages


At the moment I’m having a problem with my nextion coding, and until now I wasn’t able to find an answer here in the forum.

My Arduino is sending a numeric value in 10Hz to the nextion display. This value is stored in a global defined variable (engine_speed). I could show this value on the page (for example page1) where I have defined this variable.


Now I would like to switch to page 2 and use the same transmitted value also there. But the value seems not to be updated.

What I have tried:

On page 2 I have started a timer with 10Hz, which does this: n1.val=page1.engine_speed.val

(n1 is the number field where I would like to show the continuously updated value)


Now I have seen, that the value seems not to be updated. Only the latest value from my global variable (engine_speed) when I left page1 to page2 will be shown on page 2


Could it be, that if a page is not active where a variable is defined, that the display will not receive a transmitted value from SPI bus?


I really would like to send only ONCE the data via SPI to my nextion, and use this value on several pages – but how?





Sorry forgot the HMI file.

Where you could see my problem is on page2 the value for field x1

value update is in timer value_update


(11.6 MB)

where did you buy a Nextion with SPI interface?  :-)

Haha - You are right - different Project...
Serial of course..
Thanks for the tips...



Ok, I just tried that it seem to work just fine.

On page0 I have a variable called master defined as global.

On page1 I have a t0 defined and a timer define.

In the timer function I have:



I send page page1

then I send: page0.master.txt="Frank"

I see that value change to Frank when the timer kicks.

I also see my n0 increment as I watch it.

t0 is defined as local so when I switch pages and back I see the default value until the timer kicks.


Hi Mike!
THX for your answer and your tryout!
I'm using the arduino lib. So how could  I send something like page0.xxxx from Arduino?
The only way I know is :



And there I could not attach a "page0" for instance...

Thank you very much for your help!



That is why the values aren't changing for you.  When your not on that page the page data has to be added or it will not update the global variable.

I will look into the Arduino library and see what you might do instead.


I think to fix your issue using the Arduino library is to define your variables with the page prefix.  Once the variable is define as global it needs to have the page information prefixed.

NexNumber master = new NexNumber(5, 6, "page0.master");


Michael you are my hero!! Thank''s a lot for your help and the time you have spend! So to sumerize: If someone would like to use the same values on different pages, without checking on which page you are currently in, could this: In Nextion sw: On page 0 (for instance) I have defined several variables like engine speed, vehicle speed, torque,... All these should be global Now on every other page I have defined a timer, which copy the variables to the objects I would like to use to show that value.( could be a bar graph, number field,...) In my example now I could make different display designs for the same informations. In Arduino: What Mike already mentioned: If the variable in Nextion on page0 is called "rpm_act" you should define it in Arduino like: NexVariable rpm_act = NexVariable(0, Id, "page0.rpm_act"); Please take note, that I have seen, that this is only working with variables. If you would like to do the same with a Number field for instance, the value will be shown, but with some delay! Ciao Patrick
Login or Signup to post a comment