Nextion Button communication with arduino mega 2560

Hi guys I need help.
I want to do a simple test where when a button is pressed on the nextion display, a text box below will show a message "Hello"
I am stuck in this please help

#include <EasyNextionLibrary.h>

// Create an EasyNex object
EasyNex myNex(Serial1);

// Define the trigger function
void trigger0() {
  // Set the text of the text box to "Hello"
  myNex.writeStr("t0.txt", "Hello");
  Serial.println("TRIGGERED");
}

void setup() {
  // Begin serial communication with the Nextion display
  Serial.begin(9600);
  
  // Initialize the EasyNex library
  myNex.begin(9600);
}

void loop() {
  // Listen for events from the Nextion display
  myNex.NextionListen();
}

I am using easynextionlibraryand want to use trigger, as in my project requires me to use trigger function

Button.zip (18.7 KB)

conncections are:

Arduino | Nextion
TX1 | RX
RX1 | TX
GND | GND
5V | 5V

please help @cattledog

This is a new problem

Uncheck the box for Send Component ID in the touch release event for the newtext button. There should just be TouchReleaseEvent(1).

I'm not certain of the root cause but the addition of the component id affects the recognition of the trigger functions by the Arduino. It's not well documented, but all the Easy Nextion Library examples and the HMI code do not have that box checked.

1 Like

Thanks
I got it