Is CAYNEE_OUT(parameter){} a function?


#1

I have not seen this type of coding on arduino. I am a bit confused, it looks like a function, it is never called in the sketch, what is this and how it works?


#2

Hi @dpiralis,

CAYENNE_OUT functions are called automatically from the Cayenne.run() statement in the loop() section of your code. They generally poll a sensor device for data to send to the server via a virtual pin. Here is an example from our TMP36 temperature sensor sketch: https://github.com/myDevicesIoT/CayenneArduinoSamples/blob/master/Sensors/TMP36/TMP36.ino

In this case, VIRTUAL_PIN is defined as pin V1 and any widget pointed to V1 will begin to populated with temperature data from that sensor. Notice that it was not necessary to explicitly call the CAYENNE_OUT function anywhere.