Start a new topic

Newb - question

Hey Nextion people,

Quick question: does the "sendxy" cmnd stream coordinates? 

I just found out about this display yesterday and imediately placed an order for the 3.5 enhanced and expansion board. So, I have only got acess to the simulator and this only returns the start position of a touch.

I'm hoping that I can get real time xy data from the actual device... To control a pan/tilt device etc.



P.S. So far I'm duly impressed with the GUI but have to say that it is really intensive on PC resourses - the simulator maxes out the virtual processors and flips my laptop into hot mode straight away - not good when you are actually on battery power. 

And, with just the GUI running, sleeping the PC keeps the cooling fan running... I can run multiple versions of the Arduino IDE, Chrome, resorce monitor, word, viber, etc and sleeping the laptop really sleeps the laptop - no heat - no fan. 

I'm sure these issues will be resolved in due course but in the meantime - Thanks for this - a really cheap display with many features :-)

with the command sendxy=1

The coordinates for every touch pressed and touch release is sent to the mcu over serial

in the format of: 0x67 0x00 0x53 0x00 0xE0 0x01 0xFF 0xFF 0xFF

0x67 as the first byte says Touch Coordinates Return Codes next (expect 9 bytes total)

0x00 0x53 - x coordinate, 83

0x00 0xE0 - y coordinate, 224

0x01 - touch type: if 0x01 Pressed if 0x00 Released.

0xFF 0xFF 0xFF - Data Terminated.

the command sendxy=0 turns sending the coordinates off

As far as the heating issue, which version of the Nextion Editor, and what version of Windows?

Hey Patrick,

Yeah, I thought so - bummer! I was hoping for realtime mouse or pan/tilt etc... I can work out a vector and then send it to my device but the actual 'press - drag - lift' will have to be a guesstimate and then the action will happen - overshoot/undershoot - another gusstimate etc...  Also, this means that a simple drawing sketch, signature capture with a draw of the line being traced is totally out of the question.

For what I have in mind I will need to get an Adafruit SPI display for real time control. Which is a whole lot more codeing and stiffing about...

NB: The simultor gives two identical byte strings both of which are the point of origin. (see attached) is this a bug? I hope at least the hardware will give me two points to work with.

I don't suppose the code supports object status adressing ie, if(b0.clicked) ???

I could then test a 'pressed' status on a 20mS timer...

I assume I have the latest vers of the Editor V4.0 and am running Win 10.(i5 Dual 2Ghz 16Gb ram) I have other 'beta' sim software that does the same thing, and on my main PC as well - indeed if I use expolorer and have more than 10 tabs open I get the same thing. That's why I switched to chrome. Windows power management... Havn't tried Nextion on my PC (i5 Quad 3.2Ghz 8Gb ram, Win 7pro) yet but from experience, it will be the same. 

Launch Nextion and Resource monitor the CPU green line @ 3-5% (blue line at about 30%) With the simulator this jumps to 30% and 100% and then the cooling fan kicks in (full speed). With no simulator and the laptop in sleep mode the fan comes on (slow) about 50% of the time...

Thanks for your attention,


(5.58 KB)

Look again at the sendxy.PNG you just sent.  they are not exactly the same.  The coords are.

But one is Pressed and the other is Released.  Yeah it doesn't track drag.

Oh the code does not support an if( object pressed) but ...

Click on an Component, its touch pressed and touch release code section show

The Send Component ID allows you to catch when an object is pressed and when it is released.

The Send Component ID sends out 0X65 0X00 0X02 0X01 0XFF 0XFF 0XFF

First byte identifies the component touch data follows

2nd byte is which page

3rd byte is which component

4th is 1 for pressed, 0 for released

5-6-7 is Data Terminator

Just curious, what MCU are you planning to use with the Nextion.

Challenging to get an MCU to track real time mouse pan/tilt in realtime via serial

Yep, I know 'when pressed' is different to 'when released' - I was refering to the coordinates, ie, 'where pressed' and 'where released' ie, the difference between the starting point and the ending point...

The send ID component would rely on the MCU to figure it out, which of course it can do with defined UP-DOWN-LEFT-RIGHT buttons etc, which I can do with physical buttons attached directly to the MCU... Like I say I wanted start and finish coordinates.

Using a Leonardo emulating a keyboard/mouse you can use a thumb joystick or mini trackball to move the cursor around the screen or move a pan/tilt etc. I've had a joystick with an I2C mux in between it and a leonardo with no problem - but who like these little joysticks? They are an absolute pain to use. The trackball is my best option so far.

I would have thought 115200Kbs serial acomplishing this easily... If blutooth can do it... In Vers two I was going to use an UNO with USB host controller running a blutooth link to the PC for a wireless vers. Havn't had the time to get into host controllers and not sure if the libraries exist yet for blutooth and Arduino...

An SPI display will transmit realtime xy coordinates, so a touchscreen mousepad pointing device using a Leonardo seems feasable, I'm just trying to eliminate writing all the code. There are other serial TFT's that I believe also transmit realtime coordinates but @ $160.00ea plus the MCU/box/battery etc I'm looking for a cheaper solution...

I will try the nexion either using direction buttons on the screen, or a mini trackball - but this is not as elegant as an all in one anwer :-) I need to build up 11 of these and I've got a small spi cap touch screen - it's just, the coding time to polish the interface I lack...

Thanks again,


I wish you well with your project.  It is unfortunate that the Nextion doesn't provide the dragging you are seeking.  The sendxy pressed and released as implemented allows a user to pair object released with the previous object pressed on their mcu side.  Again, it's not the same kind of application you are seeking without more coding. Also, we have a modest mcu driving the display, at the price point you are suggesting, perhaps we could have implemented the Supercomputing Cray of MCUs. 

I would also recommend that you re-check the margins your source is seeking to profit by.  As 4D Systems and your source are both Australian, your source identified in the your links above is greedy and far overpriced in comparison to purchasing directly for $101AUD. It's a $600+AUD savings on 11

Yeah? Wow, I've been on their site and everything was in USD - I've actually ordered a 3.5 inch from another supplier for $130... I'll let you know how it goes.

Had another thought and question - can you define an array in Nextion? ie, of vars or hotpoints/nums/txts/buttons etc?

How good is the simulator? - I don't have hardware yet. I put a few buttons on a page and pressed one them and then with the mouse button held down, dragged the cursor around the screen and over the other buttons. The first button stays down until the mouse button is released... Does the hardware do the same? ie, If you drag your finger down a row of buttons, do they turn on and of as you swipe over them or, does the first button stay on until a release?


Also, jus thinking out loud - what we need is a two dimentional slider object.

A slider puts out realtime data in one axis, ie will update a num as you move it and I've tried putting: print h0.val in the move event and this works!! In one dimention anyway, ie it does stream the value as you slide the cursor up and down without waiting for a release to do it.

Can't wait to test this theory in hardware...

Can the sendxy data be written to an internal var or array or object?

Still working on it,



The debug simulator is a fair representation of the firmware, the hardware is quicker than the simulator.  The simulator does not have any extra functions that the firmware cannot do.  The slider is a special case with an onMove event.  The sendxy can not be redirected.

Cool and thanks again - I'll put a request in for a two dimentional slider... This will solve both of my project problems: pan tilt / mouse.

Still can't find a reference to arrays... Can we define an array of anything in nextion?



There is one Component array that is valid for a current page.

b[.id] will work with the component record with the .id attribute of .id

There are no other arrays, and users can not define an array short of a basic string
or numeric integer array by adding many variables and making use of this b[ ] component array

The HMI is a static design, and essentially creates lookup tables to work with
your HMI resources via the interpreter in the firmware.

When you realize that on the Basic model of the Nextion, its onboard mcu is limited
An STM32F030C8T6 8K SRAM, and 64KB Flask with 4M/16MB SPI Flash.
The 8K SRAM is responsible for both the firmware and the HMI,
- reserving 3584 bytes per page for each page in the HMI file.

When you consider that the firmware and the User HMI runs in this limited space, it is actually quite amazing. However, much of the features you are looking for require much more compute power, though some can be realized through creative coding, some are not viable from the limitations of the existing hardware.

The HMI design is statically defined at design time.

Cheers again Patrick,

You seem to be a full time one man forum guru/saint! ?? Are you an employee of Nextion? Do you own shares?

I asked about these arrays here because a search for them got me references to your code posted as tft files, can you post your HMI files for your clock example and typewriter? Not that I'm 'uncomfortable' with that old ver dwnload mess - but for the sake of NEWBs who really are!

Thanks again,


Hi Clifford,

we only try to bring things a bit into the right order and make things a bit better ... and no, we don't own shares :-)

Normally we don't post HMI sources, we want to give inspirations, but no ready to use code solutions ...

But just wait for Patrick, maybe .....  :-)


Thanks Gerry,

You guy's are certainly keen...

Do you mean that if I do all of the following I just get to see it work - no code to play with etc ?

The older versions of the Nextion Editor are under Announcements in the thread

Download the latest Nextion Editor

DO NOT Install an older version when you have a new version of the Nextion Editor

Instead the file needs to be extracted from the installation file and then

unpacked into a clean folder. 

1) Create a new folder on your system

2) Copy the installation folder to your new folder

3) from the command line, change directory to your new folder

4) extract with > nextion-setup-v0.38.exe /extract

5) with 7zip or equivalent, unpack the file

6) remove the setup exe file (to avoid accidental installation)

7) Run the older version Nextion Editor from that new folder.

8) Without opening any projects, click Debug

   - this will ask you to select a TFT file to run.

If you are uncomfortable with any of these steps, DO NOT PROCEED.

The best option is to ask the author if they are willing to share their HMI file.

Well Clifford,

I didn't always work for itead as staff, that's only in the last few weeks.  So in the months and months before that, there were questions not being answered with a staff response sometimes for months.  So yes, I would provide answers to help some get their projects unstuck and understand how the TFT was built and its firmware.  At the time, if I hadn't answered your questions, they could have sat with no response for months.

My opinions then were personally my own and did not necessarily always favour itead and I can see in the threads the difference between personal replies and a staff reply (staff replies have a hue, and my avatar is not a P as just my normal user was)  But yes, I now work for itead, and one of my main responsibilities is to reply on the forum.

I have to apologize for the lack of hmi files to accompany the tft files on my posts that lack the HMIs.  That was my former pre-staff self being arrogant and sort of a show-off.  I don't have the HMI anymore, it was posted in a "see it can be done" attitude.  The clock was made with 180 variables that packed x/y endpoints where the origin center was known, and used the line command and the undocumented b[.id] component array.  The timer was set in around 890ms to account for the time it took to run the code.  The typewriter was carefully positioned text components with hotspots to swap all characters out when the shift state changed and some old DOS 3.3 techniques when edlin ruled and full screen editors were only starting to come into existence.

On a brighter note, my smarTank2.0 project is going to be a full blown Tutorial.

Login or Signup to post a comment