GetNumber Timeout

Hardware: Arduino Mega Nextion NX4024T032_011 display.

I'm having great difficulty making a code work in one subroutine that works fine in another. I'm trying to use the .getvalue() function of a number box in nextion in arduino. In one, it works perfectly. In another I get an error message which reads "getNumber timeout"

I have been searching here and on the internet for over a week. I can't find any information regarding a getnumber timeout.

The project is a system to contol my pool pump & filter. It will not only schedule the times the pump is on, but inject chlorine, run when pool surface gets above 100 degrees F, shut the system down if pump does not prime within 2 minutes and shut the system off if the pressue rises above 30psi. I don't think anyone wants me to post over 600 lines of code.

The following is the part that works. It simply puts values into the eeprom in case of a power failure. byte1 is a global variable declared as uint32_T. hrs1on/mins1on thru hrs4on/mins4on are number boxes on the nextion display and declared properly in the beginning of the program. I have verified them numerous times.

void btnPumpSchApplyPopCallback(void* ptr) {// Apply button on Pump Schedule page of nextion

//Check boxes to activate/deactivate running a schedule
    chk1.getValue(&byte1);
    if (byte1 == 1) {
        EEPROM.write(29, 1);
        chk1.setValue(1);
    }
    else if (byte1 == 0) {
        EEPROM.write(29, 0);
        chk1.setValue(0);
    }
    chk2.getValue(&byte1);
    if (byte1 == 1) {
        EEPROM.write(30, 1);
        chk2.setValue(1);
    }
    else if (byte1 == 0) {
        EEPROM.write(30, 0);
        chk2.setValue(0);
    }
    chk3.getValue(&byte1);
    if (byte1 == 1) {
        EEPROM.write(31, 1);
        chk3.setValue(1);
    }
    else if (byte1 == 0) {
        EEPROM.write(31, 0);
        chk3.setValue(0);
    }
    chk4.getValue(&byte1);
    if (byte1 == 1) {
        EEPROM.write(32, 1);
        chk4.setValue(1);
    }
    else if (byte1 == 0) {
        EEPROM.write(32, 0);
        chk4.setValue(0);
    }
//Period 1
    hrs1on.getValue(&byte1);
    EEPROM.write(0, byte1);
    mins1on.getValue(&byte1);
    EEPROM.write(1, byte1);
    hrs1off.getValue(&byte1);
    EEPROM.write(2, byte1);
    mins1off.getValue(&byte1);
    EEPROM.write(3, byte1);
//Period 2

    hrs2on.getValue(&byte1);
    EEPROM.write(4, byte1);
    mins2on.getValue(&byte1);
    EEPROM.write(5, byte1);
    hrs2off.getValue(&byte1);
    EEPROM.write(6, byte1);
    mins2off.getValue(&byte1);
    EEPROM.write(7, byte1);
//period 3

    hrs3on.getValue(&byte1);
    EEPROM.write(8, byte1);
    mins3on.getValue(&byte1);
    EEPROM.write(9, byte1);
    hrs3off.getValue(&byte1);
    EEPROM.write(10, byte1);
    mins3off.getValue(&byte1);
    EEPROM.write(11, byte1);
//period 4

    hrs4on.getValue(&byte1);
    EEPROM.write(12, byte1);
    mins4on.getValue(&byte1);
    EEPROM.write(13, byte1);
    hrs4off.getValue(&byte1);
    EEPROM.write(14, byte1);
    mins4off.getValue(&byte1);
    EEPROM.write(15, byte1);
    Eprint();
}

However, this short subroutine does not work and uses the same format as the above code.

void SetTime() {
    uint32_t HrSet, MinSet;
    Serial.println("Set Time Executed");
    StrN1.getValue(&HrSet);
    StrN2.getValue(&MinSet);
    rtc.adjust(DateTime(2020, 2, 22, HrSet, MinSet, 55));
    Serial.println(HrSet);
    Serial.println(MinSet);
}

The error code I get when the above routine is called is: Set Time Executed getNumber timeout getNumber timeout 3642860816 66018

Can someone please help me with this?

without seeing the entire sketch, only you know.

It seems very odd that there is a variable named StrN1 (or StrN2) but you are expecting a uint32_t value. At first glance, I would think those are text boxes that return strings.

But again, only you know since only you can see the entire sketch.

blh64: without seeing the entire sketch, only you know.

It seems very odd that there is a variable named StrN1 (or StrN2) but you are expecting a uint32_t value. At first glance, I would think those are text boxes that return strings.

But again, only you know since only you can see the entire sketch.

StrN1 & StrN2 are number boxes on the Nextion screen. This forum will not let me post the 700 lines of code. It said I had over 9000 characters.

Then post it as an attachment. Take some time to read the sticky post at the top of the forum about how to effectively use this forum to get the most out of it.

Here is the attachment.

PoolFilterSystem.ino (18.6 KB)

A couple of things

. just #include <nextion.h> and it will include all the other header files for you - cleaner code

. your objects must all have unique names but that is not true for your code. There are 2 named “n1” and 2 named “btnPumpOn”

. this code

void btnTestPopCallback(void* ptr) {
	char myData;
	tstText1.getText(&myData, 2);
	Serial.println();
	Serial.println(myData);
	Serial.println();
}

creates 1 byte for myData but you lie and tell getText() there is room for 2 bytes. It should be an array

void btnTestPopCallback(void* ptr) {
	char myData[10];
	tstText1.getText(myData, sizeof(myData));
	Serial.println();
	Serial.println(myData);
	Serial.println();
}

. it is very confusing to have variables named byte1 and byte2, yet they are of type uint32_t (4 bytes).

Not sure if any of this is the root of your problem. You way want to pare it down a bit to isolate the problem.

A million thank you’s blh64! I am eternally grateful.

I have been struggling for weeks with getText. Your code worked perfectly. I did not realize an array needed to be used. getValue works much differently and I was trying to do it the same way. Neither did I know there was a sizeof keyword.

. just #include <nextion.h> and it will include all the other header files for you - cleaner code

I originally had just nextion.h, but when I started getting trouble I put it back the way the library installed itself. If you haven’t already guessed, I’m still a bit new at this and nowhere near the level of many of you on the Arduino site. Sometimes I just need to see how it’s done and expand from there.

your objects must all have unique names but that is not true for your code. There are 2 named “n1” and 2 named “btnPumpOn”

. this code

I didn’t realize I had duplicate names. Thank you for spotting them.

. it is very confusing to have variables named byte1 and byte2, yet they are of type uint32_t (4 bytes).

byte1 & 2 have been changing data types throughout this project. As I finish up this project, they will get proper names.

Again, thank for looking at this. I’m sure you spent quite a bit of time decifering it.

Study some/all of the nextion examples that came with the library. Much of what I gleaned was from those examples.

blh64, I’m sorryI need some help again. The gettext with the char array works well.

I cannot get this if statement to work. The array my data returns “SetTime”, but the if statement will not trip. I can’t believe I can’t get a simple if statement to work. :o Can you see anything I’m missing?

void btnKpEnterPopCallback(void* ptr) {
 
 Serial.println();
 Serial.println("Keypad Enter Key Pressed");//lets me know popcallback tripped

 char myData[10];

 vaFunc.getText(myData, sizeof(myData));

 if (myData=="SetTime"){
 Serial.println("If statement captured");
 SetTime();
 Serial.print("vaFunction on keypad=");
 Serial.println(myData);//Verifies correct data was retrieved from vaFunc
     }
 
}

This is C/C++ and '==' is not how you compare c-strings. You must use the strcmp() function

Many thanks again.