Start a new topic

How Can I get value of a system variable to Arduino?

Hi, 

I would like to get value of "sys0", "sys1", or new system variable "dp" to Arduino. How can I do this? Please help...


Gerry replied:


The Nextion is accepts much of its commands via text over serial
These commands can be found in the Nextion Instruction Set located here
http://wiki.iteadstudio.com/Nextion_Instruction_Set

As well as the list of Nextion commands, the Nextion Instruction Set also has
A list of the valid Nextion Return Codes and the format of the expected data being returned.

Other samples and Tutorials can be located in the Itead Blog located here
https://www.itead.cc/blog/

Further Information can be found in the posts in the Announcement section of the Forum
Nexion FAQs
http://support.iteadstudio.com/support/discussions/topics/11000002523
Nextion Users manual
http://support.iteadstudio.com/support/discussions/topics/1000065323

Questions related to programming and code can be directed to our Free Chat Section
http://support.iteadstudio.com/support/discussions/forums/1000228333


I have reviewed almost all of the pages you said.
However, I have not been able to find out how to read the system variables via the serial port using your arduino library.
 
I am sending the command with the following code.
 
//--------------------------------
SendCommand ("get dp");
//--------------------------------
 
But how do I read the return value?
 
If I want to get the data on a certain page, there is no problem with it. I define the variable as follows and read the return value.
 
//--------------------------------
NexVariable dpk1_Gun = NexVariable(7, 4, "Gun");
dpk1_Gun.getValue(&DersGunu);
//--------------------------------
 
 
So, if I wanted to define the system variable, how would I describe it in arduino, or how would I read the return value of a command like "SendCommand ("get dp");".
 
 

System variables are not really defined for the Library


One workaround for a system variable would be to

- use a variable mydp inside your HMI design

- in Arduino sendCommand("mydp.val=dp");

Then use in Arduino the variable component to getvalue from mydp



I found the way. I described a function and call it like this.



uint16_t Nextion_getBrightness()

{

  sendCommand("get dim");

  uint32_t val;

  if (recvRetNumber(&val))

    return val;

  else

    return 0;

}

 

uint16_t Nextion_PageID()

{

  sendCommand("get dp");

  uint32_t val;

  if (recvRetNumber(&val))

    return val;

  else

    return 0;

}


void loop() {

  // put your main code here, to run repeatedly:

  brightness = Nextion_getBrightness();

  dbSerial.print("getBrightness: ");

  dbSerial.println(brightness);

 

  PageID = Nextion_PageID();

  dbSerial.print("Nextion_PageID: ");

  dbSerial.println(PageID);

}

Login or Signup to post a comment