DanNixon / NeoNextion

Arduino library for the Nextion displays
https://dannixon.github.io/NeoNextion
GNU General Public License v2.0
48 stars 34 forks source link

GetValue strange behavior #40

Open llist opened 6 years ago

llist commented 6 years ago

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 commented 6 years ago

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

Snake675 commented 4 years ago

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

vandijkict commented 4 years ago

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

llist commented 4 years ago

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

vandijkict commented 4 years ago

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

llist commented 4 years ago

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