Start a new topic

How can I to send a variable to arduino ???


How can I send a variable from my nextion display to the arduino.

I have a variable that can be set in the nextion display and I want this variable to be sent to the arduino. How can this be accomplished ?

You can pass the value of a variable to a timer, no and then obtain the timer values.

I don't understand, I want to send a txt.value or a number value to the arduino, how can this be done ?

Can you post an example ?

send this command from Arduino to Nextion :

get txt.value

Nextion will respond with text value (more information are available in nextion instructions set :

So the trick is to request the value using the arduino and then wait for a response from the nextion.


I created a button with a release event in the nextion editor:
a.val=a.val+1         <<<<< defined as numeric variable
get a.val                 <<<<< this sends the numeric value
tmp.txt       <<<<< defined as string variable
get tmp.txt              <<<<< this sends the string


 The arduino code:


#include <Nextion.h>

NexButton b3 = NexButton(0, 6, "b3");
NexTouch *nex_listen_list[] = { &b3, NULL };

void b3PopCallback(void *ptr)
	uint32_t n;
	char txt[100];

	recvRetNumber(&n);					// get numeric variable a
	txt[recvRetString(txt, 100)] = 0;	// get string vtxt and set termination character

void setup(void)
	b3.attachPop(b3PopCallback, &b3);

void loop() {




2 people like this
Alex, Love your simple example on writing values fron Nextion to Arduino, do you have one going from Adruino to Nextio, for floats, and text values
Login or Signup to post a comment