Nextion getValue without using libraries

Is there a way to get a number from a nextion number box and send it to the arduino using it as an int within the code without the use of the nextion library? im at a stand still with my project because of this. any help would be greatly appreciated.

Is there a way to get a number from a Nextion number box and send it to the Arduino using it as an int within the code without the use of the Nextion library?

Obviously there must be, as the Nextion library is just some code that someone has written!

There's more than one answer to this:

  1. If you are using the methods I set out in 'Using Nextion displays with Arduino', then don't use the number boxes at all. Keep all variables on the Arduino and send them as text to a text box for display, if you do that you don't need number boxes at all. I recommend this as it means all variables are always accessible to your program on the Arduino when the program needs them, without having to ask the Nextion to send them, then wait for the reply.

  2. If you look at the Nextion instruction set you can use, for example

get n0.val

And the Nextion will return the value of n0, however, the methods I use are deliberately not compatible with the Nextion standard for sending data because I wanted to use my own standard and not have it clash with stuff the Nextion sent that I didn't need. I use fixed length variables with a 3 byte start of 0xa5 0xa5 0xa5, which then doesn't get confused with the variable length terminated in 0xff 0xff 0ff that the Nextion generates. If you wan to use 'get' then you will have to write code to receive it.

  1. If you look in my tutorial part 4 I have included 'Arduino Nextion scroll demonstration', (note to anyone reading this in the future, this will almost certainly change as I add new ideas to the demonstration) this also includes a method of the Arduino triggering the Nextion to send something to the Arduino. The example does not exactly do what you want, but you should be able to adapt it.

I am working on a more comprehensive set of examples, but they are not ready yet.

I will try to use txt boxes instead of number boxes and code for such. But i still would like to know why there library doesnt work with my code for it

void b14PushCallback(void *ptr) // Press event for ride height setting 1
{
  uint32_t PreSet_FL = 0;
  
  n40.getValue(&PreSet_FL);
  
  Serial.print(PreSet_FL);
}

Its compiles without errors but returns a 0

1. If you are using the methods I set out in 'Using Nextion displays with Arduino', then don't use the number boxes at all. Keep all variables on the Arduino and send them as text to a text box for display, if you do that you don't need number boxes at all. I recommend this as it means all variables are always accessible to your program on the Arduino when the program needs them, without having to ask the Nextion to send them, then wait for the reply.

My problem with this is that i want the number to be entered into the screen as a setting then used in the code. So maybe txt box wont work??

My problem with this is that i want the number to be entered into the screen as a setting then used in the code. So maybe txt box won't work??

Each press of a button on the screen sends the identity of the button that was pressed to the Arduino. The Arduino does whatever with the button press; adds to a variable, increments a variable, decrements at variable, whatever you need it to do. Then the Arduino sends back to a text box the updated value of the variable.

If you look at the demonstration code in my tutorial that's exactly what the 6 buttons for setting the clock do, there are 3 buttons to increment the hour, minute and second, and 3 buttons to decrement them. That means that the 3 variables that hold the time can be changed on the Arduino every second as time passes, and changed by button presses on the Arduino. In both cases the result is sent to the Nextion to be displayed as the time.

There's also a scroll bar on there that does pretty much the same thing; move the scroll bar and the new value is sent to the Arduino, the variables updated and the result printed on the Nextion as text.

PerryBebbington: Each press of a button on the screen sends the identity of the button that was pressed to the Arduino. The Arduino does whatever with the button press; adds to a variable, increments a variable, decrements at variable, whatever you need it to do. Then the Arduino sends back to a text box the updated value of the variable.

If you look at the demonstration code in my tutorial that's exactly what the 6 buttons for setting the clock do, there are 3 buttons to increment the hour, minute and second, and 3 buttons to decrement them. That means that the 3 variables that hold the time can be changed on the Arduino every second as time passes, and changed by button presses on the Arduino. In both cases the result is sent to the Nextion to be displayed as the time.

There's also a scroll bar on there that does pretty much the same thing; move the scroll bar and the new value is sent to the Arduino, the variables updated and the result printed on the Nextion as text.

Ok ill give it a whirl. Btw im working with the basic model not the higher model.

Btw im working with the basic model not the higher model.

Not a problem, my methods work with any model.