Nextion Display Code Not Working!!!

Hello!
I have a Nextion display from itead studios. I have made a simple program from the Nextion Editor, and uploaded it to the Nextion display using an SD card. (It works) The Nextion program is simply a screen with a few different buttons on it. I have written some corresponding Arduino code to go with the Nextion program, using the Nextion library.

However, my code is not working! The Serial Monitor shows "Setup Done" successfully, but when I press the buttons on the display, there is no message in the Serial Monitor! What did I do wrong?

Any help would be super! :slight_smile: :slight_smile: :slight_smile:
-SQ

#include <doxygen.h>
#include <NexButton.h>
#include <NexCheckbox.h>
#include <NexConfig.h>
#include <NexCrop.h>
#include <NexDualStateButton.h>
#include <NexGauge.h>
#include <NexGpio.h>
#include <NexHardware.h>
#include <NexHotspot.h>
#include <NexNumber.h>
#include <NexObject.h>
#include <NexPage.h>
#include <NexPicture.h>
#include <NexProgressBar.h>
#include <NexRadio.h>
#include <NexRtc.h>
#include <NexScrolltext.h>
#include <NexSlider.h>
#include <NexText.h>
#include <NexTimer.h>
#include <Nextion.h>
#include <NexTouch.h>
#include <NexUpload.h>
#include <NexVariable.h>
#include <NexWaveform.h>

NexButton buttonPhone = NexButton(0, 1, "buttonPhone");
NexButton buttonRadio = NexButton(0, 2, "buttonRadio");
NexButton buttonMessages = NexButton(0, 3, "buttonMessages");
NexButton buttonSettings = NexButton(0, 4, "buttonSettings");

NexTouch *nex_listen_list[] =
{
  &buttonPhone,
  &buttonRadio,
  &buttonMessages,
  &buttonSettings,
  NULL
};

void buttonPhonePopCallback(void *ptr) {
  dbSerialPrintln("buttonPhonePopCallback");
}
void buttonRadioPopCallback(void *ptr) {
  dbSerialPrintln("buttonRadioPopCallback");

}
void buttonMessagesPopCallback(void *ptr) {
  dbSerialPrintln("buttonMessagesPopCallback");
}
void buttonSettingsPopCallback(void *ptr) {
  dbSerialPrintln("buttonSettingsPopCallback");
}

void setup() {
nexInit();
Serial.begin(115200);
nexSerial.begin(9600);
buttonPhone.attachPop(buttonPhonePopCallback);
buttonRadio.attachPop(buttonRadioPopCallback);
buttonMessages.attachPop(buttonMessagesPopCallback);
buttonSettings.attachPop(buttonSettingsPopCallback);
dbSerialPrintln("Setup Done");

}

void loop() {
nexLoop(nex_listen_list);
}
#include <doxygen.h>

Why does your code need this header file?

NexButton buttonPhone = NexButton(0, 1, "buttonPhone");
NexButton buttonRadio = NexButton(0, 2, "buttonRadio");
NexButton buttonMessages = NexButton(0, 3, "buttonMessages");
NexButton buttonSettings = NexButton(0, 4, "buttonSettings");

Magic numbers suck.

  dbSerialPrintln("buttonSettingsPopCallback");

Which one of those 14 bazillion include files contains this function?

Nevermind!
My connections were wrong!

ALWAYS BE SURE TO CHECK YOUR CONNECTIONS, EVEN IF THE DISPLAY TURNS ON. THANKS!

#include "Nextion.h" // is the only library you need to include. All other libraries are within Nextion.h

baud=115200 will need setting on your Nextion editor.

  1. go to page0- click on page for attributes
  2. go to User input panel (Tab) Send command)
  3. input-- baud=115200
  4. upload to Nextion display
    The default for Nextion display is 9600 changing the baud to 115200 will reset the default.

You need to include button state--- char buffer[100] ={0}

I have attached example i am working on if i could get some input on this would be great

testino1.txt (630 Bytes)