NeoNextion icon indicating copy to clipboard operation
NeoNextion copied to clipboard

GetValue strange behavior

Open llist opened this issue 7 years ago • 6 comments

Hi,

I have a Numeric Variable I can SET the variable but when i read the Value the result is 0 ?? Same for a Slider , I can change color and value but when I use slider.getValue() the result is 0 !!

Every setValue => OK Every getValue => not OK return value are 0 An Idea ?

Arduino Mega 2560 and screen Nextion NX4832K035_011 or NX4832T035_011

llist avatar Jan 27 '18 20:01 llist

this is the solution

For UNO #define UNO_RXPIN 10 #define UNO_TXPIN 11 SoftwareSerial nextionSerial(UNO_RXPIN, UNO_TXPIN); // RX, TX

For MEGA #define MEGA_RX_PIN 53 #define MEGA_TX_PIN 51

SoftwareSerial nextionSerial(MEGA_RX_PIN, MEGA_TX_PIN); // RX, TX

llist avatar Jan 28 '18 11:01 llist

Hi This solution does not work for me. Still getting zeros all the time on any "getValue()".

Snake675 avatar Nov 24 '19 10:11 Snake675

I have the same problem, my result for getValue() is always 0 The same problem with dual state buttons or radiobuttons

vandijkict avatar Feb 18 '20 20:02 vandijkict

Hi, If you can change the value that means your TX_PIN is the good one . GetValue = Rx_PIN = read pin if you cannot read there are 2 assumptions : Case 1 : For RX_PIN choose the good PIN number in your Arduino board ( See First post ) Case 2: under your screen through Nextion Editor change/verify if your variable attribut was set to : VSCOPE = global. Reason : ex: Screen 1 contains the Variable1 : you can read it only if screen1 is in front ( displayed) If you are set this variable in global mode you can read even if the screen is not displayed.

Hoping that can help you

llist avatar Feb 19 '20 03:02 llist

There is nothing wrong with communication, because I can read the callback events and read and change textboxes

vandijkict avatar Feb 19 '20 08:02 vandijkict

Hi Another possibility.

Into your source code add the screen name into the variable declaration: see ECRANS.onoff_pompBois

//---------------------------------------- #define ECRAN_1 1 ..... Nextion nex(nextionSerial); NextionPage ecran1(nex, ECRAN_1, 0, "ECRANS");

NextionVariableNumeric MyVar(nex, ECRAN_1, 6, "ECRANS.onoff_pompBois");

try this

Good luck

llist avatar Feb 20 '20 18:02 llist