Hello everyone,
I’m new to the cayenne world and I’m using it in my project to get a signal from a switch then open or close a valve. Can you please help me.
I want to know more about the cayenne programming language ( the code ) such as the meaning of cayenne Out, Cayyene In, the vertual channel, so I become more confident while writing the code.
I used to write the code in Arduino first then if it workes I try to write it in Cayyene. I tried to search in google to know more about the language but I did not get a results that can help me. ( I’m using Arduino Ano)
Welcome to the cayenne community @jwmalbreiki
if you want to learn how the library work then it is quite hard. here are all the code file which cayenne developer have build so that the cayenne users can have ease at doing IOT project. Cayenne-MQTT-Arduino/src at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub
In short, what you need to know is:
CAYENNE_OUT()
----> this function is used to send data from your Arduino to cayenne.
CAYENNE_IN()
----> this function is used to receive data from cayenne to your Arduino.
virtual_channel
—> this are channel or path number used to communicate between your arduino and cayenne.
example:
CAYENNE_OUT(2) // this function sends data to cayenne on channel 2
{
Cayenne.virtualWrite(2, x, "temp", "c"); // this line is used to send data `x` on channel `2` with type value = `temp` and unit type = `c`
}
You can read more about virtualWrite and data types here Data types for Cayenne MQTT API
CAYENNE_IN(6) // this function is called whenever we get value from dashboard
{
int x = getValue.asInt(); stores the value received from the cayenne into `x`
}