Variable in CAYENNE_IN / OUT function not available outside of function

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.

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

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.

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

you need to declare voltage globally

what is this doing here?

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