Start a new topic

NEXTION LCD help

Good day. I need advice.Right to the point:I need a fixed set of attribute ID button. Optionally change it for ever what will suit me. This ID can not be changed. And when I delete a button and the ID shift, then I have it in Arduino transcripts and control.Is there such a possibility?The problem is that it uses two LCD on the same serial line that suits me. But I understand that signals on the direction of an address ID. If at least "objname" responded to the Arduino without an address. Example.

NexButton setsp_sv2dec = NexButton (7, 4, "sw_sp_sv2d '); NexButton setde_sv2dec = NexButton (7, 4, "sw_de_sv2d ');

In this case nextion used only the first one. Although the software is every Nextion display defined for each button separately.
1 LCD-defined "objname": sw_sp_sv2d

2 LCD-defined "objname": sw_de_sv2d

After clicking on either the LCD Arduino always accepted only the first one. If the address "7 4", delete or change it to zero, it does not work. although changes to any control objname Name.
For just any help thank you in advance

First - IDs can be changed with the two arrow buttons on the Nextion Editor Toolbar.

 - the up arrow (Bring Top) will set the ID to the last and highest component number

 - the down arrow (Bring Bottom) will set the ID to the first with component .id of 1

   (the page component is always .id of 0)


When designing the HMI in the Nextion Editor, it is always a good strategy I use to move the components that I am satisfied with to the bottom and arrange their number sequencing as I desire.  This leaves the higher numbered components as those I am not yet satisfied with.  Should I end up deleting an unsatisfied component, it will not affect my numbering sequence of my satisfied components that I have sent lower.  It is furthermore important to be satisfied with this sequence and order before heading over to the MCU side coding as "changing the sequence in the HMI, means having to make code changes".


Second - understanding the Nextion communications.

- when a button is pressed (you reference buttons) the Nextion sends a return code

   0x65 0x07 0x04 0x01 0xFF 0xFF 0xFF.

- when I set the text on a button, I must sent out page7.sw_sp_sv2d.txt="MyText"ÿÿÿ


So in the Arduino Library, the NexButton parses for these two scenarios.

Declaring a button as

NexButton setsp_sv2dec = NexButton (7, 4, "sw_sp_sv2d ');

sets setsp_sv2dec as a NexButton class for you to use Arduino side


When you look deeper into the library code (which you should to be familiar with)

functions like setText parse this so that it knows to send your objname sw_sp_sv2d

 as sw_sp_sv2d.txt="<param_of_setText>" and add the terminator 0xFF 0xFF 0xFF (or ÿÿÿ)

from the third parameter of your declaration.


It also knows that incoming touch events for this button will be

 0x65 0x07 0x04 0x01 0xFF 0xFF 0xFF - touch press tiggered

 0x65 0x07 0x04 0x00 0xFF 0xFF 0xFF - touch release triggered

from the first two parameters of your declaration


In the example you have provided above, both are at the same touch event page 7 and .id 4

NexButton setsp_sv2dec = NexButton (7, 4, "sw_sp_sv2d ');

NexButton setde_sv2dec = NexButton (7, 4, "sw_de_sv2d ');


It is impossible for two components within the HMI design to have this scenario

The Nextion Editor numbers sequentially, even when re-ordering components.

Therefore, setting from Arduino will set the correct button as objnames are unique

- but receiving is not unique, and only one could possibly respond.


I Hope this brings some light to your issue

Thank you very much for your answer. Me would have sufficed if the ID could be changed and choose ake want me and not the choice of which software. If I can, attach a picture where the mouse cursor shows the ID i can not change :(
IMG5496.JPG
(3.64 MB)

Again, the ID can be changed


First - IDs can be changed with the two arrow buttons on the Nextion Editor Toolbar.

 - the up arrow (Bring Top) will set the ID to the last and highest component number

 - the down arrow (Bring Bottom) will set the ID to the first with component .id of 1

   (the page component is always .id of 0)



Ok I understand. But the problem that only those arrows to move between components. But I want to set a specific component ID. For example, a component with ID 14 I want to change the ID 18. But to have to add more components 15,16,17. Because I know the Arduino as an example, the ID18 what is nextion his address with the page. A ID8 want to apply for a second nextion LCD. And Arduino will know that, for example. ID18 is a button for LCD button 2 and ID8 the LCD 1. Do you understand me? Thank you Martin
My point is that I have a project with two LCDs. Both LCD will serve one Arduino, which I will send the date and time. (This works for me OK) to the same ID. But there I have a switch that controls the lights and I want everyone to display control other lights. But in design will be same. All components will have the same I'll like twins graphically

You are making things way more complicated than you need to.

If an item is 14 in the HMI change it to 14 in the code


NexButton setsp_sv2dec = NexButton (7, 14, "sw_sp_sv2d ');


All the Arduino side processing is based off of setsp_sv2dec


There is only one location where the HMI is mapped and that is in the Component declarations. So unless you are attempting to reverse engineer existing software to match there is no need for what you describe.  And if reverse engineering is what you are doing .. then perhaps I need regress.

I may have missed one in cross-sending.


If you are attempting twinning, I would take the components that are the same on both and with the arrow down (Bring bottom) so that there is no gaps between and you don't need to add filler components to achieve the result.  But this twinning will require additional work and extra attention to detail


Not fully understanding your design, but one really shouldn't be attempting to put two devices on a single serial line.  Serial is meant for one transmitter and one receiver - two devices.  You'll run into many more issues.  One should be using two serial lines for two Nextions.

I know this is not standard procedure connects more LCD for one serial link.

But to me this project is good and I have also tried my beautiful it works

when the TX LCD1 passed through the diode directed to the RX Arduino. This certainly do in the second LCD. And RX both nextion involved in TX Arduino.

Everything works great, and that both LCD listen to the same signal. If there were at least able to isolate

Addressing ID display. Something like this:

 

Origin:

NexButton setsp_sv2dec = NexButton (7, 4, "sw_sp_sv2d ');

NexButton setde_sv2dec = NexButton (7, 4, "sw_de_sv2d ');

 

New:

NexButton setsp_sv2dec NexButton = (1, 7, 4, "sw_sp_sv2d ');

NexButton setde_sv2dec NexButton = (2, 7, 4, "sw_de_sv2d ');

 

While number 1 was defined in the first LCD and 2 in the second. That would be great.

It is possible to fix such a presentation? Thus, each had its LCD and does not address the problem.

I've had enough big plans with your LCD.

Thank you for your response.


If I'm still not advisable to be questioned So how should I solve a connection, for example, one of three LCD Arduino?

Connecting more than one devices (called Nextions not LCDs) on single serial


Sending: both device may receive the intended message;

Both will respond with Nextion Return Data - either at same time or slightly off time.

  - this will scramble return data (such as a desired button press)

  - imagine two mother-in-laws speaking loudly at the exact same time.

     neither conversation will be discernable.


When two devices have their own serial lines, each get their orderly turn.

The MCU decides by user code which to listen to first, and then the other.

If such Arduino is an MEGA2560 for example

 - there are 4 serials,

     Serial - usually used for debug

     Serial1, Serial2 and Serial3


If I have the same message going out to two devices then

   Serial1.print(msg);  Nextion device 1

   Serial2.print(msg);  Nextion device 2


When I listen to each in turn

   If Serial1.available  or

   If Serial2.available


There is much you will need to code, this is your domain to do


I am sorry if you have given me much doubt about, but you

are not reading the documentation available, you are not reading

the code in your Arduino Nextion Library, you are not applying basics


I would have to guess this may be too advanced to make first project

Try mastering one Nextion before attempting several.


The default Arduino Nextion Library is for a single Nextion device


A multi-Nextion library would be needed to do two or more.

Such a multi-Nextion library is user coded for specific purpose.

I would not guess such library is free, it would require much coding


Thanks for responding. Yes I understand functionality serial link. I know that it should be one to one communication line. I can fix it to each of the LCD Connect separate Arduino and reprogram communication between Arduino. But I wanted to see whether it is possible that the otherwise applicable. As I say me specifically for that project suit. I even have several orders for LCD 6 or more units and one line system there would be sufficient, but we will have to withdraw from the project because the program 6ks Arduino to communicate with each other is not for me an advantage. So I will have to look for another way. Well but not to ask. How would thus could connect 6 or more units on one LCD Arduino? When Arduino Mega 2560 contains 4 serial lines? Thank you in advance. Have a nice day.

 with 4 serial lines you can serve 4 slave devices ...


as Patrick already stated, RS232 is NOT designed as MultiMaster topology. It is a Master Slave topology ...


And in such a topology, there can only be ONE Master (Sender) at same time ...


As long as you only need to send from one Master out, you can connect as many receiving Slaves as you like, but as soon as your Slaves also start sending, it just can't be done. 


6 Nextions = 1 TX Line and 6 RX Lines (needs software addressing mechanism) ... better 6 TX / 6 RX

You might consider using a very small Arduino (a 10$ Leonardo will do) for each display that connects to it via UART and on the other hand serves an I2C interface. All will have identical, short code and an individual I2C ID.

Then you will have all Nextions on the "one wire" I2C bus, each addressable individually. Data sent out from the master Arduino can be broadcasted with address 0, whereas the responding displays will be lined up by their individual IDs.

This will work with up to 127 Nextions on one master Arduino.

Here is a nice tutorial on I2C: I2C tutorial on Tronixstuff

 

Login or Signup to post a comment