How to trigger a page from arduino to nextion ?

Hello friends,

I want to get an input signal from arduino to nextion, and it will trigger any page;

In arduino code i have created an input

#define BUTTON 2

and set it as an input

pinMode(BUTTON, INPUT);

and after setup i am using a code like this;

if(digitalRead(BUTTON)==HIGH){

Serial.print("t1.txt=");

Serial.write(0x22);

Serial.print("READY");

Serial.write(0x22);

Serial.write(0xff);

Serial.write(0xff);

Serial.write(0xff);

}

I have a temp. sensor ds18b20 and i am using this code to get value to nextion;

float temperature = getTemp();

Serial.print("t0.txt=");

Serial.write(0x22);

Serial.print(temperature);

Serial.write(0x22);

Serial.write(0xff);

Serial.write(0xff);

Serial.write(0xff);

I can see temp sensor (t0) and button input (t1) texts on nextion screen. I want to trigger a page when t1 text is "READY"

I have tried on my page 0's preinitialize and post initialize tab

if(t1.txt=="READY")

{

page 1

}

and

if(t1.txt!="")

{

page 1

}

i can see the text on the screen (t1) but it doesnt changes the page to page 1.

any suggestions to solve my problem ?

Regards

In arduino code i have created an input

#define BUTTON 2

and set it as an input

pinMode(BUTTON, INPUT);

And, then, you sewed a button onto the Arduino?

You need to use a switch, not a button. You need to wire the switch properly, with pullup or pulldown resistor, since you are not using the internal pullup resistor.

if(digitalRead(BUTTON)==HIGH){

Serial.print("t1.txt=");

Serial.write(0x22);

Serial.print("READY");

Serial.write(0x22);

Serial.write(0xff);

Serial.write(0xff);

Serial.write(0xff);

}

Where is the serial data going?

I have tried on my page 0's preinitialize and post initialize tab

When you post ALL of your real code, and explain how the button is sewn onto the Arduino, you might get some help. Until then, all you are going to get is answers like this.

in stead of

if(t1.txt=="READY") 

{ 

  page 1 

}

You could use:

if(t1.txt=="READY") 

{ 

  sendCommand("page 3");

}

But you have to use the nextion library. If you download that it also has multiple examples you can take a look at.

Hope it helps.

Regards,
Jeroen

I responded too quickly... I see now you are doing the logic locally in the Nextion. It is possible (probably just a matter of syntax)

But why not do it from within the Arduino, saves you the trouble of coding in 2 places...

so

if(digitalRead(BUTTON)==HIGH){ 

sendCommand("page 1");

}

Can you advise me on doing the exact reverse

Trigger Nextion "start" button to start the arduino

Trigger Nextion "start" button to start the arduino

Normally, one starts the Arduino by applying power to it. I'd having a hard time visualizing how the Arduino can be causing the Nextion to display a page with a strat button, when the Arduino is not started.

Perhaps you have some other definition of "start" in mind.

The Nextion displays are capable to function (display / buttons / pages / ...) without a serial connection.

They are intelligent subsystems.