Nextion Commands and Functions

We have compiled the details, assignments and functions of nextion commands that you need to know when using Nextion HMI under this heading. These are the sets of commands that Nextion can use.
You can switch directly to any location in the Table of Contents.

1. General Rules and Practices

  1. All commands over the series: terminated with three bytes 0xFF 0xFF 0xFF.
  2. All commands and parameters must be ASCII.
  3. All commands must be written in lowercase letters.
  4. Code blocks enclosed in { } parenties cannot be sent over a serial connection, which means that if, for, and while commands are unavailable when commands are not available over the series.
  5. A space character, i.e. 0x20, is used to separate the command from the parameters.
  6. There are no spaces in the parameters unless specifically specified.
  7. Nextion uses integer math and does not support real or float.
  8. Assignments are assessments that are not exactly complex when the value is reached after the operator.
  9. The comparison assessment is not complex, but it can be combined (see &&& and ||).
  10. Instructions over the series are processed when termination is received (see 1.1).
  11. Character output is performed using two text characters: r creates 2 bytes 0x0D 0x0A, " 0x22, and for 0x5C
  12. Nextion does not support transactional order. sys0=3+(8*4) is invalid
  13. 16-bit 565 Colors are desed from 0 to 65535.
  14. Text values should be enclosed in double quotes: that is, "circuit"
  15. Elements specific to Enhanced Models are specified as follows: K
  16. Transparent Data Mode (used by addt and wept commands.)
  17. Only component properties in green and non-read-only system variables can be assigned new values at run time. All others except .objname are read-only at run time
  18. Numeric values can now be entered with byte-aligned hex. i.e. n0.val=0x01FF
  19. Address mode is an advanced technique that prevents serial instruction with two bytes for the address. The two-byte address will be sent in small endian order, that is: 2556 0xFC 0x09. By default, the Nextion address is 0 and does not require two bytes of pre-attachments. When two-byte addressing is used, Nextion will only respond to the command if the address matches the two-byte prefix, or if the forwarded address is broadcast 65535. See the addr system variable.
  20. Protocol Re parsing mode is an advanced technique that allows users to define their own incoming protocols and incoming serial data processing. When the Active Protocol is in Re parsing mode, incoming serial data is not processed locally by the Nextion hardware, but waits in the serial buffer for processing. To exit Active Protocol Reparse mode, the recmod must be set passively again (that is: as recmod=0 in nextion logic), which cannot be performed with this series. To exit active mode over the series, send DRAKJHSUYDGBNCJHGJKSHBDNùù in series. Most HMI applications do not require Protocol Re parsing mode and should be skipped if they are not fully understood.
  21. Interpreting user code in Events uses the double slash (two slashes / ) technique. See 2.30 for correct use.

2. Assignment Expressions

NumberData typeOperatorDescription
1Text=Assignment. The right side will be evaluated by the result placed on the left side. The .txt-maxl component must be large enough to hold the result.
t0.txt="circuit"
2Text+=Insert Text. The result combines the left side with the right side so that it is placed on the left side. that is, t0.txt+="Hello" is equivalent to t0.txt=t0.txt+"Hello".
t0.txt="-"+t0.txt, t0.txt=t0.txt+"-""
Use the temp variable to add to the top. add "World" to va0.txt=t0.txt t0.txt="-"+va0.txt
t0.txt+=" World" // t0.txt
//t0.txt contains "Hello World"
3Text-=Extract Text. It will remove the right side (a certain amount of numeric characters to remove) from the end of the left side and place the result on the left side.
Remove last 4 characters from t0.txt-=4 or t0.txt=t0.txt-4 // t0.txt
4TextEscape Character. (see 1.11)
Supported r hex 0x0D 0x0A, " hex 0x22, hex 0x5C,
t0.txt="r"
5Text==Boolean Equality. It is evaluated from left to right.
If both left and right sides are the same, it creates an accurate condition
if(t0.txt==va0.txt)
6Text!=Boolean Inequality. Evaluate from left to right.
If both left and right sides are different, it creates a real condition
if(t0.txt!=va0.txt)
7Numeric=Assignment. The right side of the equation will be evaluated and the result will be placed on the left side. If there are multiple operators on the right side, a full evaluation and assignment takes place on each operator.
Places the value n0.val=bauds // baud in component n0.val
8Numeric+=Numeric Append. Adds the left side and right side value with the result placed on the left side. n0.val+=4 equals n0.val=n0.val+4
n0.val+=va0.val
9Numeric-=Numeric Subtraction. The result is placed on the left side, which removes the right side from the left side. n0.val-=4 equals n0.val=n0.val-4
n0.val-=60 // n0.val reduces value by 60
10Numeric*=Numeric Multiplication. The left side and the right side are multiplied by the product result placed on the left side. n0.val =2 is equivalentto n0.val=n0.val2
n0.val*=2
11Numeric/=Numeric Section. Synchronizes the division of the share (left side) and the division (right side) and places the integer section on the left side. 60000/20001=2
n0.val/=60
12Numeric%=Digital Module. Equalizes the division of the share (left side) and the division (right side), and places the integer on the left side. It must be a dividing constant. 60000/20001=19998
n0,val%=60
13Numeric<<Arithmetic Bit Left Scroll. Moves all bits of the specified number to the left.
Using the following 16-bit example, all bits that are shifted above 15 (32 bits use similar rules)
are lost, and undefined bits become
0 n0.val=n0.val <4
0 0 0 0. 0 0 1.1 1 1 0 0.0 0 0 0 1
0 0 1 1.1 1 0 0.0 0 0 1.
0 0 1 1.1 1 0 0.0 0 1. 0 0 0 0 0
14Numeric>>Arithmetic Bit Right Shift. Moves all bits of the specified number to the right.
Using the following 16-bit example, all bits that are scrolled below 0 (32 bits use similar rules)
are lost, and undefined bits become marked bits.
When the signed bit is 1 (the value is negative), then filled with 1s.
When the marked bit is 0 (value positive), it is left full of
0s n0.val=n0.val>>4
0 0 0.0 0 1 1.1 1 0 0. 0 0 0 1
0 0 0 0.0 0 1 1.1 1 0 0 0
0 0. 0 0 0 0.0 0 1 1.1 1 0 0
16Numeric&Logical Bitic VE. Compares all lice on the left side with all bits on the right side (mask)
Using the following 16-bit example, (32 bits use similar rules)
The result is a bit 1, in which both left and right bits are 1.
n0.val=n0.val&35381
0 1 0 1. 1 0 1 1.0 0 1 0.0 1 0 1 n0.val value 23333
1 0 0 0.1 0 1 0.0 0 1 1.0 0 1 mask 35381
0 0 0 0.1 0 1 1 0.0 0 1 0.0 0 0 1 1 1 2597
16Numeric|Logical Bitsel OR. Compares all bits on the left side with all bits on the right Using the
following 16-bit example, (32 bits use similar rules)
The result is 1 bit, where the left or right bits are 1.
n0.val=n0.val|35381
0 1 0 1.1 0 1 1.0 0 1 0.0 1 1 0 1 n0.val value 23333
1 0 0 0.1 0 1 0.0 0 1 1.0 0 1 fixed 35381
1 1 0 1.1 0 1 1.0 0 1 1.0 0 1 result 56117
17Numeric^Logical Bitic XOR. Applies bit inverse to all bits in the bit mask Using the
following 16-bit example, (32 bits use similar rules)
The result is a little inverse where the mascot is 1, unchanged where the mascot is 0
n0.val=n0.val^35381
0 1 0 1.1 0 1.0 0 1 0.0 1 0 1 0.val of 23333
1 0 0 0.1 0 1 0.0 0 1 1.0 1 0 1 35381 bit mask 1 1 0 0 0 0
1.0 0 0 1.0 0 0 0 result 53520
18Numeric==Boolean Equality. It is evaluated from left to right.
If both left and right sides are the same, it creates an accurate condition
if(n0.val==va0.val)
19Numeric!=Boolean Inequality. It is evaluated from left to right.
If both left and right sides are different, it creates a real condition
if(n0.val!=va0.val)
20Numeric<BooleAn less. It is evaluated from left to right.
Creates the correct condition if the left side is smaller than the right side
while(n0.val<va0.val)
21Numeric<=Boolean Is Small or Equal. It is evaluated from left to right.
If the left side is less than or equal to the right, it creates an accurate condition
while(n0.val<=va0.val)
22Numeric>Boolean bigger. It is evaluated from left to right.
If the left side is larger than the right side, it creates a real condition
while(n0.val>va0.val)
23Numeric=>Boolean Is Greater Than or Equal to. It is evaluated from left to right.
If the left side is greater than or equal to the right, it creates an accurate condition
while(n0.val>=va0.val)
24Code{ }Code Block starts with open parentheses { on its own, the
Code Block ends with the closing parenthesis starting a new line } see if
(see 3.25) while (see 3.26) and for (see 3.27)
25Code&&Conditional AND
Conditions can be combined without leaving a space between conditions, see if evaluated from left to right
(see 3.25) while (see 3.26) and for (see 3.27)
26Code||If conditions or
conditions can be combined without leaving spaces between conditions, see if they are evaluated from left to right
(see 3.25) while (see 3.26) and for (see 3.27)
27Code( )The conditions attachment begins with open parent brackets
(and ends with parentthesis closing at the end of the line).
Parentaries are not allowed to create complex expressions.
see if (see 3.25) while (see 3.26) and for (see 3.27)
28Code.Period Separator. Separates Page, Component, and Attributes
It is also used in contingent with the page index and component array. (see 2.29)
page1.va0.val or p0.pic
29Code[ ]Array[index]. There are 3 sequences. The keyboard source shows 2
arrays. . . B[.id] component array that takes the id component as an
index p[index] page array that takes the page index as an index
These (p[].b[]) must be used carefully. A reference to a component without a specified Attribute can create long and potentially frustrating debugging sessions. The third array is the Serial Buffer Data u[index] array. This is true when the active Protocol is in Re parsing mode. Protocol Re parsing is an advanced technique that must be bypassed if it is not fully understood.
p[pageindex].b[bileşen.id].attribute // global scope
b[component.id].attribute // local scope on the current page
30Comment//Double-SlashEd Commenting to add user comments to code.
Everything to his right, including a double slash, is a comment that will not be executed by the Nextion interpreter. Comments: 1) with a double slash at the beginning of the line (without a space at the beginning), 2) a line with no space allocation code and double slash immediately after the code. Interpretation of code blocks: 1) must be after the code block 3) in the opening and closing brackets before the condition/iteration. Notes: It is important to note that comments cannot cut blocks of code without causing the error "Error: Index was out of bounds of the directory". Comments are counted to the general strict limit of "code + attributes" of 65534.
Correct usage: // these are valid
comments reset sys0=0// sys0

Misuse: // valid comment before condition/iteration
for(sys0=0;sys0 <=sys1;sys0++)
// invalid comment between condition/recurrence and block
{
doevents//valid comment after code in the same line
// valid comment in block
}
// valid comment outside the block

3. Operational Commands

NumbernameNumber of ParametersDescription
1Page1Change the page to the specified page. Removes the old page to load the specified page.
Nextion installs page 0 by default at startup.
usage: page <pid>
pid: page index number or page name is
page 0 // Change page to indexed page 0
main // Change page to main</pid>
2Ref1Refreshes the component (auto-refresh when the attribute changes since v0.38)
– if the component is blocked (stacking), the ref puts the component at the top.
Usage: ref <cid>
cid: Is the .id or .objname attribute of the component to refresh – refreshes everything on the current page when it is
0 (the page component).
ref t0 // Refreshes component t0 with .objname
ref 3 // Refreshes component with .id
3 ref 0 // Refreshes all components on the current page (same as ref 255)</cid>
3Click2Trigger specified components Touch Press/Release Event
Because the event code is always local, the object cannot be prefixi on the page
usage: click <cid> <event>
cid: the .id or .objname attribute of the component to refresh the component is
event:1 to trigger the Press Event, 0 to trigger Broadcast Events.
click b0,1 // Trigger Touch Press Event .objname b0
to click component 4.0 // .id 4 to trigger component's Touch Drop Event</event> </cid>
4ref_stop0The default waveform stops refreshing (it is not refreshed when the data point is added)
– waveform refresh will continue with ref_star (see 3.5)
Usage: ref_stop
5ref_start0Continue refresh default waveform (refresh in adding data point)
– used to resume waveform refresh stopped by ref_stop (see 3.4)
Usage: ref_start
6Get1Send attribute/constant over serial connection (0x70/0x71 Return Data)
usage: get <attribute>
attribute: numeric value, .txt content or constant
get t0.txt // t0.txt's text content in 0x70 Return Data format
get "123" // "123" text constant 0x70 Sends in Return Data format
get n0.val // sends the numeric value of n0.val // n0.val in 0x71 Return Data format
get 123 // Sends numeric constant 123 in 0x71 Return Data format</attribute>
7sendme0Sends the number of pages currently installed in series (0x66 Return Data)
– the number of pages already loaded is stored in the system variable dp – used in the
initialization event of a page, which is automatically sent as the page
loads usage: send
8covx4Convert the variable from numeric type to text or text to numeric type
– the text must be a text ASCII representation of an integer value.
– the source and destination types must not be of the same type
– when the source is numeric, the hexadecimal format and length are not 0 and <4. yani: (len 2) pozitif anlamlı (bayt 0 ila 3), 123 = 0000007B = 007B yani: (len 2) negatif anlamlı (bayt 3 ila 0), -123 = FFFFFF85 = FF85 – değer, izin verilen alandan fazlaysa, bir kesmeye neden olur – covx'ten önce kullanıcı kodunda kaynak uzunluğunun işlenmesinin sağlanması önerilir – v0.53'te, kaynak uzunluktan büyükse veya hedef txt_maxl, istenen uzunluktan daha küçük. (some of which are undefined, exploitable) i.e.: the src numeric value of 123 with a length of 0, the resulting target text "123" – when the length is constant and the value is smaller, the leading zeros will be added: the src numeric value of 123 with a length of 4, the resulting target text "0123" – when the value is greater than the length, the .txt is truncated to the least significant digits: the numeric value of 23425 src with a length of 4 results, using target text "3425": covx ,,,
is a text property (or numeric attribute when it is text) is a
numeric attribute (or text attribute when numeric),
determines whether leading zeros are added to the conversion to text
0: integer, 1: Comma separated 1000s, 2: Convert hex
covx h0.val,t0.txt.0.0 // h0 to t0.txt without zero
covx t0.txt,h0.val,0.0 // t0.txt in h0.val was ignored.
convert covx h0.val,t0.txt,4,0 // h0 to exactly 4 digits t0.txt
covx h0.val,t0.txt,4,1 // h0 comma t0.txt
covx h0.val,Convert t0.txt,4,2 // h0 to t0.txt in 2-byte hexadecimal digit
Invalid: covx h0.val,va0.val,0.0 or covx t0.txt.txt.0// source and target of the same type.
8acov3Converting from numeric type to text or text to numeric type
– text must be a text ASCII representation of an integer value.
– the source and target types should not be of the same type
– when the length is constant and the value is smaller, the initial zeros will be added: the
src numeric value of 123 with a length of 4, the resulting target text "0123"
– the target txt_maxl and length must be large enough to accommodate the conversion.
that is: the src numeric value of 123 with a length of 0, the resulting target text "123"
– when the value is greater than the length, causes an abbreviation .txt – it is recommended that the resource length be treated before
cov in the user code
Note:v0.53 changed behavior from previous v0.53 pre/post-v0.53 behaviors.
cov is considered undefined if the source is larger than the length or if the target is txt_maxl.
smaller than the desired length. Some undefined people can be exploited.
usage: cov ,
is a text property (or numeric attribute when it is
text) is a numeric attribute (or text attribute when numeric),
determines whether leading zeros are added to the conversion to text
cov h0.val,t0.txt,Convert the value of 0 // h0 from zero to t0.txt
cov t0.txt,h0.val,0 // h0.val convert the ignored integer to t0.txt.
Convert the value of cov h0.val,t0.txt.4 // h0 to exactly 4-digit t0.txt
Invalid: cov h0.val,va0.val,0 or cov t0.txt,va0.txt,0 // source and destination of the same type.
9touch_j0Re calibrate the touch sensor of the resistant Nextion device – it provides 4 points on the
screen for the user to touch, record, and then restart.
– the device is generally not required as it is factory calibrated
– the sensor may be affected by changes in conditions in the environment –
Capacitive Nextion devices cannot be calibrated by the user.
Usage:
Triggers the recalibration of the touch_j touch_j // touch sensor
10substr4Use of extracting characters from the contents of a text
attribute: substr <src>, , , , is the text property from which to extract<dest><start><count>
<src>text</src> </count> </start> </dest> </src>
<dest>is the text property in which to place extracted text</dest>
<start>is the starting position for subtraction (0 first characters is 1 second)</start>
<count>, the number of characters to extract
substr va0.txt,t0.txt,0,5 // va0.txt remove the first 5 characters from , put them in t0.txt</count>
11Vis2Hide or show component on current page
– show will refresh and visually remove the hide component that will bring it to the forefront, touch events will be disabled – use

layering for a careful purpose, it can cause tearing and flickering.
– use carefully and carefully, difficult debugging session may cause
usage: vis <comp> <state>
<comp>is the .objname or .id of the component on the current page,
– valid .id 0 – page is 1 to 250 if the component exists and 255 for
<state>all, 0 if hidden, or 1 if shown.
hide vis b0.0 // component with .objname
b0 show vis b0.1 // component with .objname b0, refresh on front layer
vis 1.0 // hide component with .id 1
Show vis 1.1 // component with .id 1, refresh in front layer
vis 255.0 // hides all components on current page</state> </comp></state></comp>
12tsw2Enable or disable touch events for the component on the current page
– by default, All components are enabled unless disabled by tsw
– use carefully and carefully, it can cause a difficult debugging session
usage: tsw <comp> <state>
<comp>is the .objname or .id of the component on the current page, – valid .id 0 – the page is
1 to 250 if the component exists and 255
<state>for all, or 1 to enable.
Disable Touch Press/Release events for component
tsw b0.0 // b0 Enable Touch Press/Release events for component
tsw b0.1 // b0 Component with ID tsw 1.0 // 1 Disable Touch Press/Release events for
tsw 1.1 // Enable Touch Press/Release events for component with ID 1
tsw 255.0 // Disable all Touch Press/Release events on the current page</state> </comp></state></comp>
13com_stop0Stop executing instructions from
Serial – The series will continue to receive and store in the buffer.
– The execution of instructions from Serial will continue with com_star (see 3.14).
– Using com_stop and com_star may cause buffer overruns.
– See device datasheet for buffer size and command queue size
usage: com_stop
com_stop // Stops executing instructions from Serial
14com_star0Continue the execution of instructions from Serial – used to
maintain an execution stop caused by com_stop (see 3.13)
– When com_star is taken, all instructions in the buffer are executed – using com_stop and com_star may cause buffer
overruns.
– See device datasheet for buffer size and command queue size
usage: com_star
com_star // Continue executing instructions from Serial
15randset2Set up Random Generator Range for use with Rand (see 6.14)
the interval will continue until changed or Nextion restarts Before using Rand, set the range to the desired range – the default open range is

-2147483648 to 2147483647, the runtime range can be defined by the user.
usage: randset <min>,<max>
<min> value between -2147483648 and 2147483647
<max>, greater than min and less than 2147483647
Randset 1,100 //set current random constructor range from 1 to 100
randset 0.65535 //set current random constructor range from 0 to 65535</max> </min> </max> </min>
16code_c0Clears commands/data queued in the command buffer without executing
usage: code_c
code_c // Clears the command buffer without running it
17prints2Send raw formatted data to MCU over Series
– prints do not use Nextion Return Data, the user must process the MCU side
– the amount of data can be limited to serial buffer (all data < 1024) – 4 bayt 32 bit küçük endian düzende gönderilen sayısal değer değer = bayt1+bayt2 256+bytes365536+bytes4*16777216 – text content sent, 1 ASCII byte per character is sent without empty bytes Usage: , prints <attr>, prints , <length> </attr>
<attr>is either component property, variable, or Constant</attr>
<length>is 0 (all) or number to limit bytes to be sent.
T0.txt.0 prints // returns 1 byte per t0.txt character without an empty byte break.
Prints t0.txt,4 // returns 1 byte per t0.txt character without an empty byte break.
j0.val prints 0 // j0.val returns 4 bytes in small endian order for
j0.val,1 prints // returns 1 byte j0.val in small endian order
"1 Prints 23",2 // Returns 2 bytes for text "12", 0x31 0x32
prints 123.2 // returns 2 bytes for 0x7B 0x00 value of 123</length>
17aprint1he was depreciated. Send raw formatted data to MCU over Series
– print/printh does not use Nextion Return Data, the user must process the MCU side
– the amount of data can be limited to serial buffers (all data < 1024) – 4 bayt 32 bit küçük endian düzende gönderilen sayısal değer değer = bayt1+bayt2 256+bytes365536+byte4*16777216 – the text content sent is sent, 1 ASCII byte per character without empty bytes usage: print print.<attr>
<attr>returns 1 byte per t0.txt character without either component property, variable, or Constant
t0.txt print // empty byte break.
Return 4 bytes in small endian order for j0.val print // j0.val
Print "123" // Return 3 bytes for text "123" 0x31 0x32 0x33
print 123 // 4 bytes for 123 0x7B 0x00 0x00 0x00</attr>
18printh1 and moreSend raw bytes or multiple raw bytes to mcu over series
– printh is one of the few commands that the parameter uses 0x20 the space character
– when multiple bytes are sent, each byte is separated by a space
– bytes are represented by 2 (ASCII character, hexadecimal value for each part)
– quantity can be limited to serial buffer (all data < 1024)
– print/printh, nextion return data is required to handle the user's MCU
side: printh <hexhex> <space><hexhex][…<space><hexhex] her bir parçanın onaltılık değeridir.</space></space> [</hexhex> 0x34 34 is
0x20 a space character used to separate each pair.
printh 0d // send single bytes: value 13 hex: 0x0d
printh 0d 0a // send two bytes: value 13.10 hex: 0x0d0x0a
19add3Add a single value to the Waveform Channel
– waveform channel data range min 0, max 255
– 1 pixel column per added data value is used
– y placement, value , < s0.h ise s0.y+s0.h-değeri, aksi takdirde s0.y kullanım: add <waveform><channel>, <value> </channel> </waveform>
<waveform>is the .id of the waveform component</waveform>
<channel>is the channel through which data will be added</channel>
<value>is the ASCII text of the data value or numeric value
– current: add va0.val or sys0 or j0.val or 10
1,0,30 // Add 30 values to Waveform's Channel 0 with .id 1 Add 30 values to Channel
0 of Waveform // Add h0.val to Waveform's Channel 1 with .id 2</value>
20addt3Add a single value to the Waveform Channel
– waveform channel data range min 0, max 255
– 1 pixel column per added data value is used
– y placement, value , < s0.h ise s0.y+s0.h-değeri, aksi takdirde s0.y kullanım: <waveform><channel>, <qty> </channel> </waveform>
<waveform>is the .id of the waveform component</waveform>
<channel>is the channel through which to add data</channel>
<qty>is the ASCII text of the data value or numeric value
– current: add va0.val or sys0 or j0.val or 10
1,0,30 // Add 30 values to Waveform's Channel 0 with .id 1 Add 30 values to Channel
0 of Waveform // Add h0.val to Waveform's Channel 1 with .id 2</qty>
21Cle3Waveform clears channel data
usage: cle <waveform>, <channel> </waveform>
<waveform>is the .id of the waveform component</waveform>
<channel>must be a valid channel to
clear: < waveform.ch veya 255
0 if .ch is 1, 1 if .ch 2, 2 if .ch 3, and 3 and 255 (all channels) if .ch=4 (all channels)
cle 1.0 // Clear channel 0 data from the waveform with .id</channel>
22rest0Resets Nextion Device
usage: rest
rest // Instant reset of Nextion – restart.
23doevents0Force instant screen refresh and get serial bytes to buffer
– useful in a custom code block for visual refresh (see 3.26 and 3.27)
usage: doevents
doevents // allow refresh and serialization during the code block
24strlen2Calculates the length of the string in and puts the value in
usage: strlen <txt>, <len> </txt>
<txt>must be a string attribute, that is: t0.txt, va0.txt
<len>, must be numeric, that is: n0.val, sys0, va0.val
strlen t0.txt,n0.val // assigns n0.val with the length of the content of t0.txt</len></txt>
24abtlen2calculates the number of byte strings in and puts a value into
usage: btlen <txt>, must be a string<len>
<txt>attribute, that is: t0.txt, va0.txt , must be
<len>numeric, that is: n0.val, sys0, va0.val
btlen t0.txt,n0.val // assigns n0.val with the number of bytes occuped by t0.txt</len> </txt> </len> </txt>
25ifBlockExecute the code block conditionally if the Boolean condition is
met – if (conditions) are met, execute commands within the { } block.
– () nested conditions are not allowed. invalid: ((h0.val+3)>0)
– block opening bracket { must be online on its own – there || >


<, =="," !=","> <= destekler

is
no space between block closed bracket } and else. Usage: if condition block [else if condition block] [else block]
– (conditions) is a simple noncomplicated boolean comparison that evaluates from left to
right: (j0.val>75) is invalid: (j0.val+1> j0.val <now.val+60)
Example:
if(t0.txt=="123456")
{ page
1 }

if(t0.txt=="123456"|| sys0==14&n0.val==12)
{
page 1
}
if(t0.txt=="123456"&sys0!=14) {
page
1 }

if(n0.val==123)
{
b0.txt="stop"
}else {

b0 .txt="start"
}
if(rtc==1)
{
t0.txt="Jan"
}else if(rtc1==2)
{
t0.txt="Feb"
}else if(rtc1==3)
{
t0.txt="Mar"
}else {

t0.txt="etc"
}</,>
26whileBlockThe Boolean condition executes the block continuously until it is no longer met
– it tests the boolean condition and executes commands in block { } if the conditions are met, and continues to replay the block until the condition is not met.
– () nested conditions are not allowed. invalid: ((h0.val+3)>0)
– block opening bracket { must be online on its own – Text comparison support
==, !=
– Numeric comparison >, <, =="," !=",">=, <= destekler – koşullar && veya || ile birleştirilebilir boşluk kullanılmadan – olaylar kullanılmadığı sürece, yalnızca tamamlanana kadar blok çalışır (bkz. </,> 3.23). Usage: while condition block – (conditions) is a simple noncomplicated boolean comparison that evaluates from left to right: (j0.val>75) invalid: (j0.val+1>75)
Example:
while(n0.val <100)
{
n0.val++
}
27ForBlockRepeat the execution of the code block as long as the Boolean condition is met
– executes init_assignment, then tests and executes the boolean condition
the commands within the { } block are executed step_assignment block execution is completed during replication if the boolean condition
is met. Repeat the
block and step_assignment until the boolean condition is not met.
– () nested conditions are not allowed. invalid: ((h0.val+3)>0)
– block opening bracket { must be online on its own – Text comparison support
==, !=
– Numeric comparison >, <, =="," !=",">=, <= destekler – koşullar && veya || ile birleştirilebilir boşluk kullanılmadan – olaylar kullanılmadığı sürece, yalnızca tamamlanana kadar blok çalışır (bkz. </,> 3.23). Usage: for(init_assignment;condition;step_assignment) block – init_assignment and step_assignment are simple expressions that are not complex: n0.val=4, sys2++, n0.val=sys24+3 is invalid: n0.val=3+(sys24)-1 – (conditions) is a simple intricate boolean comparison that evaluates from left to right: (j0.val>75) invalid: (j0.val+1>75)
Example:
for(n0.val=0;n0.val=0;n0.val) <100;n0.val+=2) { doevents }
28wepo2Save the value/string to EEPROM
– EEPROM current address range is between 0 and 1023 (1K EEPROM)
– numeric value length: 4 bytes, -2147483648 – 2147483647
– long integer with signature numeric data type stored in small endian order.
val[addr+3]16777216+val[addr+2]65536+val[addr+1]*256+val[addr] – string content length: .txt content is .txt-maxl +1 or fixed length +1
usage: wepo <attr>, <addr> </attr>
<attr>is variable or constant</attr>
<addr>is the storage start address in EEPROM
writes wepo t0.txt,10 // t0.txt content to addresses 10 to 10+t0.txt-maxl
wepo "abcd",10 // 10 to 14 type "abcd" constant on addresses between
wepo 11.10 // 10 through 13 fixed 11 summer
wepo n0.val,10 // Type n0.val for addresses 10 through 13</addr>
29Repo2Read value from EEPROM
– EEPROM current address range between 0 and 1023 (1K EEPROM)
– numeric value length: 4 bytes, -2147483648 – 2147483647
– long integer signed with numeric data type stored in small endian layout.
val[addr+3]16777216+val[addr+2]65536+val[addr+1]*256+val[addr] – string content length: .txt content is less than .txt-maxl or empty until the value is reached.
Usage: repo<attr>, <addr></attr>
<attr>is variable or constant</attr>
<addr>is the storage start address in EEPROM
repo t0.txt.10 // reads .txt-maxl characters (or until empty) from 10 to t0.txt
repo n0.val,10 // address reads from 10 to 13 to 4 bytes n0.val</addr>
30wept2Store the specified number of bytes from MCU to EEPROM over Series
– EEPROM uses transparent data mode from 0 to 1023 (1K EEPROM)
– (see 1.16)
– limited quantity with serial buffer (all commands+terminations + data < 1024) kullanım: wept <addr>, <qty> </addr>
<addr>is the storage start address in EEPROM</addr>
<qty>is the number of bytes to store
wept writes 20 bytes from series to EEPROM addresses from 30 to 49
// data bytes, not ascii text of the byte value, but is a raw data byte.</qty>
31rept2Read the number of bytes specified from EEPROM to MCU via Series
– EEPROM current address range is between 0 and 1023 (1K EEPROM)
usage: rept<addr>,<qty></addr>
<addr>is the storage start address in EEPROM</addr>
<qty>is the number of bytes to read
rept sends 20 bytes to the series from EEPROM addresses between 30.20 // 30 and 49
// data byte is the raw data byte of the byte value, not the ASCII text.</qty>
32cfgpio3Nextion GPIO configuration
usage: cfgpio <io>,<mode>, <comp> </mode> </io>
<io>is the number of the extended I/O pin.
– Valid values in PWM output mode: 4 to 7, all other modes 0 to 7.</io>
<mode>,</mode><io>is the operating mode of the pin selected by .
– Current values: 0-pull up input, 1-input binding, 2-push pull output,
3-PWM output, 4-open drain output.
<mod>When there is 1, the <comp>component is .objname or .id (otherwise use 0)
– in binding mode, the cfgpio must be notified after each refresh of the page to reconnect to the Touch event, it is best to put the cfgpio in the page pre-launch event
cfgpio configures 0.0.0 // io0 as a pull-up input.
configures cfgpio 1,2,0 // io1 as push-pull output, writes pio1=1,
cfgpio 2.1 configures b0 // io2 as binding input with existing page b0.
binding triggers b0 Press on the falling edge and b0 For PWM mode, leave it on the rising
edge, set the task cycle before cfgpio: that is: 20% for the task pwm4=20.
Configures cfgpio 4,3,0 // io4 as PWM output. pwmf=933 To change Hz.
changing pwmf changes the frequency of all configured PWM io4 to io7</comp> </mod></io>
33ucopy4Read-only. Applies in Active Protocol Re parsing mode.
Copies data from a serial buffer.
When Nextion is in active Protocol Re parsing mode, ucopy copies data from the serial buffer. Most HMI applications do not require Protocol Re parsing and should be skipped if they are not fully understood.
Usage: ucopy <attr><srcstart>, ,<len>, <deststart> </len> </srcstart> </attr>
<attr>must be a writable attribute, that is: t0.txt, va0.val</attr>
<srcstart>must be a numeric value, that is: 0</srcstart>
<len>must be a numeric value, that is: 4</len>
<deststart>must be a numeric value, that is: 0
ucopy n0.val,0,2,0 // buffer bytes 0.1 copy below 2 bytes of
n0.val ucopy n0.val,0,2,2 // buffer bytes 0.1 n0.val's top 2 bytes copy
ucopy n0.val,0,4,0 // buffer bytes to 0.1,2,4 copy buffer bytes
to 0.txt.val ucopy t0.txt,0,10,0 // .txt 0 to 9</deststart>
34Move7Move a component.
usage: <comp>, , , , , <x1><y1><x2><y2><priority>, <time> </priority> </y2> </x2> </y1> </x1> </comp>
<comp>is the component name or component ID</comp>
<x1>is the starting X coordinate</x1>
<y1>is the starting Y coordinate</y1>
<x2>is the destination X coordinate</x2>
<y2>is the target Y coordinate</y2>
<priority>is a value between 0 and 100, 100 is the highest priority</priority>
<time>is the time in ms.
Move t0 to 100,150 t0,-30,-30,100,150,95,120 // 120ms
move t1 to 200,150 t1,-30,-30,200,15 0,90,180 // Move 180ms
to move t2 to 300,150 t2,-30,-30,300,150,100,150 // Move 150ms
// when sample priorities are given, t2 moves first, then t0 and finally t1</time>
35Play3Plays the audio source on the selected Channel
usage: play <ch>, component name or component ID , Sound Source<resource><loop>
<ch>
<resource>ID</resource> </ch> </loop> </resource> </ch>
<loop>0 Notes so that there is no 1 for
looping: The playback instruction is used to configure and start audio playback. audio0 and audio1 are used to control the channel.</loop> Audio playback is common and playback continues after leaving and replacing pages, if you want the sound to stop when you leave the page you should do this in the page breakout event
1,3,0// Play source 3 on channel 1 without
loop 0,2,1// loop and play source 2 on channel 0
36twfile2Transfers file over Serial
usage: twfile <filepath>, <filesize> </filepath>
<filepath>, destination path, and file name citation is encapsulated text</filepath>
<filesize>is the size of the file in bytes.
twfile "ram/0.jpg",1120// jpg over series to ram/0.jpg size 1120
bytes twfile "sd0/0.jpg",1120// jpg transfers sd0/0.jpg size over series to 1120 bytes</filesize>
37delfile1Deletes the external file.
Usage: delfile <filepath>
<filepath>is the destination path and file name as quoted text
delfile "ram/0.jpg"// remove the transferred file ram/0.jpg
delfile "sd0/0.jpg"// remove the transferred file sd0/0.jpg</filepath>
38refile2Rename the external file.
usage: <oldname> <newname> ,</oldname>
<oldname>, the source path and file name as the quoted encapsulated
<newname>text, the destination path and file name as the quoted text is
"ram/0.jpg","ram/1.jpg"// rename the file ram/0.jpg ram/11.jpg
rename "sd0/0.jpg","sd0/1.jpg"// to sd0/0.jpg.jpg</newname></oldname>
39findfileUse the Find File command if there are named external
files: findfile <pathfile>, <result> </pathfile>
<pathfile>is the source path and file name as quotation encapsulated text</pathfile>
<result>is a numeric property of the result to be stored.
Returns the result 0 if discovery fails and 1 if the discovery succeeds.
findfile "ram/0.jpg",n0.val// check for files, store the result in n0.val
findfile "sd0/0.jpg", check for sys0//file, store the result in sys0</result>
40rdfileRead the contents of the file and serially extract the contents
usage: rdfile <pathfile>, , ,<offset><count>, <crc> </count> </offset> </pathfile>
<pathfile>is the source path and file name as quotation encapsulated text</pathfile>
<offset>is the starting distance of the file</offset>
<count>is the number of bytes to return (see note if 0)</count>
<crc>is an option (0: crc none, 1: Modbus crc16, 10: crc32)
If the number is 0, the file size of 4 bytes is returned in small endian order.
Send the first 10 bytes of the rdfile "ram/0.jpg",0,10,0// file, no CRC, 10 bytes.
Send the first 10 bytes of the rdfile "sd0/0.jpg",0,10,1// file, MODBUS CRC, 12 bytes.
Send the first 10 bytes of the rdfile "sd0/0.jpg",0,10,10// file, CRC32, 14 bytes.</crc>
41setlayer2Set Component Layer
Usage: setlayer <comp1>, <comp2> </comp1>
<comp1>is the component ID or object name of the component that must change the layers</comp1>
<comp2>is the component ID or the object name above which comp1 is placed
Note: Using a comp2 value of 255 places comp1 on the top layer.
place setlayer t0.n0//n0 above layer
place setlayer t0,255//t0 on top layer
place setlayer n0.3//n0 on layer 3</comp2>
42newdir1Create a new index
usage: new <dir>
<dir>
note: the index name must end with a slash /
new is "sd0/data/"//data create index named
"sd0/202003/"//202003</dir>
43drill1Remove an index
usage: drill <dir>
<dir>
note: the directory name must end with a slash /
is delegated "remove index called sd0/data/"//data
"sd0/202003/"//202003</dir>
44redir2Renames an index
usage: redir <srcdir>, <destdir> </srcdir>
<srcdir>is the directory to rename</srcdir>
<destdir>, new name of the renamed array
Note: index names must end with a slash /
"sd0/data/","sd0/data2/"//rename data2
redirection "sd0/202003/","sd0/2004/"//202003 to 2004</destdir>
45finddir2Tests whether the index
is usage: finddir <dir>, <attr> </dir>
<dir>is the directory to test, if any</dir>
<attr>
note: index names end with a slash / Index names end with a slash /
Returns 1 if index is not found, returns 0 if it is not found
finddir "sd0/data/",va0.val//find index data, results in va0.val
finddir "sd0/2003/", sys0/find directory 2004, results in sys0</attr>
46udelete1Removes bytes from Serial Buffer
usage: udelete <qty>
<qty>is the number of bytes to remove from the startup of Serial Buffer
Note: Protocol Re parsing Mode (recmod) must be enabled for use.</qty> Most HMI applications do not require Protocol Re parsing and should be skipped if they are not fully understood.
udelete 24//Delete the first 24 bytes of the buffer
udelete Delete the first 10 bytes of 10/Buffer
47crcrest2Reset and Start CRC
usage: crcrest <crctype>, <initval> </crctype>
<crctype>must be 1 (Modbus CRC16 type)</crctype>
<initval>is the initial value of crc (usually 0xFFFF)
reset and start crcrest 1.0xFFFF// crc</initval>
48crcputs2Collects CRC for variable or constant
usage: crcputs <attr>, <lenght> </attr>
<attr>is attribute or constant</attr>
<lenght>
crcputs accumulate crc (auto-length) crcputs for crcputs va0.val,0//va0.val that is the specified length of 0 (default) or specified length
crcputs accumulate crc for the first 3 bytes of va1.txt,3//va1.txt</lenght>
49crcputh1CRC spool usage for hex
string: crcputh <hex>
<hex>is hex string
Note: each byte in the hexadecimal string has 2 hexadecimal digits, separated by a space.
Crcputh accumulate crc for 0A//byte 0x0A crc accumulate
crcputh 0A 0D//bytes crc 0x0A 0x0D</hex></hex>
50crcputu2CRC accumulates usage on Serial
Buffer: crcputu <start>, <qty> </start>
<start>is the serial buffer start byte to be spooled</start>
<qty>is the number of bytes to collect, including the starting byte
Note: Protocol Re parsing Mode (recmod) must be enabled for use.</qty> Most HMI applications do not require Protocol Re parsing and should be skipped if they are not fully understood.
crcputu accumulates crc for the first 10 bytes of the 0.10//Serial Buffer CRC accumulates
crc for 10,10//second 10 bytes 0x0A 0x0D
51spstr4Split string
usage: spstr <src>,</src><dest>,</dest><key>,</key><index>
<src>is an src .txt attribute or string data constant</src>
<dest>is the .txt property where the result is stored</dest>
<key>is a double-quoted text delimiter</key>
<index>is the result of a zero-index replica to be returned
spstr "ab3cd3ef3ghi",va1.txt,"3",0//returns the ab string before the first
delimiter occurs spstr "ab3cd3ef3ghi",va1.txt,"3",2//second delimiter returns the ef string after it occurs</index>

4. GUI Design Commands

NumbernameNumber of ParametersDescription
1Cls1Clean the screen and fill the entire screen with the specified color
usage: cls <color>
<color>, decimal number is 565 Color Value or Color Constant
cls BLUE // Clear screen and fill with BLUE color
cls 1024 // Clear screen and fill with color 1024</color>
2Pic3Use of a Source Image Images at the specified
coordinate: pic <x>,<y>, <picid> </y> </x>
<x>is the x coordinate of the upper-left corner where the picture should be drawn</x>
<y>is the y-coordinate of the upper-left corner where the picture should be drawn</y>
<picid>is the number of the Source Image in the HMI design
pic 10.20.0 // Display Source Image #0 in the upper left corner (10.20) Display Source Image
#0 pic 40,50,1 // Display Source Image #1 with upper-left corner (40.50)</picid>
3picq5Crop Picture from Source Image using defined field
– replaces the defined area with content in the same area of the Source
Picture – The Source Image must be full-screen size or the field may be undefined
usage: picq <x>, , , ,<y><w><h>, <picid> </h> </w> </y> </x>
<x>is the x coordinate of the upper-left corner of the defined crop area</x>
<y>is the y-coordinate of the upper-left corner of the defined crop area</y>
<w>is the width of the defined crop area</w>
<h>is the height of the defined crop area</h>
<picid>is the number of the Source Image in the HMI design
image 20,50,30,20,0
// field 30×20, (20.50) (to 49.69), source image from 0</picid>
4xpic7Advanced Image Crop
source Source Image to crop area create at target coordinate
usage: xpic <destx>,<desty>,</desty> </destx><w>,<h>,</h></w><scrx>,<scry>,</scry></scrx><picid>
<destx>is the x coordinate of the destination upper-left corner</destx>
<desty>is the y-coordinate of the upper-left corner of the target</desty>
<w>is the width of the defined crop area</w>
<h>is the height of the defined crop area</h>
<scrx>is the x coordinate of the upper-left corner of the defined crop area</scrx>
<scry>is the y-coordinate of the upper-left corner of the defined crop area</scry>
<picid>is the number of the Source Image in the HMI design
xpic creates 20,50,30,20,15,15,0 // crop area 30×20, (15.15) (44.34),
// Source Image from 0 and in the upper left corner (20.50)</picid>
5xstr11Prints text on a Nextion device using the field defined for text processing
Usage: xstr<x>,<y>,<w>,<h>,<font>,<pco></font></h></w></y></x>,<bco>,<xcen>,<ycen>,<sta>,<text></sta></ycen>
<x>is the x coordinate of the upper-left corner of the defined text field</x>
<y>is the y-coordinate of the upper-left corner of the defined text field</y>
<w>is the width of the defined text field</w>
<h>is the height of the defined text field</h>
<font>is the number of the Source Font</font>
<pco>is the foreground color of the text (Color Constant or color value 565)</pco>
<bco>is picid if a) the background color of the text or b) is set to 0 or 2.</bco>
<xcen>is Horizontal Alignment (0 – left, 1 – centered, 2 – right)</xcen>
<ycen>is Vertical Alignment (0 – top/top, 1 – medium, 3 – bottom/bottom)</ycen>
<sta>background is Fill (0 – cropped image, 1 – solid color, 2 – image, 3 – none)</sta>
<text>is the string content (fixed or .txt attribute), that is, "China" or va0.txt
xstr 10,100,30,1,WHITE,GREEN,1,1,1,va0.txt
// va0.txt.txt Use 100.30 between (10.10) and (109×.39) to print the contents of the .txt
// Font Source 1 creates Green letters on a white background with both
// horizontal and vertical centering and sta, is set to solid color.</text>
6fill5Fills a defined field with the specified color
usage: fill<x>,<y>,<w>,<h>,<color></h></w></y></x>
<x>is the x coordinate of the upper-left corner of the defined fill area</x>
<y>is the y-coordinate of the upper-left corner of the defined fill area</y>
<w>is the width of the defined fill area</w>
<h>is the height of the defined fill area</h>
<color>fills in the
150.50 field between // (20.20) and
(169.69) with 56×5 Color 1024</color>
7Line5Use of a point-to-point line plotter with the specified
color: line <x1>,</x1><y1>,</y1><x2>,</x2><y2>,<color></y2>
<x1>is the x coordinate of the starting point of the line to be drawn</x1>
<y1>is the y-coordinate of the starting point of the line to be drawn</y1>
<x2>is the x-coordinate of the endpoint of the line to be drawn</x2>
<y2>is the y-coordinate of the endpoint of the line to be drawn</y2>
<color>draws a BLUE line between line color, decimal 565 Color Value, or Color
Constant, line 20,30,170,200, BLUE // (20.30) and (170,200).</color>
8Draw5Draw a hollow rectangle around the area specified by the specified color
usage:draw <x1>,</x1><y1>,</y1><x2>,</x2><y2>,<color></y2>
<x1>is the x coordinate of the upper-left corner of the rectangle area</x1>
<y1>is the y-coordinate of the upper-left corner of the rectangle area</y1>
<x2>is the x coordinate of the lower-right corner of the rectangle area</x2>
<y2>is the y-coordinate of the lower-right corner of the rectangle area</y2>
<color>is the color of the line, decimal number 565 Draw a Green rectangle between 565 Color Value or Color Constant
10,10,70,70,GREEN // (10.10) and (79.79)
// (x1.y1) to (x2.y1) to (x2.y2) to (x1.y2) to (x1.y1)</color>
9cir4Draw a hollow circle with the specified radius and specified color
usage: cir <x>, ,<y>,<radius>, <color> </radius> </y> </x>
<x>is the x coordinate of the center point of the circle</x>
<y>is the y-coordinate of the center point of the circle</y>
<radius>is a radius in pixels</radius>
<color>is the line color, the decimal number is 565 Color Value or Color Constant
cir 100,100,30,RED // creates a hollow Red circle with a circle center (100,100),
// 30 pixel radius, 61 pixel diameter, (70.70) to (130,130) within the boundaries.</color>
10cirs4Draw a circle filled with the specified radius and specified color
usage: cirs <x>, , ,<y><radius>, <color> </radius> </y> </x>
<x>is the x coordinate of the center point of the circle</x>
<y>is the y-coordinate of the center point of the circle</y>
<radius>is a radius in pixels</radius>
<color>is the fill color, the decimal number is 565 Color Value or Color Constant
cir 100,100,30,RED // central (100,100) which creates a full Red circle,
// 30 pixel radius, 61 pixel diameter, (70.70) to (130,130) within the boundaries.</color>

5. Color Code Constants

NumberConstant565 Color ValueLegend Color
1BLACK0Black
2BLUE31Blue
3BROWN48192Brown
4GREEN2016Green
5YELLOW65504Salim
6RED63488Red
7GRAY33840Gray
8WHITE65535White

6. System Variables

NumberNameDon't understandDescription
1DpCurrent
Page Number
dp=1, n0.val=dp
read: Contains the current page displayed according to the HMI design
write: change the page to the specified value (same effect as the page command)
min 0, the maximum number of pages available in the user's HMI design.
2dim
dims
Nextion Backlightdim=32, dims=100
Sets the backlight level to
percentage min 0, maximum 100, default 100 or user-defined
Note: dim=32 will set the current backlight level to 32%.
Using dims=32 will set the current backlight level to 32%, saving it as the new power at the default backlight level, which continues until it is changed.
3baud
bauds
Nextion
Baud Rate
baud=9600 sets bauds=9600
Nextion Baud rate to bits per second
min 2400 max 921600, default 9600, or user-defined
valid values: 2400, 4800, 9600, Note: baud=38400 will set the current baud rate to 38400, 19200, 312500, 38400, and 115200,
230400, 250000, 256000, 512000, and 921600.
Using bauds=38400 will set the current baud rate to 38400 and save it as new at the default baud rate, which continues until it is changed.
Note: In rare cases, bauds may be lost. With the addition of the Editor Program.s property, it is now recommended that you specify the baud rate baud=9600 that you want between notifications and before the page0 command, and that the first page is now added bauds=9600 to the HMI Preboot Event.
4spax
spay
Font
space
spax=2 sets the default rendering area for spay=2
xstr:
horizontally between font characters
with additional pixels, and vertically between additional pixels and lines (if multi-line).
min 0, max 65535, default 0
Note: Components now have their own individual .spax/.spay attributes, and they are now used to determine the range for individual components.
5ThcTouch
Brush
Color
thc=RED, thc=1024
Sets the color of the touch drawing brush min
0, max 65535, default 0
Valid options are color constants, or decimal is 565 color value.
6thdraDraw with touchthdra=1 (on), thdra=0 (off)
Turns the internal drawing function on or off.
Min 0, max 1, default 0
With the drawing function turned on, Nextion will follow the drag by tapping with the current brush color (as determined by the thc variable).
7usspSleep mode without serial connectionussp=30
After internal, the non-serial timer sets to the specified value in seconds
min 3, max 65535, default 0 (max: 18 hours 12 minutes 15 seconds)
Nextion will automatically go to sleep when this timer expires.
Note: To disable sleep without seriality, the Nextion device must wake up to give ussp=0, otherwise it will continue until the USSP is set once, restarted, or reset.
8thspSleep mode without touchingthsp=30
After internal touch, the sleep timer is set to the specified value in seconds
min 3, max 65535, default 0 (max: 18 hours 12 minutes 15 seconds)
Nextion will automatically go to sleep when this timer expires.
Note: To disable touch-to-sleep sleep, the Nextion device must wake up to give thsp=0, otherwise it will continue until thsp is set once, restarted, or reset.
9thupAutomatic sleep in touchthup=0 (wake), thup=1 (wake at touch)
Adjusts whether Nextion automatically wakes from sleep mode when touch is pressed.
When min 0, max 1, default 0
Is Value 1, and Nextion is in sleep mode, the first touch only triggers automatic wake mode, and touch does not trigger any event.
thup has no effect on sendxy, sendxy will work independently.
10sendxyTouch coordinatessendxy=1 (start sending) sendxy=0 (stop sending)
sets whether Nextion 0x67 and sends 0x68 Return Data
min 0, max 1, default 0
– Less accuracy to edges and closer to center.
Note: waiting for a full pixel (0.0) or (799,479) simply cannot be achieved.
11delayDelay/StandbyDelay=100
ms creates a stop in Nextion code execution for the specified time of minimum
0, maximum 65535
Because the delay is interpreted, the total is avoided without stopping. Incoming serial data is retrieved and stored in the buffer, but not processed until the delay ends. If a delay of more than 65,535 seconds is required, multiple latency statements must be used.
delay=-1 max. = 65.535 seconds.
12SleepSleepsleep=1 (Enter sleep mode) or sleep=0 (Wake out)
sets Nextion mode between sleep and wakefulness.
Min 0, max 1, or default 0
The Nextion device will automatically refresh the page when it wakes.
(as determined by the value in the wup variable) and reset the backlight brightness (as determined by the value in the dim variable). A get/print/printh/wup/sleep command can be executed during sleep mode. Extended IO binding interruptions do not occur in sleep.
13bkcmd
Error/Error-Inaccurate Return Data
Debugging
bkcmd=3
Sets the fallback level for commands processed over a series.
min 0, max 3, default 2
– Level 0 Off – not returned successfully/unsuccessfully
– Level 1 is OnSuccess only when the last serial command succeeded.
– Level 2 is OnFailure only when the last serial command fails
– Level 3 is Always, returning the 0x00 to 0x23 result of the serial command.
The result is sent only after the serial command/task is completed, because this provides an invaluable state for debugging and branching. Chapter 7 Nextion Return Data Table 2 is not subject to bkcmd
14RandRandom Valuen0.val=rand
Reads Salt. The value returned by Rand is random each time it is referenced.
default range – 2147483648 to 2147483647 rand
range, set with user-customizable randset using
randset command, will continue until restart or reset
15sys0
sys1
sys2
Digital System Variablessys0=10 sys1=40 sys2=60 n0.val=sys2
System Variables are inherently global without the need to define or create them.
They can be read or written from any page. Innuenlar numbers marked 32 bits.
The minimum value of -2147483648 is the maximum value of 2147483647,
and the recommended uses of sys variables include:
– as temporary variables in complex calculations –
as parameters for switching to click or switching between pages.
16wupWake Pagewup=2, n0.val=wup
When exiting sleep mode, nextion sets which page it
loads min 0, max when the number of the last page in the HMI or the default is 255
wup=255 (not set to any existing page)
– Nextion wakes up to the current page, refreshes only components
wup, adjustable even when nextion is in sleep mode
17usupWake Up When Serial Data Arrivesusup=0, usup=1
Adjusts whether serial data automatically wakes Nextion.
when min 0, max 1, default 0
usup=0, send sleep=0εùù to wake nextion
usup=1 any sequence received wakes Nextion
18rtc0
rtc1
rtc2
rtc3
rtc4
rtc5
rtc6
RTC (Only valid on Enhanced and Intelligent models)rtc0=2017, rtc1=8, rtc2=28,
rtc3=16, rtc4=50, rtc5=36, n0.val=rtc6
Nextion RTC:
rtc0, 2000 to 2099, rtc1 1 to 12 months, rtc2 1 to 31 days,
rtc3 0 to 23 hours, rtc4, minutes 0 to 59 minutes, rtc5 0 to 59 seconds.
rtc6 is 0 to 6 days a week (Sunday=0, Saturday=6)
rtc6 is read-only and calculated by RTC when the date is valid.
19pio0
pio1
pio2
pio3
pio4
pio5
pio6
pio7
GPIO(Only valid on Enhanced and Intelligent models)pio3=1, pio3=0, n0.val=pio3
The default mode when the power is on is: pull up input
built-in pull up resistance: 50K
GPIO is digital. It can only get a value of 0 or 1.
– See cfgpio command to set GPIO mode
Read if in input mode, write if in output mode
20pwm4
pwm5
pwm6
pwm7
PWM Duty
Cycle(Only valid on Enhanced and Intelligent models)
pwm7=25
Value as percentage. minimum 0, maximum 100, default 50.
– See cfgpio to set GPIO mode
21pwmfPWM Frequency(Only valid on Enhanced and Intelligent models)pwmf=933
Value is in Hz. minimum value 1 Hz, maximum value 65535 Hz. default 1000 Hz All
PWM output is combined at only one Frequency, independent individual settings are not allowed.
– See cfgpio to set GPIO mode
22addrAddressaddr=257
Enables/disables Nextion's two-byte Address Mode
0 or minimum value 256, maximum value 2815. default 0
Address setting will remain the new opening default.
– see section 1.19
23tch0
tch1
tch2
tch3
Touch Coordinatesx.val=tch0, y.val=tch1
Read-only. When pressed, the tch0 x coordinate is the tch1 y coordinate.
When released, tch0 and tch1 will be 0.
tch2 holds the last x coordinate, tch3 holds the last y coordinate.
24recmodProtocol Re parserecmod=0, recmod=1
Set passive or active Protocol Re parsing mode.
When min 0, max 1, default
0 recmod=0, Nextion is in passive mode and processes serial data according to the Nextion Command Set. Most HMI applications do not require Protocol Re parsing and should be skipped if they are not fully understood.
25usizeBytes in Serial Buffern0.val=usize
Read-only. Applies in Active Protocol Re parsing mode.
When at least 0, maximum 1024
Nextion-enabled Protocol Re-Parsing mode, the usize reports the number of bytes available in the serial buffer. Most HMI applications do not require Protocol Re parsing and should be skipped if they are not fully understood.
26u[index]Serial Buffer Datan0.val=u[0]
Read-only. Applies in Active Protocol Re parsing mode.
with a minimum of 0 and a maximum of 255
Nextion enabled Protocol Re-Parsing mode, the u[index] array returns the byte in the location directory in the serial buffer. Most HMI applications do not require Protocol Re parsing and should be skipped if they are not fully understood.
27eql
eqm
eqh
Equalizer Groupings(Applies to Nextion P Device)eqm=7
is not supported in debug simulator.
min 0, max 15
eql: Bass (31Hz – 125Hz, eq0.. eq2)
eqm: Medium range (250Hz – 2000Hz, eq3.. eq6)
eqh: Treble (4000Hz – 1600Hz, eq7.. eq9)
Setting to 7 is balanced without slimming and gaining
0..6 setting, the lower the value, the higher the slimming
8..15 setting, the higher the gain
note: The base of the equalizer eq0.. It is operated according to eq9,
when a group is changed, the corresponding individual bands are replaced, but changing a single band does not change the group. (that is: the eql=4 setting sets eq0, eq1, and eq2 to 4, but the eq1=3 setting does not change the eql to 3, the eq0 and eq2 remain in 4).
28eq0
eq1
eq2
eq3
eq4
eq5
eq6
eq7
eq8
eq9
Equalizer
Individual
Bands(Applies to Nextion P Device)
eq6=7
is not supported in debug simulator.
min 0, max 15
eq0 (31Hz), eq1 (62Hz), eq2 (125Hz),
eq3 (250Hz), eq4 (500Hz), eq5 (1000Hz), eq6 (2000Hz),
eq7 (4000Hz), eq8 (8000Hz), eq9 (16000Hz)
7 settings, Balanced without slimming and
gaining 0..6 setting, The lower the value, the higher the slimming
8..15 setting, the higher the value, the higher the gain
NOTE: The base of the equalizer is eq0. It is operated according to eq9,
when a group is changed, the corresponding individual bands are replaced, but changing a single band does not change the group. (that is: the eql=4 setting sets eq0, eq1, and eq2 to 4, but the eq1=3 setting does not change the eql to 3, the eq0 and eq2 remain in 4).
29volumeVolume (Valid on Nextion P Device)volume=60
is not supported in the Debug Simulator.
min 0, max 100
volume continues and sets the opening default for volume
30audio0
audio1
Audio Channel Control(Applies to Nextion P Device)audio0=0// channel 0 Stop playing audio
min 0, max 2
0 (stop), 1 (continue), 2 (pause).
Notes: The playback instruction is used to configure and start audio playback. audio0 and audio1 are used only to control the channel. It can only be continued if the channel is paused, and a playback instruction is required to restart if the channel is stopped. Audio playback is global and playback continues after leaving and replacing pages, if you want the channel to stop when it exits the page, you should do so in the page break event
31crcvalCRC Valuex.val=crcval
Read-only. Keeps the accumulated value of the existing CRC.
Use crcrest to reset and start
Use crcputs, crcputh, or crcputu to accumulate
32lowpowerLow Power Mode (deep slep)Works on the Discovery Series. Low Power starts deep sleep at 0.25mA,
adjusting whether Nextion enters deep sleep mode in the sleep command.
min 0, max 1, default 0
lowpower=0 (normal operations), lowpower=1 (deep sleep enabled)
In deep sleep mode, the wake-up time will be longer, data will probably be lost when receiving the serial power wake-up command. It is recommended that you send an empty command (NIS 1.1 termination) and wait 500ms before processing.

BC Format of Nextion Return Data

Return Codes linked to bkcmd value greater than 0

NumberBytebkcmdlen(length)Don't understandFormat
10x002,34Invalid
Instruction
0x00 0xFF 0xFF 0xFF
Returned when the instruction sent by the user fails
20x011,34Successful Instruction0x01 0xFF 0xFF 0xFF Returned
when the instruction sent by the user succeeds
30x022,34Invalid Component ID0x02 0xFF 0xFF 0xFF returned
when invalid component ID or name is used
40x032,34Invalid Page ID0x03 0xFF 0xFF 0xFF returned
when invalid page ID or name is used
50x042,34Invalid Image ID0x04 0xFF 0xFF 0xFF returned
when invalid image ID is used
60x052,34Invalid Font ID0x05 0xFF 0xFF 0xFF returned
when invalid font ID is used
70x06 (P)2,34Invalid File Operation0x06 0xFF 0xFF 0xFF Returned
when file operation fails
80x092,34Invalid CRC0x09 0xFF 0xFF 0xFF
CRC-validated Instructions are returned when CRC check fails
90x112,34Invalid Baud Rate Setting0x11 0xFF 0xFF 0xFF returned
when invalid baud rate is used
100x122,34Invalid Waveform ID or Channel Number0x12 0xFF 0xFF 0xFF returned
when using Invalid Waveform ID or Channel #
110x1A2,34Invalid Variable name0x1A 0xFF 0xFF 0xFF returned
when invalid variable name or invalid attribute is used
120x1B2,34Invalid Variable Operation0x1B 0xFF 0xFF 0xFF returned
when the Variable Operation is invalid.
for example: Text assignment t0.txt=abc or t0.txt=23, Numeric assignment j0.val="50" or j0.val=abc
130x1C2,34Assignment could not be assigned0x1C 0xFF 0xFF 0xFF Returned
when attribute assignment cannot be assigned
140X1D2,34EEPROM Operation failed0x1D 0xFF 0xFF 0xFF Is
returned when an EEPROM Operation fails
150x1E2,34Invalid Parameter Quantity0x1E 0xFF 0xFF 0xFF
Returned when the number of command parameters is invalid
160x1F2,34I/O I/O I/O Operation failed0x1F 0xFF 0xFF 0xFF Returned
when an IO operation fails
170x202,34Escape Character Invalid0x20 0xFF 0xFF 0xFF Returned
when an unsupported escape character is used
180x232,34
Variable name too long
0x23 0xFF 0xFF 0xFF
returned when the variable name is too long. 
The maximum length is 29 characters: 14 + "."
+ for 14 components.

Return Codes that are not affected by the bkcmd value that is valid in all cases

NumberBytelen(length)Don't understandFormat
190x006Nextion Startup0x00 0x00 0x00 0xFF 0xFF 0xFF returned
when Nextion starts or resets
200x244Serial Buffer Overrun0x24 0xFF 0xFF 0xFF is
returned when a Serial Buffer overflow occurs, the buffer continues to receive the current instruction, all previous instructions are lost.
210x657Touch Activity0x65 0x00 0x010x01 0xFF 0xFF 0xFF
returned when touch occurs and the

component's corresponding Send Component ID is checked in the user's HMI design.

0x00 is the page number,
the 0x01 is the component ID, 0x01

event (0x01 Press and Release 0x00)
data : Page 0, Component 1, Printed  
220x665Current Page Number0x66 0x01 is returned when the
0xFF 0xFF 0xFF send command is used.
0x01 current page number is
data : page 1
230x679Tap Coordinate (awake)When 0x67 0x00 0x7A 0x00 0x1E 0x01 0xFF 0xFF 0xFF
is sendxy=1 and is not in sleep
mode, the x coordinate in
0x00 0x7A large endian order, the y coordinate in the 0x00 0x1E large endian order,
is returned when there is 0x01 event ( 0x01 Press and 0x00 Release)
( 0x00 *256+ 0x71 , 0x00 *256+ 0x1E )
data : ( 122 , 30 ) Pressed
240x689Tap Coordinate (sleep)When 0x68 0x00 0x7A 0x00 0x1E 0x01 0xFF 0xFF 0xFF
sendxy=1 and when you wake
up, the x-coordinate in the
0x00 0x7A large endian order, the y-coordinate in the 0x00 0x1E large endian order, is returned when there is 0x01 event
(0x01 Press and 0x00 Release)
(0x00 *256+ 0x71 , 0x00 *256+ 0x1E )
data : ( 122 , 30 ) Pressed
250x70miscellaneousString Data Added0x70 0x61 0x62 0x31 0x32 0x33 0xFF 0xFF 0xFF
returned when the get command is used for a string.
Each byte is converted to a character.
data :
ab123
260x718Digital Data Added0x71 0x01 0x02 0x03 0x04 0xFF 0xFF 0xFF is
returned when the get command is given to return a 4-byte 32-bit value in a small endian layout.
(0x01 + 0x02 *256+ 0x03 *65536+ 0x04 *16777216)
data :
67305985
270x864Auto-Entered Sleep Mode0x86 0xFF 0xFF 0xFF
Nextion is automatically returned when it goes to
sleep Sleep=1 does not return a 0x86
280x874Auto-Wake From Sleep0x87 0xFF 0xFF 0xFF
Nextion is automatically returned when it wakes
Sleep=0 does not return 0x87
290x884Nextion Ready0x88 0xFF 0xFF 0xFF is
returned when Nextion is opened and now successfully started
300x894Start microSD Upgrade0x89 0xFF 0xFF 0xFF Is
rotated when power is turned on, the installed microSD is
detected, and the microSD upgrade process begins
310xFD4Transparent Data Complete0xFD 0xFF 0xFF 0xFF is
returned when all desired bytes of Transparent Data mode are received and immediately exit transparent data mode (see 1.16 )
320xFE4Transparent Data Ready0xFE 0xFF 0xFF 0xFF
Transparent Data mode is rotated at will and the device is now ready to start receiving the specified amount of data (see 1.16 )