Nextion Display not communicating with Arduino


I’m very new to Arduino. I’m working on an automated Titration system.
All scripts are working. Now I decided to add a Touch Display and found the Nextion Display.
I thought that it was easy to program since I could use their GUI designer (I know that GUISlicer for other Displays exists).

I bought the Display and tried to get it running. First I couldn’t get the Arduino to communicate with it at all. I tried many different libraries until I found this [post [/url] .

I used his Sketch and HMI file. It worked! My first successful communication.

Now I wanted to bind in my components. I have a small relay (here) which is working in all my other sketches (without display).

But if I try to control it with the Nextion Display: nothing.

So now I tried creating a simple Sketch with the Display that just controls the relay but it is not working.

This is my sketch that should just turn the Pump on or off if I press a button:

#include "Nextion.h"
#include "NexText.h"
#include "NexSlider.h"
#include "NexGauge.h"
#include "NexButton.h"
#include "NexDualStateButton.h"
#include "Arduino.h"   //I know I don't need to add all these libraries since I'm not using them. 

SoftwareSerial HMISerial(10, 11);
#define motor 2

NexDSButton bt0 = NexDSButton(1,  2, "bt0");

NexTouch *nex_listen_list[] = {&bt0, NULL};

void bt0PopCallback(void *ptr)
  uint32_t dual_state;
  NexDSButton *btn = (NexDSButton *)ptr;  //I probaly can remove this stuff here, or?
  if (dual_state)               
        digitalWrite(motor, LOW);          // if my dual state buton is pressed
    digitalWrite(motor, HIGH);        // if not


void setup(void)
  pinMode(motor, OUTPUT);
  bt0.attachPop(bt0PopCallback, &bt0);
  dbSerialPrintln("setup done");

void loop(void)

(I added my HMI File in the attachment)

I’m pretty sure that this is a pretty stupid mistake that I’m doing. But I’m just very frustrated after hours and days of troubleshooting.

I also tried a simple Sketch with a normal button. So if you press the button it turns on (without a Dualstate) without success…

I hope somebody can help me.

Thank you very much and have a nice weekend.


Forgot to add:
Arduino UNO
Nextion NX3224T024 Display 2.4 (1.23 MB)](Nextion LCD communicate with Arduino UNO - Arduino Project Hub)

Hello John / Joshua,


Support for Nextion on these fora is pretty much as follows:
You can follow the methods I set out in using Nextion displays with Arduino. My methods do not use the Nextion libraries, so while I am happy to offer help on using my methods I cannot offer anything very helpful for any Nextion library.
The original Nextion libraries are full of bugs. There is a link from my tutorial to some improved Nextion libraries created by Ray Livingston, I suggest those might be worth trying if you prefer to use a library.
There's also Seithan who has also developed his own ways of dealing with Nextion displays, you can find his methods in his tutorial on how to write code with Nextion and Arduino.
Beyond that the odd person occasionally offers a bit of help but not much.