Variable in CAYENNE_IN / OUT function not available outside of function

#1

Hi, I have faced some issue with obtaining the variable from CAYENNE_IN / OUT function from different channel. Eg, I want to obtain variable from CAYENNE_IN(V1) and use it in CAYENNE_IN(V2), but (V2) did not receive the value.
Your help is very much appreciated.

#2

I was wondering how his code was able to pass the variable from CAYENNE() function to CAYENNE() function.

#3

V1 V2 V3 V4 … are all MQTT channels and not variables that store data. in CAYENNE_IN(V1) V1 is the channel number 1 to receive data from cayenne while CAYENNE_IN(V2) is the channel number 2 to send data to cayenne.

#4

Sorry, what i meant was if i have a variable eg. Int voltage from .getValue in channel V1, the variable will not be known in channel V2 if i use the same variable voltage again.
Eg:
Channel(V1)
Int voltage=5

Channel(V2)
voltage = 0 (cannot get back 5) from channel V1

#5

you need to declare voltage globally

#6

what is this doing here?

#7

Ok I have noticed that I have missed out the global variable. Thank you for your quick response and assistance, very much appreciated.

1 Like