#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h>
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “xxx”;
char password = “xxx”;
char clientID = “xxx”;
#define VIRTUAL_CHANNEL_1 1
#define ACTUATOR_PIN_1 22 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL_2 2
#define ACTUATOR_PIN_2 24 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL_3 3
#define ACTUATOR_PIN_3 26 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL_4 4
#define ACTUATOR_PIN_4 28 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL_5 5
#define ACTUATOR_PIN_5 30 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL_6 6
#define ACTUATOR_PIN_6 32 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL_7 7
#define ACTUATOR_PIN_7 34 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL_8 8
#define ACTUATOR_PIN_8 36 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
void setup()
{
Serial.begin(9600);
pinMode(ACTUATOR_PIN_1, OUTPUT);
pinMode(ACTUATOR_PIN_2, OUTPUT);
pinMode(ACTUATOR_PIN_3, OUTPUT);
pinMode(ACTUATOR_PIN_4, OUTPUT);
pinMode(ACTUATOR_PIN_5, OUTPUT);
pinMode(ACTUATOR_PIN_6, OUTPUT);
pinMode(ACTUATOR_PIN_7, OUTPUT);
pinMode(ACTUATOR_PIN_8, OUTPUT);
Cayenne.begin(username, password, clientID);
}
void loop()
{
Cayenne.loop();
}
// This function is called when data is sent from Cayenne.
CAYENNE_IN(VIRTUAL_CHANNEL_1)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(ACTUATOR_PIN_1, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN_1, LOW);
}
}
CAYENNE_IN(VIRTUAL_CHANNEL_2)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(ACTUATOR_PIN_2, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN_2, LOW);
}
}
CAYENNE_IN(VIRTUAL_CHANNEL_3)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(ACTUATOR_PIN_3, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN_3, LOW);
}
}
CAYENNE_IN(VIRTUAL_CHANNEL_4)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(ACTUATOR_PIN_4, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN_4, LOW);
}
}
CAYENNE_IN(VIRTUAL_CHANNEL_5)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(ACTUATOR_PIN_5, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN_5, LOW);
}
}
CAYENNE_IN(VIRTUAL_CHANNEL_6)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(ACTUATOR_PIN_6, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN_6, LOW);
}
}
CAYENNE_IN(VIRTUAL_CHANNEL_7)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(ACTUATOR_PIN_7, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN_7, LOW);
}
}
CAYENNE_IN(VIRTUAL_CHANNEL_8)
{
// Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
if (getValue.asInt() == 0) {
digitalWrite(ACTUATOR_PIN_8, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN_8, LOW);
}
}