Nextion Intelligent Display, Tracker SoM and CompButton

I could use a little help.

I have a project using a Particle Tracker and an HMI using a Nextion 7" Int. Display.

Most parts are working fine. I am using 0.0.18 of the included ITEADLIB libraries that were ported by ScruffR. I can send data to the display all day long and I have checked the continuity of the cables multiple times and RX <> TX. However, I cannot seem to get a button callback to work to save my life.

Some pertinent areas of code that might help:

From global section:

#include "Nextion.h"

USARTSerial& nexSerial = Serial1;

#include "Adafruit_ADS1X15.h"

Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */

// Setup Nextion Objects

void test_callback(void *ptr);

NexText t_pre = NexText(1, 1, "pre");
NexText t_rc = NexText(1, 5, "run");
NexText nx_mode = NexText(1, 6, "gmMode");
NexText t_aJ = NexText(1, 16, "aJ");
NexText t_r0 = NexText(3,1,"r0");
NexText t_r1 = NexText(3,1,"r1");
NexText t_r2 = NexText(3,1,"r2");
NexText t_r3 = NexText(3,1,"r3");
NexText t_r4 = NexText(3,1,"r4");
NexText t_r5 = NexText(3,1,"r5");
NexText nx_date = NexText(1,25,"date");
NexText nx_time = NexText(1,26,"time");
NexText nx_run = NexText(1,26,"run");

NexButton nx_test = NexButton(1,27,"test");
//Setup Nextion Interupts for all possible touch events

NexTouch *nex_listen_list[] = 

The Callback function:

void test_callback(void *ptr){

   NexButton *btn = (NexButton *)ptr;

    nx_test.setText("Starting Test");


    Serial.println("<* FUNCTION TEST BUTTON PUSHED *>");


From Setup();



    nx_test.attachPop(test_callback, &nx_test);


Above, I have tried both nx_test.attachPOP and nx_test.attachPUSH. Neither has worked for me.

and I have the “nexLoop(nex_listen_list);” set up in loop();

I have tried to trigger a setText() function from the callback and I have resorted to just trying to get the program to Serial.Print(“TEST BUTTON”); whenever the button is pressed.

I have even tried to just Serial1.Read() and print whatever comes from the UART, but I get nothing. However, the display definitely updates when I send values from the program to the display via the objects.

Any help would be appreciated as always!

I do not have the editor in front of me but when you put the button on the screen did you check the box to send id (or something like that)?

1 Like

I am having someone else design the screens for me. This is a big project and we are dividing and conquering. I noticed this checkbox from another forum entry and I have enquired. I will hopefully get back to you with that answer sometime this weekend.


That has bit me several times when I have forgot to check that box.

Thanks, after talking with the screen designer over the weekend, this was exactly the problem.

Thanks for the quick response!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.