Nextion Display and Arduino

Hi everyone

I have been playing with Arduino for about a year now and understand a fair bit.

Recently I picked up a Nextion touch screen, as I thought this would be great for 2 way communication to and from an Arduino.

Its been a bit of a learning curve, and is definitely not the easiest item to get working well with an Arduino, however after watching a few YouTube tutorials, I managed to get my head around some of the code.

So I made a simple 2 state button on the display, when i press the button on the Nextion screen the LED on pin 13 of the arduino lights up, when I press it again the LED goes off great, I also print a message to the the screen

So moving on from that, if then start to add extra items into the code for a temp sensor, rtc then I run into difficulties.

If you check the code below, eveything works as I stated, however if I un-comment these items at void setup,

//bme280.init();
//clock.begin(); /
/clock.setDateTime(2018, 7, 26, 8, 59, 55);

all hell breaks loose and the LED no longer comes on or no message when I press the Nextion touch screen.

Any ideas greatfully appreciated as I cant figure it out.

Cheers Alan

#include <Nextion.h> 
#include <DS3231.h>                   // Real Time Clock
#include <Seeed_BME280.h>             // H/T/P/ Sensor

BME280 bme280;
DS3231 clock;

int variable1 = 0;  // Create a variable to have a counter going up by one on each cycle
int counter = 0;  // Create a variable to have a counter for the + and - buttons

NexDSButton bt0 = NexDSButton(0, 7, "bt0");  // Dual state button added
NexText t0 = NexText(0, 2, "t0");  
NexText t1 = NexText(0, 3, "t1");  
NexText t2 = NexText(0, 6, "t2"); 
NexText t3 = NexText(0, 7, "t3");  


// End of declaring objects

NexTouch *nex_listen_list[] = 
{

  &bt0,  // Dual state button added
  
  NULL  // String terminated
};  // End of touch event list


void bt0PopCallback(void *ptr)  
{
  uint32_t number5 = 0;  
  bt0.getValue(&number5);  

  if(number5 == 1){  
    digitalWrite(13, HIGH);  

    Serial.print("t0.txt=");  
    Serial.print("\"");  
    Serial.print("Hooray!");  
    Serial.print("\"");  
    Serial.write(0xff);  
    Serial.write(0xff);
    Serial.write(0xff);
  }else{  
    digitalWrite(13, LOW);  

    Serial.print("t0.txt=");  
    Serial.print("\"");  
    Serial.print("It Works!");  
    Serial.print("\"");  
    Serial.write(0xff);  
    Serial.write(0xff);
    Serial.write(0xff);
  }
}  // End of release event

void setup() {  // Put your setup code here, to run once:
  
  Serial.begin(9600);  // Start serial comunication at baud=9600

  delay(500);  // This dalay is just in case the nextion display didn't start yet, to be sure it will receive the following command.
  Serial.print("baud=115200");  
  Serial.write(0xff);  
  Serial.write(0xff);
  Serial.write(0xff);

  Serial.end();  // End the serial comunication of baud=9600

  Serial.begin(115200);  // Start serial comunication at baud=115200
  
  bt0.attachPop(bt0PopCallback);  // Dual state button bt0 release
  
 
  pinMode(13, OUTPUT);

  //bme280.init();
  //clock.begin();
  //clock.setDateTime(2018, 7, 26, 8, 59, 55);

}  // End of setup


void loop() {  // Put your main code here, to run repeatedly:


  delay(30);  


  nexLoop(nex_listen_list);  // Check for any touch event


}  // End of loop
#include <Nextion.h>

Which pins does this device actually use?

#include <DS3231.h>                   // Real Time Clock

Same question.

#include <Seeed_BME280.h>             // H/T/P/ Sensor

Ditto.