Trouble obtaining Values from nextion

Good day All,

Hopefully this is the right place to get a solution to all my answers. Currently I have a setup running an Arduino BME 280 sensor and a 4.3" Nextion screen. What my program does is sent all the calculated values from the BME to numbers and progress bars in my Nextion on a screen called "Run". This page consists of 3 values: Delta T, Temperature and Humidity as well as 3 buttons for an alarm. Each of these displayed values is connected to their own progress bar. Each of the individual values has a lower and upper alarm setting which can be adjusted on a following Nextion screen called "Settings".

So basically what I am struggling with is obtaining the obtaining the values from my "settings" screen to write the "if" function in my arduino i.e (if the button is enabled on the run page and the value is less than X on the "Settings" page or more than Y on the "Settings" page, sound the alarm). I have used the .getValue function, but it does not return a value to my Arduino program. Can anyone please assist. It will be highly appreciated.

// Include required libraries
#include <NexTouch.h>
#include <NexDualStateButton.h>
#include <NexNumber.h>
#include <NexProgressBar.h>
#include <NexText.h>
#include <Nextion.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

//Define BME parameters
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C

//Define variables
int Delta_T;
int Temp_disp;
float Temp_wb;
float Temp;
int rh;

//Define NEXTION variables
  //Transport Page
    NexNumber Trans_deltaT = NexNumber(2, 10, "n0");
    NexNumber Trans_T = NexNumber(2, 11, "n1");
    NexNumber Trans_H = NexNumber(2, 12, "n2");
  //Run Page
    NexNumber Run_deltaT = NexNumber(3, 14, "n0");
    NexNumber Run_T = NexNumber(3, 15, "n1");
    NexNumber Run_H = NexNumber(3, 16, "n2");
    NexDSButton Delta_Temp= NexDSButton(3,12,"bt0");
    NexDSButton Temperature= NexDSButton(3,22,"bt1");
    NexDSButton Hum= NexDSButton(3,13,"bt2");

  //Settings Page
    NexNumber DT_min= NexNumber(4,5,"n6");
    NexNumber DT_max= NexNumber(4,12,"n3");
    NexNumber T_min= NexNumber(4,6,"n7");
    NexNumber T_max= NexNumber(4,14,"n4");
    NexNumber Hum_min= NexNumber(4,7,"n8");
    NexNumber Hum_max= NexNumber(4,16,"n5");

NexTouch *nex_listen_list[]=
//  &DT_min,
//  &DT_max,
//  &T_min,
//  &T_max,
//  &Hum_min,
//  &Hum_max

void Delta_TempPopCallback(void*ptr)
  uint32_t DT = 0;        // Button State 
  uint32_t DT_act=0;
  uint32_t DelT_min=0;    //Define DT_min setting
  uint32_t DelT_max=0;    //Define DT_max setting
    // Read value of dual state button to know the state (0 or 1)

  if(DT== 0 && DT_act<DelT_min || DT_act>DelT_max ){  // If dual state button is equal to 1 (meaning is ON)...
    digitalWrite(2, HIGH);  // Turn ON internal LED
  }else{  // Since the dual state button is OFF...
    digitalWrite(2, LOW);  // Turn OFF internal LED

void setup() {


void loop(){
//    Serial.print("Temperature = ");
//    Serial.print(Temp);
//    Serial.println(" *C");

//    Serial.print("Humidity = ");
//    Serial.print(rh);
//    Serial.println(" %");
//    Serial.print("Wet Bulb Temp= "); 
//    Serial.print(Temp_wb);
//    Serial.println(" *C");

//    Serial.print("Delta T=");
//    Serial.print(Delta_T);
//    Serial.println(" *C");
//    Serial.println();   





Run page.PNG

Settings Page.PNG

Run page.PNG

Settings Page.PNG

Try to change the 'vscope' property of fields n3 to n8 to global.

Ciao, Ale.

All the variables are already set to global? Is there no other fault in my code?

have you triple checked that, the IDs in


are correct ?

normally, the setting page needs to be the current page on your screen for values to update on Arduino side

Yes I have checked those settings numerous times. Even with changing the values on the settings page the alarm function still does not work ie. I deliberately make the values on the run page go into the alarm range.

It seems as if there is no more advice to be given?

It seems as if there is no more advice to be given?

Hello lh_agri-tech,
I have been following this but not commenting as you are using the Nextion libraries and I know nothing about them, plus you seemed to be getting the help you needed.

If you stuck try 'using Nextion displays with Arduino' at the top of the Displays section of the forum. However, be aware that my methods are different to what you are used to with Nextion libraries and you will have to understand how my methods work to use them.

Thanks PerryBebbington,
If I do not solve the problem I will try your methods. I hve read through your post, however it would seem that, by using your methods, I would uave to start the whole project from scratch. This is something I am still trying to avoid

Yes, you will have to change your project a lot to use my methods, it will work though..

Don't fall for the sunk cost fallacy