Raspberry & arduino Due by serial


#1

after the update I’m getting crazy, the inputs do not work and only some outputs.
the arduino is connected but something is wrong, and correct the program?

#include <CayenneMQTTSerial.h>

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";
//************* Action pins Out 1°piano rele N.O.************************
#define VIRTUAL_CHANNEL22 22  
#define VIRTUAL_CHANNEL24 24
#define VIRTUAL_CHANNEL26 26
#define VIRTUAL_CHANNEL28 28
#define VIRTUAL_CHANNEL30 30
#define VIRTUAL_CHANNEL32 32
#define VIRTUAL_CHANNEL34 34
#define VIRTUAL_CHANNEL36 36
#define VIRTUAL_CHANNEL38 38
#define VIRTUAL_CHANNEL40 40
#define VIRTUAL_CHANNEL42 42
#define VIRTUAL_CHANNEL44 44
#define VIRTUAL_CHANNEL46 46
#define VIRTUAL_CHANNEL48 48
#define VIRTUAL_CHANNEL50 50
#define VIRTUAL_CHANNEL52 52

 
#define ACTUATOR_PIN22 22  
#define ACTUATOR_PIN24 24
#define ACTUATOR_PIN26 26
#define ACTUATOR_PIN28 28
#define ACTUATOR_PIN30 30
#define ACTUATOR_PIN32 32
#define ACTUATOR_PIN34 34
#define ACTUATOR_PIN36 36
#define ACTUATOR_PIN38 38
#define ACTUATOR_PIN40 40
#define ACTUATOR_PIN42 42
#define ACTUATOR_PIN44 44
#define ACTUATOR_PIN46 46
#define ACTUATOR_PIN48 48
#define ACTUATOR_PIN50 50
#define ACTUATOR_PIN52 52

//*************Action pins Input gnd  2°piano************************************

      
#define VIRTUAL_CHANNEL2 2
#define VIRTUAL_CHANNEL3 3
#define VIRTUAL_CHANNEL4 4
#define VIRTUAL_CHANNEL5 5
#define VIRTUAL_CHANNEL6 6
#define VIRTUAL_CHANNEL7 7
#define VIRTUAL_CHANNEL8 8
#define VIRTUAL_CHANNEL9 9
#define VIRTUAL_CHANNEL10 10
#define VIRTUAL_CHANNEL11 11
#define VIRTUAL_CHANNEL12 12
#define VIRTUAL_CHANNEL13 13
#define VIRTUAL_CHANNEL14 14
#define VIRTUAL_CHANNEL15 15
#define VIRTUAL_CHANNEL16 16
#define VIRTUAL_CHANNEL17 17

#define SENSOR_PIN2 2
#define SENSOR_PIN3 3
#define SENSOR_PIN4 4
#define SENSOR_PIN5 5
#define SENSOR_PIN6 6
#define SENSOR_PIN7 7
#define SENSOR_PIN8 8
#define SENSOR_PIN9 9
#define SENSOR_PIN10 10
#define SENSOR_PIN11 11
#define SENSOR_PIN12 12
#define SENSOR_PIN13 13
#define SENSOR_PIN14 14
#define SENSOR_PIN15 15
#define SENSOR_PIN16 16
#define SENSOR_PIN17 17

//*************Action pins Input +  2°piano************************************
#define VIRTUAL_CHANNEL23 23
#define VIRTUAL_CHANNEL25 25
#define VIRTUAL_CHANNEL27 27
#define VIRTUAL_CHANNEL29 29
#define VIRTUAL_CHANNEL31 31
#define VIRTUAL_CHANNEL33 33
#define VIRTUAL_CHANNEL35 35
#define VIRTUAL_CHANNEL37 37
#define VIRTUAL_CHANNEL39 39
#define VIRTUAL_CHANNEL41 41
#define VIRTUAL_CHANNEL43 43
#define VIRTUAL_CHANNEL45 45
#define VIRTUAL_CHANNEL47 47 
#define VIRTUAL_CHANNEL49 49
#define VIRTUAL_CHANNEL51 51
#define VIRTUAL_CHANNEL53 53

#define SENSOR_PIN23 23
#define SENSOR_PIN25 25
#define SENSOR_PIN27 27
#define SENSOR_PIN29 29
#define SENSOR_PIN31 31
#define SENSOR_PIN33 33
#define SENSOR_PIN35 35
#define SENSOR_PIN37 37
#define SENSOR_PIN39 39
#define SENSOR_PIN41 41
#define SENSOR_PIN43 43
#define SENSOR_PIN45 45
#define SENSOR_PIN47 47 
#define SENSOR_PIN49 49
#define SENSOR_PIN51 51
#define SENSOR_PIN53 53

void setup()
{
  //Serial.begin(9600);
  //Baud rate can be specified by calling Cayenne.begin(username, password, clientID, 9600);
  Cayenne.begin(username, password, clientID);
  

pinMode (ACTUATOR_PIN22, OUTPUT);
pinMode (ACTUATOR_PIN24, OUTPUT);
pinMode (ACTUATOR_PIN26, OUTPUT);
pinMode (ACTUATOR_PIN28, OUTPUT);
pinMode (ACTUATOR_PIN30, OUTPUT);
pinMode (ACTUATOR_PIN32, OUTPUT);
pinMode (ACTUATOR_PIN34, OUTPUT);
pinMode (ACTUATOR_PIN36, OUTPUT);
pinMode (ACTUATOR_PIN38, OUTPUT);
pinMode (ACTUATOR_PIN40, OUTPUT);
pinMode (ACTUATOR_PIN42, OUTPUT);
pinMode (ACTUATOR_PIN44, OUTPUT);
pinMode (ACTUATOR_PIN46, OUTPUT);
pinMode (ACTUATOR_PIN48, OUTPUT);
pinMode (ACTUATOR_PIN50, OUTPUT);
pinMode (ACTUATOR_PIN52, OUTPUT);

pinMode (SENSOR_PIN2 , INPUT_PULLUP);
pinMode (SENSOR_PIN3 , INPUT_PULLUP);
pinMode (SENSOR_PIN4 , INPUT_PULLUP);
pinMode (SENSOR_PIN5 , INPUT_PULLUP);
pinMode (SENSOR_PIN6 , INPUT_PULLUP);
pinMode (SENSOR_PIN7 , INPUT_PULLUP);
pinMode (SENSOR_PIN8 , INPUT_PULLUP);
pinMode (SENSOR_PIN9 , INPUT_PULLUP);
pinMode (SENSOR_PIN10 , INPUT_PULLUP);
pinMode (SENSOR_PIN11 , INPUT_PULLUP);
pinMode (SENSOR_PIN12 , INPUT_PULLUP);
pinMode (SENSOR_PIN13 , INPUT_PULLUP);
pinMode (SENSOR_PIN14 , INPUT_PULLUP);
pinMode (SENSOR_PIN15 , INPUT_PULLUP);
pinMode (SENSOR_PIN16 , INPUT_PULLUP);
pinMode (SENSOR_PIN17 , INPUT_PULLUP);

pinMode (SENSOR_PIN23, INPUT);
pinMode (SENSOR_PIN25, INPUT_PULLUP);
pinMode (SENSOR_PIN27, INPUT);
pinMode (SENSOR_PIN29, INPUT);
pinMode (SENSOR_PIN31, INPUT);
pinMode (SENSOR_PIN33, INPUT);
pinMode (SENSOR_PIN35, INPUT);
pinMode (SENSOR_PIN37, INPUT);
pinMode (SENSOR_PIN39, INPUT);
pinMode (SENSOR_PIN41, INPUT);
pinMode (SENSOR_PIN43, INPUT);
pinMode (SENSOR_PIN45, INPUT);
pinMode (SENSOR_PIN47, INPUT);
pinMode (SENSOR_PIN49, INPUT);
pinMode (SENSOR_PIN51, INPUT);
pinMode (SENSOR_PIN53, INPUT);
}

void loop() {
  Cayenne.loop();
  
}

//  uscite valide ***********************************************************************************
CAYENNE_IN(VIRTUAL_CHANNEL22)
{int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN22, HIGH);}
  else { digitalWrite(ACTUATOR_PIN22, LOW);}}
  
CAYENNE_IN(VIRTUAL_CHANNEL24)
{int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN24, HIGH);}
  else { digitalWrite(ACTUATOR_PIN24, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL26)
{int value = getValue.asInt();   if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN26, HIGH);}
  else { digitalWrite(ACTUATOR_PIN26, LOW);}}  

CAYENNE_IN(VIRTUAL_CHANNEL28)
{int value = getValue.asInt();   if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN28, HIGH);}
  else { digitalWrite(ACTUATOR_PIN28, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL30)
{ int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN30, HIGH);}
  else { digitalWrite(ACTUATOR_PIN30, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL32)
{ int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN32, HIGH);}
  else { digitalWrite(ACTUATOR_PIN32, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL34)
{int value = getValue.asInt();   if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN34, HIGH);}
  else { digitalWrite(ACTUATOR_PIN34, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL36)
{ int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN36, HIGH);}
  else { digitalWrite(ACTUATOR_PIN36, LOW);}}
  
CAYENNE_IN(VIRTUAL_CHANNEL38)
{int value = getValue.asInt();   if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN38, HIGH);}
  else { digitalWrite(ACTUATOR_PIN38, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL40)
{ int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN40, HIGH);}
  else { digitalWrite(ACTUATOR_PIN40, LOW);}}
  
CAYENNE_IN(VIRTUAL_CHANNEL42)
{ int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN42, HIGH);}
  else { digitalWrite(ACTUATOR_PIN42, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL44)
{ int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN44, HIGH);}
  else { digitalWrite(ACTUATOR_PIN44, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL46)
{int value = getValue.asInt();   if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN46, HIGH);}
  else { digitalWrite(ACTUATOR_PIN46, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL48)
{int value = getValue.asInt();   if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN48, HIGH);}
  else { digitalWrite(ACTUATOR_PIN48, LOW);}}
   
CAYENNE_IN(VIRTUAL_CHANNEL50)
{ int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN50, HIGH);}
  else { digitalWrite(ACTUATOR_PIN50, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL52)
{ int value = getValue.asInt();  if (getValue.asInt() == 1) { digitalWrite(ACTUATOR_PIN52, HIGH);}
  else { digitalWrite(ACTUATOR_PIN52, LOW);}}
     
//    Ingressi    ********************************************************************

CAYENNE_OUT(VIRTUAL_CHANNEL2)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL2, digitalRead(SENSOR_PIN2));}

CAYENNE_OUT(VIRTUAL_CHANNEL3)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL3, digitalRead(SENSOR_PIN3));}

CAYENNE_OUT(VIRTUAL_CHANNEL4)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL4, digitalRead(SENSOR_PIN4));}

CAYENNE_OUT(VIRTUAL_CHANNEL5)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL5, digitalRead(SENSOR_PIN5));}

CAYENNE_OUT(VIRTUAL_CHANNEL6)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL6, digitalRead(SENSOR_PIN6));}

CAYENNE_OUT(VIRTUAL_CHANNEL7)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL7, digitalRead(SENSOR_PIN7));}

CAYENNE_OUT(VIRTUAL_CHANNEL8)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL8, digitalRead(SENSOR_PIN8));}

CAYENNE_OUT(VIRTUAL_CHANNEL9)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL9, digitalRead(SENSOR_PIN9));}

CAYENNE_OUT(VIRTUAL_CHANNEL10)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL10, digitalRead(SENSOR_PIN10));}

CAYENNE_OUT(VIRTUAL_CHANNEL11)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL11, digitalRead(SENSOR_PIN11));}

CAYENNE_OUT(VIRTUAL_CHANNEL12)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL12, digitalRead(SENSOR_PIN12));}

CAYENNE_OUT(VIRTUAL_CHANNEL13)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL13, digitalRead(SENSOR_PIN13));}

CAYENNE_OUT(VIRTUAL_CHANNEL14)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL14, digitalRead(SENSOR_PIN14));}

CAYENNE_OUT(VIRTUAL_CHANNEL15)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL15, digitalRead(SENSOR_PIN15));}

CAYENNE_OUT(VIRTUAL_CHANNEL16)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL16, digitalRead(SENSOR_PIN16));}

CAYENNE_OUT(VIRTUAL_CHANNEL17)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL17, digitalRead(SENSOR_PIN17));}

CAYENNE_OUT(VIRTUAL_CHANNEL23)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL23, digitalRead(SENSOR_PIN23));}

CAYENNE_OUT(VIRTUAL_CHANNEL25)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL25, digitalRead(SENSOR_PIN25));}

CAYENNE_OUT(VIRTUAL_CHANNEL27)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL27, digitalRead(SENSOR_PIN27));}

CAYENNE_OUT(VIRTUAL_CHANNEL29)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL29, digitalRead(SENSOR_PIN29));}

CAYENNE_OUT(VIRTUAL_CHANNEL31)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL31, digitalRead(SENSOR_PIN31));}

CAYENNE_OUT(VIRTUAL_CHANNEL33)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL33, digitalRead(SENSOR_PIN33));}

CAYENNE_OUT(VIRTUAL_CHANNEL35)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL35, digitalRead(SENSOR_PIN35));}

CAYENNE_OUT(VIRTUAL_CHANNEL37)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL37, digitalRead(SENSOR_PIN37));}

CAYENNE_OUT(VIRTUAL_CHANNEL39)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL39, digitalRead(SENSOR_PIN39));}

CAYENNE_OUT(VIRTUAL_CHANNEL41)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL41, digitalRead(SENSOR_PIN41));}

CAYENNE_OUT(VIRTUAL_CHANNEL43)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL43, digitalRead(SENSOR_PIN43));}

CAYENNE_OUT(VIRTUAL_CHANNEL45)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL45, digitalRead(SENSOR_PIN45));}

CAYENNE_OUT(VIRTUAL_CHANNEL47)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL47, digitalRead(SENSOR_PIN47));}

CAYENNE_OUT(VIRTUAL_CHANNEL49)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL49, digitalRead(SENSOR_PIN49));}

CAYENNE_OUT(VIRTUAL_CHANNEL51)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL51, digitalRead(SENSOR_PIN51));}

CAYENNE_OUT(VIRTUAL_CHANNEL53)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL53, digitalRead(SENSOR_PIN53));}

#2

do you have any other way to connect your device to cayenne like an ethernet shield or esp8266? As CayenneMQTTSerial library is a bit difficult as you cannot find the cause of the error using debugging.


#3

I have updated the system with W5100 ethernet.
ok connect, but outputs 32 to 52 do not work
inputs still to be tested

how do I insert the listing in the below window?

#define CAYENNE_DEBUG       // Uncomment to show debug messages
#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[] = "";
char password[] = "";
char clientID[] = "";

//************* Action pins Out 1°floor relè N.O.************************
#define VIRTUAL_CHANNEL22 22  
#define VIRTUAL_CHANNEL24 24
#define VIRTUAL_CHANNEL26 26
#define VIRTUAL_CHANNEL28 28
#define VIRTUAL_CHANNEL30 30
#define VIRTUAL_CHANNEL32 32
#define VIRTUAL_CHANNEL34 34
#define VIRTUAL_CHANNEL36 36
#define VIRTUAL_CHANNEL38 38
#define VIRTUAL_CHANNEL40 40
#define VIRTUAL_CHANNEL42 42
#define VIRTUAL_CHANNEL44 44
#define VIRTUAL_CHANNEL46 46
#define VIRTUAL_CHANNEL48 48
#define VIRTUAL_CHANNEL50 50
#define VIRTUAL_CHANNEL52 52

 
#define ACTUATOR_PIN22 22  
#define ACTUATOR_PIN24 24
#define ACTUATOR_PIN26 26
#define ACTUATOR_PIN28 28
#define ACTUATOR_PIN30 30
#define ACTUATOR_PIN32 32
#define ACTUATOR_PIN34 34
#define ACTUATOR_PIN36 36
#define ACTUATOR_PIN38 38
#define ACTUATOR_PIN40 40
#define ACTUATOR_PIN42 42
#define ACTUATOR_PIN44 44
#define ACTUATOR_PIN46 46
#define ACTUATOR_PIN48 48
#define ACTUATOR_PIN50 50
#define ACTUATOR_PIN52 52

//*************Action pins Input gnd  2° floor ************************************

      
#define VIRTUAL_CHANNEL2 2
#define VIRTUAL_CHANNEL3 3
#define VIRTUAL_CHANNEL4 4
#define VIRTUAL_CHANNEL5 5
#define VIRTUAL_CHANNEL6 6
#define VIRTUAL_CHANNEL7 7
#define VIRTUAL_CHANNEL8 8
#define VIRTUAL_CHANNEL9 9
//#define VIRTUAL_CHANNEL10 10  // disable for w5100
#define VIRTUAL_CHANNEL11 11
#define VIRTUAL_CHANNEL12 12
#define VIRTUAL_CHANNEL13 13
#define VIRTUAL_CHANNEL14 14
#define VIRTUAL_CHANNEL15 15
#define VIRTUAL_CHANNEL16 16
#define VIRTUAL_CHANNEL17 17

#define SENSOR_PIN2 2
#define SENSOR_PIN3 3
#define SENSOR_PIN4 4
#define SENSOR_PIN5 5
#define SENSOR_PIN6 6
#define SENSOR_PIN7 7
#define SENSOR_PIN8 8
#define SENSOR_PIN9 9
//#define SENSOR_PIN10 10  // disable for w5100
#define SENSOR_PIN11 11
#define SENSOR_PIN12 12
#define SENSOR_PIN13 13
#define SENSOR_PIN14 14
#define SENSOR_PIN15 15
#define SENSOR_PIN16 16
#define SENSOR_PIN17 17

//*************Action pins Input +  2° floor ************************************
#define VIRTUAL_CHANNEL23 23
#define VIRTUAL_CHANNEL25 25
#define VIRTUAL_CHANNEL27 27
#define VIRTUAL_CHANNEL29 29
#define VIRTUAL_CHANNEL31 31
#define VIRTUAL_CHANNEL33 33
#define VIRTUAL_CHANNEL35 35
#define VIRTUAL_CHANNEL37 37
#define VIRTUAL_CHANNEL39 39
#define VIRTUAL_CHANNEL41 41
#define VIRTUAL_CHANNEL43 43
#define VIRTUAL_CHANNEL45 45
#define VIRTUAL_CHANNEL47 47 
#define VIRTUAL_CHANNEL49 49
#define VIRTUAL_CHANNEL51 51
#define VIRTUAL_CHANNEL53 53

#define SENSOR_PIN23 23
#define SENSOR_PIN25 25
#define SENSOR_PIN27 27
#define SENSOR_PIN29 29
#define SENSOR_PIN31 31
#define SENSOR_PIN33 33
#define SENSOR_PIN35 35
#define SENSOR_PIN37 37
#define SENSOR_PIN39 39
#define SENSOR_PIN41 41
#define SENSOR_PIN43 43
#define SENSOR_PIN45 45
#define SENSOR_PIN47 47 
#define SENSOR_PIN49 49
#define SENSOR_PIN51 51
#define SENSOR_PIN53 53

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);
  

pinMode (ACTUATOR_PIN22, OUTPUT);
pinMode (ACTUATOR_PIN24, OUTPUT);
pinMode (ACTUATOR_PIN26, OUTPUT);
pinMode (ACTUATOR_PIN28, OUTPUT);
pinMode (ACTUATOR_PIN30, OUTPUT);
pinMode (ACTUATOR_PIN32, OUTPUT);
pinMode (ACTUATOR_PIN34, OUTPUT);
pinMode (ACTUATOR_PIN36, OUTPUT);
pinMode (ACTUATOR_PIN38, OUTPUT);
pinMode (ACTUATOR_PIN40, OUTPUT);
pinMode (ACTUATOR_PIN42, OUTPUT);
pinMode (ACTUATOR_PIN44, OUTPUT);
pinMode (ACTUATOR_PIN46, OUTPUT);
pinMode (ACTUATOR_PIN48, OUTPUT);
pinMode (ACTUATOR_PIN50, OUTPUT);
pinMode (ACTUATOR_PIN52, OUTPUT);

pinMode (SENSOR_PIN2 , INPUT_PULLUP);
pinMode (SENSOR_PIN3 , INPUT_PULLUP);
pinMode (SENSOR_PIN4 , INPUT_PULLUP);
pinMode (SENSOR_PIN5 , INPUT_PULLUP);
pinMode (SENSOR_PIN6 , INPUT_PULLUP);
pinMode (SENSOR_PIN7 , INPUT_PULLUP);
pinMode (SENSOR_PIN8 , INPUT_PULLUP);
pinMode (SENSOR_PIN9 , INPUT_PULLUP);
//pinMode (SENSOR_PIN10 , INPUT_PULLUP);  // disable for w5100
pinMode (SENSOR_PIN11 , INPUT_PULLUP);
pinMode (SENSOR_PIN12 , INPUT_PULLUP);
pinMode (SENSOR_PIN13 , INPUT_PULLUP);
pinMode (SENSOR_PIN14 , INPUT_PULLUP);
pinMode (SENSOR_PIN15 , INPUT_PULLUP);
pinMode (SENSOR_PIN16 , INPUT_PULLUP);
pinMode (SENSOR_PIN17 , INPUT_PULLUP);

pinMode (SENSOR_PIN23, INPUT);
pinMode (SENSOR_PIN25, INPUT_PULLUP);
pinMode (SENSOR_PIN27, INPUT);
pinMode (SENSOR_PIN29, INPUT);
pinMode (SENSOR_PIN31, INPUT);
pinMode (SENSOR_PIN33, INPUT);
pinMode (SENSOR_PIN35, INPUT);
pinMode (SENSOR_PIN37, INPUT);
pinMode (SENSOR_PIN39, INPUT);
pinMode (SENSOR_PIN41, INPUT);
pinMode (SENSOR_PIN43, INPUT);
pinMode (SENSOR_PIN45, INPUT);
pinMode (SENSOR_PIN47, INPUT);
pinMode (SENSOR_PIN49, INPUT);
pinMode (SENSOR_PIN51, INPUT);
pinMode (SENSOR_PIN53, INPUT);
}

void loop() {
  Cayenne.loop();
  
}

//  Output Do ***********************************************************************************
CAYENNE_IN(VIRTUAL_CHANNEL22)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue22 = getValue.asInt(); if (currentValue22 == 1) { digitalWrite(ACTUATOR_PIN22, HIGH);}
  else { digitalWrite(ACTUATOR_PIN22, LOW);}}
  
CAYENNE_IN(VIRTUAL_CHANNEL24)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue24 = getValue.asInt(); if (currentValue24 == 1) { digitalWrite(ACTUATOR_PIN24, HIGH);}
  else { digitalWrite(ACTUATOR_PIN24, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL26)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue26 = getValue.asInt(); if (currentValue26 == 1)  { digitalWrite(ACTUATOR_PIN26, HIGH);}
  else { digitalWrite(ACTUATOR_PIN26, LOW);}}  

CAYENNE_IN(VIRTUAL_CHANNEL28)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue28 = getValue.asInt(); if (currentValue28 == 1)  { digitalWrite(ACTUATOR_PIN28, HIGH);}
  else { digitalWrite(ACTUATOR_PIN28, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL30)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue30 = getValue.asInt(); if (currentValue30 == 1) { digitalWrite(ACTUATOR_PIN30, HIGH);}
  else { digitalWrite(ACTUATOR_PIN30, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL32)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue32 = getValue.asInt(); if (currentValue32 == 1) { digitalWrite(ACTUATOR_PIN32, HIGH);}
  else { digitalWrite(ACTUATOR_PIN32, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL34)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue34 = getValue.asInt(); if (currentValue34 == 1)  { digitalWrite(ACTUATOR_PIN34, HIGH);}
  else { digitalWrite(ACTUATOR_PIN34, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL36)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue36 = getValue.asInt(); if (currentValue36 == 1) { digitalWrite(ACTUATOR_PIN36, HIGH);}
  else { digitalWrite(ACTUATOR_PIN36, LOW);}}
  
CAYENNE_IN(VIRTUAL_CHANNEL38)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue38 = getValue.asInt(); if (currentValue38 == 1)  { digitalWrite(ACTUATOR_PIN38, HIGH);}
  else { digitalWrite(ACTUATOR_PIN38, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL40)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue40 = getValue.asInt(); if (currentValue40 == 1) { digitalWrite(ACTUATOR_PIN40, HIGH);}
  else { digitalWrite(ACTUATOR_PIN40, LOW);}}
  
CAYENNE_IN(VIRTUAL_CHANNEL42)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue42 = getValue.asInt(); if (currentValue42 == 1) { digitalWrite(ACTUATOR_PIN42, HIGH);}
  else { digitalWrite(ACTUATOR_PIN42, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL44)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue44 = getValue.asInt(); if (currentValue44 == 1) { digitalWrite(ACTUATOR_PIN44, HIGH);}
  else { digitalWrite(ACTUATOR_PIN44, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL46)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue46 = getValue.asInt(); if (currentValue46 == 1)  { digitalWrite(ACTUATOR_PIN46, HIGH);}
  else { digitalWrite(ACTUATOR_PIN46, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL48)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue48 = getValue.asInt(); if (currentValue48 == 1)  { digitalWrite(ACTUATOR_PIN48, HIGH);}
  else { digitalWrite(ACTUATOR_PIN48, LOW);}}
   
CAYENNE_IN(VIRTUAL_CHANNEL50)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue50 = getValue.asInt(); if (currentValue50 == 1) { digitalWrite(ACTUATOR_PIN50, HIGH);}
  else { digitalWrite(ACTUATOR_PIN50, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL52)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue52 = getValue.asInt(); if (currentValue52 == 1) { digitalWrite(ACTUATOR_PIN52, HIGH);}
  else { digitalWrite(ACTUATOR_PIN52, LOW);}}
     
//    reading Input    ********************************************************************

CAYENNE_OUT(VIRTUAL_CHANNEL2)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL2, digitalRead(SENSOR_PIN2));}

CAYENNE_OUT(VIRTUAL_CHANNEL3)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL3, digitalRead(SENSOR_PIN3));}

CAYENNE_OUT(VIRTUAL_CHANNEL4)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL4, digitalRead(SENSOR_PIN4));}

CAYENNE_OUT(VIRTUAL_CHANNEL5)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL5, digitalRead(SENSOR_PIN5));}

CAYENNE_OUT(VIRTUAL_CHANNEL6)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL6, digitalRead(SENSOR_PIN6));}

CAYENNE_OUT(VIRTUAL_CHANNEL7)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL7, digitalRead(SENSOR_PIN7));}

CAYENNE_OUT(VIRTUAL_CHANNEL8)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL8, digitalRead(SENSOR_PIN8));}

CAYENNE_OUT(VIRTUAL_CHANNEL9)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL9, digitalRead(SENSOR_PIN9));}

//CAYENNE_OUT(VIRTUAL_CHANNEL10)  
//{Cayenne.virtualWrite(VIRTUAL_CHANNEL10, digitalRead(SENSOR_PIN10));}

CAYENNE_OUT(VIRTUAL_CHANNEL11)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL11, digitalRead(SENSOR_PIN11));}

CAYENNE_OUT(VIRTUAL_CHANNEL12)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL12, digitalRead(SENSOR_PIN12));}

CAYENNE_OUT(VIRTUAL_CHANNEL13)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL13, digitalRead(SENSOR_PIN13));}

CAYENNE_OUT(VIRTUAL_CHANNEL14)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL14, digitalRead(SENSOR_PIN14));}

CAYENNE_OUT(VIRTUAL_CHANNEL15)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL15, digitalRead(SENSOR_PIN15));}

CAYENNE_OUT(VIRTUAL_CHANNEL16)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL16, digitalRead(SENSOR_PIN16));}

CAYENNE_OUT(VIRTUAL_CHANNEL17)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL17, digitalRead(SENSOR_PIN17));}

CAYENNE_OUT(VIRTUAL_CHANNEL23)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL23, digitalRead(SENSOR_PIN23));}

CAYENNE_OUT(VIRTUAL_CHANNEL25)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL25, digitalRead(SENSOR_PIN25));}

CAYENNE_OUT(VIRTUAL_CHANNEL27)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL27, digitalRead(SENSOR_PIN27));}

CAYENNE_OUT(VIRTUAL_CHANNEL29)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL29, digitalRead(SENSOR_PIN29));}

CAYENNE_OUT(VIRTUAL_CHANNEL31)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL31, digitalRead(SENSOR_PIN31));}

CAYENNE_OUT(VIRTUAL_CHANNEL33)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL33, digitalRead(SENSOR_PIN33));}

CAYENNE_OUT(VIRTUAL_CHANNEL35)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL35, digitalRead(SENSOR_PIN35));}

CAYENNE_OUT(VIRTUAL_CHANNEL37)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL37, digitalRead(SENSOR_PIN37));}

CAYENNE_OUT(VIRTUAL_CHANNEL39)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL39, digitalRead(SENSOR_PIN39));}

CAYENNE_OUT(VIRTUAL_CHANNEL41)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL41, digitalRead(SENSOR_PIN41));}

CAYENNE_OUT(VIRTUAL_CHANNEL43)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL43, digitalRead(SENSOR_PIN43));}

CAYENNE_OUT(VIRTUAL_CHANNEL45)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL45, digitalRead(SENSOR_PIN45));}

CAYENNE_OUT(VIRTUAL_CHANNEL47)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL47, digitalRead(SENSOR_PIN47));}

CAYENNE_OUT(VIRTUAL_CHANNEL49)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL49, digitalRead(SENSOR_PIN49));}

CAYENNE_OUT(VIRTUAL_CHANNEL51)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL51, digitalRead(SENSOR_PIN51));}

CAYENNE_OUT(VIRTUAL_CHANNEL53)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL53, digitalRead(SENSOR_PIN53));}

#4

for channel greater than 30 you have to use CAYENNE_OUT_DEFAULT() and CAYENNE_IN_DEFAULT().

for receiving data:

CAYENNE_IN_DEFAULT()
   {
CAYENNE_LOG("CAYENNE_IN_DEFAULT(%u) - %s, %u", request.channel, getValue.getId(), 
    getValue.asInt());
    switch (request.channel) {
 case 32 :
   int x = getValue.asInt();
   Serial.println(x);
   break;
 case 33 :
   int x = getValue.asInt();
   Serial.println(x);
   break;
}
}

and for sending data:

CAYENNE_OUT_DEFAULT()
{ 
   Cayenne.virtualWrite(34, millis());
   Cayenne.virtualWrite(35, digitalRead(SENSOR_PIN35));
 }

#5

Thank you,
this works perfectly

CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %u”, request.channel, getValue.getId(),
getValue.asInt());
switch (request.channel) {

case 32 :
int x = getValue.asInt();
Serial.println(x); // for debug
if (x == 1) { digitalWrite(ACTUATOR_PIN32, HIGH);}
else { digitalWrite(ACTUATOR_PIN32, LOW);}
break;
}
}

If I put two cases gives me error

CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %u”, request.channel, getValue.getId(),
getValue.asInt());
switch (request.channel) {

case 32 :
int x = getValue.asInt();
Serial.println(x); // for debug
if (x == 1) { digitalWrite(ACTUATOR_PIN32, HIGH);}
else { digitalWrite(ACTUATOR_PIN32, LOW);}
break;
case 34 :
int x = getValue.asInt();
Serial.println(x); // for debug
if (x == 1) { digitalWrite(ACTUATOR_PIN34, HIGH);}
else { digitalWrite(ACTUATOR_PIN34, LOW);}
break;
}
}

give me this error:
arduinodue_w5100_eth_ok:189:8: error: ‘int x’ previously declared here

int x = getValue.asInt();   

    ^

exit status 1
jump to case label [-fpermissive]


#6

change to:

case 34 :
int y = getValue.asInt();
Serial.println(y); // for debug
if (y == 1) { digitalWrite(ACTUATOR_PIN34, HIGH);}
else { digitalWrite(ACTUATOR_PIN34, LOW);}
break;

#7

no work

CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %u”, request.channel, getValue.getId(),
getValue.asInt());
switch (request.channel) {

case 32 :
int x = getValue.asInt();
Serial.println(x); // for debug
if (x == 1) { digitalWrite(ACTUATOR_PIN32, HIGH);}
else { digitalWrite(ACTUATOR_PIN32, LOW);}
break;
case 34 :
int y = getValue.asInt();
Serial.println(y); // for debug
if (y == 1) { digitalWrite(ACTUATOR_PIN34, HIGH);}
else { digitalWrite(ACTUATOR_PIN34, LOW);}
break;
}
}

same error :
arduinodue_w5100_eth_ok:189:8: error: crosses initialization of ‘int x’

int x = getValue.asInt();   

    ^

exit status 1
jump to case label [-fpermissive]


#8

can you post the entire code.


#9
#define CAYENNE_DEBUG       // Uncomment to show debug messages
#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[] = "";
char password[] = "";
char clientID[] = "";

//************* Action pins Out 1°floor relè N.O.************************
#define VIRTUAL_CHANNEL22 22  
#define VIRTUAL_CHANNEL24 24
#define VIRTUAL_CHANNEL26 26
#define VIRTUAL_CHANNEL28 28
#define VIRTUAL_CHANNEL30 30
#define VIRTUAL_CHANNEL32 32
#define VIRTUAL_CHANNEL34 34
#define VIRTUAL_CHANNEL36 36
#define VIRTUAL_CHANNEL38 38
#define VIRTUAL_CHANNEL40 40
#define VIRTUAL_CHANNEL42 42
#define VIRTUAL_CHANNEL44 44
#define VIRTUAL_CHANNEL46 46
#define VIRTUAL_CHANNEL48 48
#define VIRTUAL_CHANNEL50 50
#define VIRTUAL_CHANNEL52 52

 
#define ACTUATOR_PIN22 22  
#define ACTUATOR_PIN24 24
#define ACTUATOR_PIN26 26
#define ACTUATOR_PIN28 28
#define ACTUATOR_PIN30 30
#define ACTUATOR_PIN32 32
#define ACTUATOR_PIN34 34
#define ACTUATOR_PIN36 36
#define ACTUATOR_PIN38 38
#define ACTUATOR_PIN40 40
#define ACTUATOR_PIN42 42
#define ACTUATOR_PIN44 44
#define ACTUATOR_PIN46 46
#define ACTUATOR_PIN48 48
#define ACTUATOR_PIN50 50
#define ACTUATOR_PIN52 52

//*************Action pins Input gnd  2° floor ************************************

      
#define VIRTUAL_CHANNEL2 2
#define VIRTUAL_CHANNEL3 3
#define VIRTUAL_CHANNEL4 4
#define VIRTUAL_CHANNEL5 5
#define VIRTUAL_CHANNEL6 6
#define VIRTUAL_CHANNEL7 7
#define VIRTUAL_CHANNEL8 8
#define VIRTUAL_CHANNEL9 9
//#define VIRTUAL_CHANNEL10 10  // disable for w5100
#define VIRTUAL_CHANNEL11 11
#define VIRTUAL_CHANNEL12 12
#define VIRTUAL_CHANNEL13 13
#define VIRTUAL_CHANNEL14 14
#define VIRTUAL_CHANNEL15 15
#define VIRTUAL_CHANNEL16 16
#define VIRTUAL_CHANNEL17 17

#define SENSOR_PIN2 2
#define SENSOR_PIN3 3
#define SENSOR_PIN4 4
#define SENSOR_PIN5 5
#define SENSOR_PIN6 6
#define SENSOR_PIN7 7
#define SENSOR_PIN8 8
#define SENSOR_PIN9 9
//#define SENSOR_PIN10 10  // disable for w5100
#define SENSOR_PIN11 11
#define SENSOR_PIN12 12
#define SENSOR_PIN13 13
#define SENSOR_PIN14 14
#define SENSOR_PIN15 15
#define SENSOR_PIN16 16
#define SENSOR_PIN17 17

//*************Action pins Input +  2° floor ************************************
#define VIRTUAL_CHANNEL23 23
#define VIRTUAL_CHANNEL25 25
#define VIRTUAL_CHANNEL27 27
#define VIRTUAL_CHANNEL29 29
#define VIRTUAL_CHANNEL31 31
#define VIRTUAL_CHANNEL33 33
#define VIRTUAL_CHANNEL35 35
#define VIRTUAL_CHANNEL37 37
#define VIRTUAL_CHANNEL39 39
#define VIRTUAL_CHANNEL41 41
#define VIRTUAL_CHANNEL43 43
#define VIRTUAL_CHANNEL45 45
#define VIRTUAL_CHANNEL47 47 
#define VIRTUAL_CHANNEL49 49
#define VIRTUAL_CHANNEL51 51
#define VIRTUAL_CHANNEL53 53

#define SENSOR_PIN23 23
#define SENSOR_PIN25 25
#define SENSOR_PIN27 27
#define SENSOR_PIN29 29
#define SENSOR_PIN31 31
#define SENSOR_PIN33 33
#define SENSOR_PIN35 35
#define SENSOR_PIN37 37
#define SENSOR_PIN39 39
#define SENSOR_PIN41 41
#define SENSOR_PIN43 43
#define SENSOR_PIN45 45
#define SENSOR_PIN47 47 
#define SENSOR_PIN49 49
#define SENSOR_PIN51 51
#define SENSOR_PIN53 53

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);
  

pinMode (ACTUATOR_PIN22, OUTPUT);
pinMode (ACTUATOR_PIN24, OUTPUT);
pinMode (ACTUATOR_PIN26, OUTPUT);
pinMode (ACTUATOR_PIN28, OUTPUT);
pinMode (ACTUATOR_PIN30, OUTPUT);
pinMode (ACTUATOR_PIN32, OUTPUT);
pinMode (ACTUATOR_PIN34, OUTPUT);
pinMode (ACTUATOR_PIN36, OUTPUT);
pinMode (ACTUATOR_PIN38, OUTPUT);
pinMode (ACTUATOR_PIN40, OUTPUT);
pinMode (ACTUATOR_PIN42, OUTPUT);
pinMode (ACTUATOR_PIN44, OUTPUT);
pinMode (ACTUATOR_PIN46, OUTPUT);
pinMode (ACTUATOR_PIN48, OUTPUT);
pinMode (ACTUATOR_PIN50, OUTPUT);
pinMode (ACTUATOR_PIN52, OUTPUT);

pinMode (SENSOR_PIN2 , INPUT_PULLUP);
pinMode (SENSOR_PIN3 , INPUT_PULLUP);
pinMode (SENSOR_PIN4 , INPUT_PULLUP);
pinMode (SENSOR_PIN5 , INPUT_PULLUP);
pinMode (SENSOR_PIN6 , INPUT_PULLUP);
pinMode (SENSOR_PIN7 , INPUT_PULLUP);
pinMode (SENSOR_PIN8 , INPUT_PULLUP);
pinMode (SENSOR_PIN9 , INPUT_PULLUP);
//pinMode (SENSOR_PIN10 , INPUT_PULLUP);  // disable for w5100
pinMode (SENSOR_PIN11 , INPUT_PULLUP);
pinMode (SENSOR_PIN12 , INPUT_PULLUP);
pinMode (SENSOR_PIN13 , INPUT_PULLUP);
pinMode (SENSOR_PIN14 , INPUT_PULLUP);
pinMode (SENSOR_PIN15 , INPUT_PULLUP);
pinMode (SENSOR_PIN16 , INPUT_PULLUP);
pinMode (SENSOR_PIN17 , INPUT_PULLUP);

pinMode (SENSOR_PIN23, INPUT);
pinMode (SENSOR_PIN25, INPUT_PULLUP);
pinMode (SENSOR_PIN27, INPUT);
pinMode (SENSOR_PIN29, INPUT);
pinMode (SENSOR_PIN31, INPUT);
pinMode (SENSOR_PIN33, INPUT);
pinMode (SENSOR_PIN35, INPUT);
pinMode (SENSOR_PIN37, INPUT);
pinMode (SENSOR_PIN39, INPUT);
pinMode (SENSOR_PIN41, INPUT);
pinMode (SENSOR_PIN43, INPUT);
pinMode (SENSOR_PIN45, INPUT);
pinMode (SENSOR_PIN47, INPUT);
pinMode (SENSOR_PIN49, INPUT);
pinMode (SENSOR_PIN51, INPUT);
pinMode (SENSOR_PIN53, INPUT);
}

void loop() {
  Cayenne.loop();
  
}
CAYENNE_IN_DEFAULT()
   {
CAYENNE_LOG("CAYENNE_IN_DEFAULT(%u) - %s, %u", request.channel, getValue.getId(), 
    getValue.asInt());
    switch (request.channel) {
      
 case 32 :
   int x = getValue.asInt();   
   Serial.println(x);  // for debug
   if (x == 1)  { digitalWrite(ACTUATOR_PIN32, HIGH);}
   else { digitalWrite(ACTUATOR_PIN32, LOW);}
  break;      
  case 34 :
   int y = getValue.asInt();   
   Serial.println(y);  // for debug
   if (y == 1)  { digitalWrite(ACTUATOR_PIN34, HIGH);}
   else { digitalWrite(ACTUATOR_PIN34, LOW);}
   break;
}
}
//  Output Do ***********************************************************************************
CAYENNE_IN(VIRTUAL_CHANNEL22)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue22 = getValue.asInt(); if (currentValue22 == 1) { digitalWrite(ACTUATOR_PIN22, HIGH);}
  else { digitalWrite(ACTUATOR_PIN22, LOW);}}
  
CAYENNE_IN(VIRTUAL_CHANNEL24)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue24 = getValue.asInt(); if (currentValue24 == 1) { digitalWrite(ACTUATOR_PIN24, HIGH);}
  else { digitalWrite(ACTUATOR_PIN24, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL26)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue26 = getValue.asInt(); if (currentValue26 == 1)  { digitalWrite(ACTUATOR_PIN26, HIGH);}
  else { digitalWrite(ACTUATOR_PIN26, LOW);}}  

CAYENNE_IN(VIRTUAL_CHANNEL28)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue28 = getValue.asInt(); if (currentValue28 == 1)  { digitalWrite(ACTUATOR_PIN28, HIGH);}
  else { digitalWrite(ACTUATOR_PIN28, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL30)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue30 = getValue.asInt(); if (currentValue30 == 1) { digitalWrite(ACTUATOR_PIN30, HIGH);}
  else { digitalWrite(ACTUATOR_PIN30, LOW);}}
  
/*  Disable for test
CAYENNE_IN(VIRTUAL_CHANNEL32)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue32 = getValue.asInt(); if (currentValue32 == 1) { digitalWrite(ACTUATOR_PIN32, HIGH);}
  else { digitalWrite(ACTUATOR_PIN32, LOW);}}

/*  

CAYENNE_IN(VIRTUAL_CHANNEL34)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue34 = getValue.asInt(); if (currentValue34 == 1)  { digitalWrite(ACTUATOR_PIN34, HIGH);}
  else { digitalWrite(ACTUATOR_PIN34, LOW);}}


CAYENNE_IN(34)  
{if (getValue.asInt() == 1) {digitalWrite(ACTUATOR_PIN34, HIGH);}
else {digitalWrite(ACTUATOR_PIN34, LOW);}}


CAYENNE_IN(VIRTUAL_CHANNEL36)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue36 = getValue.asInt(); if (currentValue36 == 1) { digitalWrite(ACTUATOR_PIN36, HIGH);}
  else { digitalWrite(ACTUATOR_PIN36, LOW);}}
  
CAYENNE_IN(VIRTUAL_CHANNEL38)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue38 = getValue.asInt(); if (currentValue38 == 1)  { digitalWrite(ACTUATOR_PIN38, HIGH);}
  else { digitalWrite(ACTUATOR_PIN38, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL40)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue40 = getValue.asInt(); if (currentValue40 == 1) { digitalWrite(ACTUATOR_PIN40, HIGH);}
  else { digitalWrite(ACTUATOR_PIN40, LOW);}}
  
CAYENNE_IN(VIRTUAL_CHANNEL42)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue42 = getValue.asInt(); if (currentValue42 == 1) { digitalWrite(ACTUATOR_PIN42, HIGH);}
  else { digitalWrite(ACTUATOR_PIN42, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL44)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue44 = getValue.asInt(); if (currentValue44 == 1) { digitalWrite(ACTUATOR_PIN44, HIGH);}
  else { digitalWrite(ACTUATOR_PIN44, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL46)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue46 = getValue.asInt(); if (currentValue46 == 1)  { digitalWrite(ACTUATOR_PIN46, HIGH);}
  else { digitalWrite(ACTUATOR_PIN46, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL48)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue48 = getValue.asInt(); if (currentValue48 == 1)  { digitalWrite(ACTUATOR_PIN48, HIGH);}
  else { digitalWrite(ACTUATOR_PIN48, LOW);}}
   
CAYENNE_IN(VIRTUAL_CHANNEL50)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue50 = getValue.asInt(); if (currentValue50 == 1) { digitalWrite(ACTUATOR_PIN50, HIGH);}
  else { digitalWrite(ACTUATOR_PIN50, LOW);}}

CAYENNE_IN(VIRTUAL_CHANNEL52)
{CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
int currentValue52 = getValue.asInt(); if (currentValue52 == 1) { digitalWrite(ACTUATOR_PIN52, HIGH);}
  else { digitalWrite(ACTUATOR_PIN52, LOW);}}

*/  
     
//    reading Input    ********************************************************************

CAYENNE_OUT(VIRTUAL_CHANNEL2)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL2, digitalRead(SENSOR_PIN2));}

CAYENNE_OUT(VIRTUAL_CHANNEL3)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL3, digitalRead(SENSOR_PIN3));}

CAYENNE_OUT(VIRTUAL_CHANNEL4)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL4, digitalRead(SENSOR_PIN4));}

CAYENNE_OUT(VIRTUAL_CHANNEL5)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL5, digitalRead(SENSOR_PIN5));}

CAYENNE_OUT(VIRTUAL_CHANNEL6)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL6, digitalRead(SENSOR_PIN6));}

CAYENNE_OUT(VIRTUAL_CHANNEL7)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL7, digitalRead(SENSOR_PIN7));}

CAYENNE_OUT(VIRTUAL_CHANNEL8)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL8, digitalRead(SENSOR_PIN8));}

CAYENNE_OUT(VIRTUAL_CHANNEL9)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL9, digitalRead(SENSOR_PIN9));}

//CAYENNE_OUT(VIRTUAL_CHANNEL10)  
//{Cayenne.virtualWrite(VIRTUAL_CHANNEL10, digitalRead(SENSOR_PIN10));}

CAYENNE_OUT(VIRTUAL_CHANNEL11)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL11, digitalRead(SENSOR_PIN11));}

CAYENNE_OUT(VIRTUAL_CHANNEL12)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL12, digitalRead(SENSOR_PIN12));}

CAYENNE_OUT(VIRTUAL_CHANNEL13)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL13, digitalRead(SENSOR_PIN13));}

CAYENNE_OUT(VIRTUAL_CHANNEL14)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL14, digitalRead(SENSOR_PIN14));}

CAYENNE_OUT(VIRTUAL_CHANNEL15)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL15, digitalRead(SENSOR_PIN15));}

CAYENNE_OUT(VIRTUAL_CHANNEL16)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL16, digitalRead(SENSOR_PIN16));}

CAYENNE_OUT(VIRTUAL_CHANNEL17)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL17, digitalRead(SENSOR_PIN17));}

CAYENNE_OUT(VIRTUAL_CHANNEL23)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL23, digitalRead(SENSOR_PIN23));}

CAYENNE_OUT(VIRTUAL_CHANNEL25)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL25, digitalRead(SENSOR_PIN25));}

CAYENNE_OUT(VIRTUAL_CHANNEL27)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL27, digitalRead(SENSOR_PIN27));}

CAYENNE_OUT(VIRTUAL_CHANNEL29)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL29, digitalRead(SENSOR_PIN29));}

CAYENNE_OUT(VIRTUAL_CHANNEL31)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL31, digitalRead(SENSOR_PIN31));}

CAYENNE_OUT(VIRTUAL_CHANNEL33)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL33, digitalRead(SENSOR_PIN33));}

CAYENNE_OUT(VIRTUAL_CHANNEL35)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL35, digitalRead(SENSOR_PIN35));}

CAYENNE_OUT(VIRTUAL_CHANNEL37)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL37, digitalRead(SENSOR_PIN37));}

CAYENNE_OUT(VIRTUAL_CHANNEL39)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL39, digitalRead(SENSOR_PIN39));}

CAYENNE_OUT(VIRTUAL_CHANNEL41)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL41, digitalRead(SENSOR_PIN41));}

CAYENNE_OUT(VIRTUAL_CHANNEL43)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL43, digitalRead(SENSOR_PIN43));}

CAYENNE_OUT(VIRTUAL_CHANNEL45)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL45, digitalRead(SENSOR_PIN45));}

CAYENNE_OUT(VIRTUAL_CHANNEL47)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL47, digitalRead(SENSOR_PIN47));}

CAYENNE_OUT(VIRTUAL_CHANNEL49)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL49, digitalRead(SENSOR_PIN49));}

CAYENNE_OUT(VIRTUAL_CHANNEL51)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL51, digitalRead(SENSOR_PIN51));}

CAYENNE_OUT(VIRTUAL_CHANNEL53)  
{Cayenne.virtualWrite(VIRTUAL_CHANNEL53, digitalRead(SENSOR_PIN53));}

#10

give this a try:

#define CAYENNE_DEBUG       // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h>
int x;
int y;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";

//************* Action pins Out 1°floor relè N.O.************************
#define VIRTUAL_CHANNEL22 22
#define VIRTUAL_CHANNEL24 24
#define VIRTUAL_CHANNEL26 26
#define VIRTUAL_CHANNEL28 28
#define VIRTUAL_CHANNEL30 30
#define VIRTUAL_CHANNEL32 32
#define VIRTUAL_CHANNEL34 34
#define VIRTUAL_CHANNEL36 36
#define VIRTUAL_CHANNEL38 38
#define VIRTUAL_CHANNEL40 40
#define VIRTUAL_CHANNEL42 42
#define VIRTUAL_CHANNEL44 44
#define VIRTUAL_CHANNEL46 46
#define VIRTUAL_CHANNEL48 48
#define VIRTUAL_CHANNEL50 50
#define VIRTUAL_CHANNEL52 52


#define ACTUATOR_PIN22 22
#define ACTUATOR_PIN24 24
#define ACTUATOR_PIN26 26
#define ACTUATOR_PIN28 28
#define ACTUATOR_PIN30 30
#define ACTUATOR_PIN32 32
#define ACTUATOR_PIN34 34
#define ACTUATOR_PIN36 36
#define ACTUATOR_PIN38 38
#define ACTUATOR_PIN40 40
#define ACTUATOR_PIN42 42
#define ACTUATOR_PIN44 44
#define ACTUATOR_PIN46 46
#define ACTUATOR_PIN48 48
#define ACTUATOR_PIN50 50
#define ACTUATOR_PIN52 52

//*************Action pins Input gnd  2° floor ************************************


#define VIRTUAL_CHANNEL2 2
#define VIRTUAL_CHANNEL3 3
#define VIRTUAL_CHANNEL4 4
#define VIRTUAL_CHANNEL5 5
#define VIRTUAL_CHANNEL6 6
#define VIRTUAL_CHANNEL7 7
#define VIRTUAL_CHANNEL8 8
#define VIRTUAL_CHANNEL9 9
//#define VIRTUAL_CHANNEL10 10  // disable for w5100
#define VIRTUAL_CHANNEL11 11
#define VIRTUAL_CHANNEL12 12
#define VIRTUAL_CHANNEL13 13
#define VIRTUAL_CHANNEL14 14
#define VIRTUAL_CHANNEL15 15
#define VIRTUAL_CHANNEL16 16
#define VIRTUAL_CHANNEL17 17

#define SENSOR_PIN2 2
#define SENSOR_PIN3 3
#define SENSOR_PIN4 4
#define SENSOR_PIN5 5
#define SENSOR_PIN6 6
#define SENSOR_PIN7 7
#define SENSOR_PIN8 8
#define SENSOR_PIN9 9
//#define SENSOR_PIN10 10  // disable for w5100
#define SENSOR_PIN11 11
#define SENSOR_PIN12 12
#define SENSOR_PIN13 13
#define SENSOR_PIN14 14
#define SENSOR_PIN15 15
#define SENSOR_PIN16 16
#define SENSOR_PIN17 17

//*************Action pins Input +  2° floor ************************************
#define VIRTUAL_CHANNEL23 23
#define VIRTUAL_CHANNEL25 25
#define VIRTUAL_CHANNEL27 27
#define VIRTUAL_CHANNEL29 29
#define VIRTUAL_CHANNEL31 31
#define VIRTUAL_CHANNEL33 33
#define VIRTUAL_CHANNEL35 35
#define VIRTUAL_CHANNEL37 37
#define VIRTUAL_CHANNEL39 39
#define VIRTUAL_CHANNEL41 41
#define VIRTUAL_CHANNEL43 43
#define VIRTUAL_CHANNEL45 45
#define VIRTUAL_CHANNEL47 47
#define VIRTUAL_CHANNEL49 49
#define VIRTUAL_CHANNEL51 51
#define VIRTUAL_CHANNEL53 53

#define SENSOR_PIN23 23
#define SENSOR_PIN25 25
#define SENSOR_PIN27 27
#define SENSOR_PIN29 29
#define SENSOR_PIN31 31
#define SENSOR_PIN33 33
#define SENSOR_PIN35 35
#define SENSOR_PIN37 37
#define SENSOR_PIN39 39
#define SENSOR_PIN41 41
#define SENSOR_PIN43 43
#define SENSOR_PIN45 45
#define SENSOR_PIN47 47
#define SENSOR_PIN49 49
#define SENSOR_PIN51 51
#define SENSOR_PIN53 53

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);


  pinMode (ACTUATOR_PIN22, OUTPUT);
  pinMode (ACTUATOR_PIN24, OUTPUT);
  pinMode (ACTUATOR_PIN26, OUTPUT);
  pinMode (ACTUATOR_PIN28, OUTPUT);
  pinMode (ACTUATOR_PIN30, OUTPUT);
  pinMode (ACTUATOR_PIN32, OUTPUT);
  pinMode (ACTUATOR_PIN34, OUTPUT);
  pinMode (ACTUATOR_PIN36, OUTPUT);
  pinMode (ACTUATOR_PIN38, OUTPUT);
  pinMode (ACTUATOR_PIN40, OUTPUT);
  pinMode (ACTUATOR_PIN42, OUTPUT);
  pinMode (ACTUATOR_PIN44, OUTPUT);
  pinMode (ACTUATOR_PIN46, OUTPUT);
  pinMode (ACTUATOR_PIN48, OUTPUT);
  pinMode (ACTUATOR_PIN50, OUTPUT);
  pinMode (ACTUATOR_PIN52, OUTPUT);

  pinMode (SENSOR_PIN2 , INPUT_PULLUP);
  pinMode (SENSOR_PIN3 , INPUT_PULLUP);
  pinMode (SENSOR_PIN4 , INPUT_PULLUP);
  pinMode (SENSOR_PIN5 , INPUT_PULLUP);
  pinMode (SENSOR_PIN6 , INPUT_PULLUP);
  pinMode (SENSOR_PIN7 , INPUT_PULLUP);
  pinMode (SENSOR_PIN8 , INPUT_PULLUP);
  pinMode (SENSOR_PIN9 , INPUT_PULLUP);
  //pinMode (SENSOR_PIN10 , INPUT_PULLUP);  // disable for w5100
  pinMode (SENSOR_PIN11 , INPUT_PULLUP);
  pinMode (SENSOR_PIN12 , INPUT_PULLUP);
  pinMode (SENSOR_PIN13 , INPUT_PULLUP);
  pinMode (SENSOR_PIN14 , INPUT_PULLUP);
  pinMode (SENSOR_PIN15 , INPUT_PULLUP);
  pinMode (SENSOR_PIN16 , INPUT_PULLUP);
  pinMode (SENSOR_PIN17 , INPUT_PULLUP);

  pinMode (SENSOR_PIN23, INPUT);
  pinMode (SENSOR_PIN25, INPUT_PULLUP);
  pinMode (SENSOR_PIN27, INPUT);
  pinMode (SENSOR_PIN29, INPUT);
  pinMode (SENSOR_PIN31, INPUT);
  pinMode (SENSOR_PIN33, INPUT);
  pinMode (SENSOR_PIN35, INPUT);
  pinMode (SENSOR_PIN37, INPUT);
  pinMode (SENSOR_PIN39, INPUT);
  pinMode (SENSOR_PIN41, INPUT);
  pinMode (SENSOR_PIN43, INPUT);
  pinMode (SENSOR_PIN45, INPUT);
  pinMode (SENSOR_PIN47, INPUT);
  pinMode (SENSOR_PIN49, INPUT);
  pinMode (SENSOR_PIN51, INPUT);
  pinMode (SENSOR_PIN53, INPUT);
}

void loop() {
  Cayenne.loop();

}
CAYENNE_IN_DEFAULT()
{
  CAYENNE_LOG("CAYENNE_IN_DEFAULT(%u) - %s, %u", request.channel, getValue.getId(), getValue.asInt());
  switch (request.channel) {
    case 31 :
       x = getValue.asInt();
      Serial.println(x);
      if (x == 1) {
        digitalWrite(ACTUATOR_PIN44, HIGH);
      }
      else {
        digitalWrite(ACTUATOR_PIN44, LOW);
      }
      break;
    case 32 :
       y = getValue.asInt();
      Serial.println(y);
      if (y == 1) {
        digitalWrite(ACTUATOR_PIN44, HIGH);
      }
      else {
        digitalWrite(ACTUATOR_PIN44, LOW);
      }
      break;
  }
}

//  Output Do ***********************************************************************************
CAYENNE_IN(VIRTUAL_CHANNEL22)
{ CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue22 = getValue.asInt(); if (currentValue22 == 1) {
    digitalWrite(ACTUATOR_PIN22, HIGH);
  }
  else {
    digitalWrite(ACTUATOR_PIN22, LOW);
  }
}

CAYENNE_IN(VIRTUAL_CHANNEL24)
{ CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue24 = getValue.asInt(); if (currentValue24 == 1) {
    digitalWrite(ACTUATOR_PIN24, HIGH);
  }
  else {
    digitalWrite(ACTUATOR_PIN24, LOW);
  }
}

CAYENNE_IN(VIRTUAL_CHANNEL26)
{ CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue26 = getValue.asInt(); if (currentValue26 == 1)  {
    digitalWrite(ACTUATOR_PIN26, HIGH);
  }
  else {
    digitalWrite(ACTUATOR_PIN26, LOW);
  }
}

CAYENNE_IN(VIRTUAL_CHANNEL28)
{ CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue28 = getValue.asInt(); if (currentValue28 == 1)  {
    digitalWrite(ACTUATOR_PIN28, HIGH);
  }
  else {
    digitalWrite(ACTUATOR_PIN28, LOW);
  }
}

CAYENNE_IN(VIRTUAL_CHANNEL30)
{ CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue30 = getValue.asInt(); if (currentValue30 == 1) {
    digitalWrite(ACTUATOR_PIN30, HIGH);
  }
  else {
    digitalWrite(ACTUATOR_PIN30, LOW);
  }
}

/*  Disable for test
  CAYENNE_IN(VIRTUAL_CHANNEL32)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue32 = getValue.asInt(); if (currentValue32 == 1) { digitalWrite(ACTUATOR_PIN32, HIGH);}
  else { digitalWrite(ACTUATOR_PIN32, LOW);}}

  /*

  CAYENNE_IN(VIRTUAL_CHANNEL34)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue34 = getValue.asInt(); if (currentValue34 == 1)  { digitalWrite(ACTUATOR_PIN34, HIGH);}
  else { digitalWrite(ACTUATOR_PIN34, LOW);}}


  CAYENNE_IN(34)
  {if (getValue.asInt() == 1) {digitalWrite(ACTUATOR_PIN34, HIGH);}
  else {digitalWrite(ACTUATOR_PIN34, LOW);}}


  CAYENNE_IN(VIRTUAL_CHANNEL36)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue36 = getValue.asInt(); if (currentValue36 == 1) { digitalWrite(ACTUATOR_PIN36, HIGH);}
  else { digitalWrite(ACTUATOR_PIN36, LOW);}}

  CAYENNE_IN(VIRTUAL_CHANNEL38)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue38 = getValue.asInt(); if (currentValue38 == 1)  { digitalWrite(ACTUATOR_PIN38, HIGH);}
  else { digitalWrite(ACTUATOR_PIN38, LOW);}}

  CAYENNE_IN(VIRTUAL_CHANNEL40)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue40 = getValue.asInt(); if (currentValue40 == 1) { digitalWrite(ACTUATOR_PIN40, HIGH);}
  else { digitalWrite(ACTUATOR_PIN40, LOW);}}

  CAYENNE_IN(VIRTUAL_CHANNEL42)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue42 = getValue.asInt(); if (currentValue42 == 1) { digitalWrite(ACTUATOR_PIN42, HIGH);}
  else { digitalWrite(ACTUATOR_PIN42, LOW);}}

  CAYENNE_IN(VIRTUAL_CHANNEL44)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue44 = getValue.asInt(); if (currentValue44 == 1) { digitalWrite(ACTUATOR_PIN44, HIGH);}
  else { digitalWrite(ACTUATOR_PIN44, LOW);}}

  CAYENNE_IN(VIRTUAL_CHANNEL46)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue46 = getValue.asInt(); if (currentValue46 == 1)  { digitalWrite(ACTUATOR_PIN46, HIGH);}
  else { digitalWrite(ACTUATOR_PIN46, LOW);}}

  CAYENNE_IN(VIRTUAL_CHANNEL48)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue48 = getValue.asInt(); if (currentValue48 == 1)  { digitalWrite(ACTUATOR_PIN48, HIGH);}
  else { digitalWrite(ACTUATOR_PIN48, LOW);}}

  CAYENNE_IN(VIRTUAL_CHANNEL50)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue50 = getValue.asInt(); if (currentValue50 == 1) { digitalWrite(ACTUATOR_PIN50, HIGH);}
  else { digitalWrite(ACTUATOR_PIN50, LOW);}}

  CAYENNE_IN(VIRTUAL_CHANNEL52)
  {CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  int currentValue52 = getValue.asInt(); if (currentValue52 == 1) { digitalWrite(ACTUATOR_PIN52, HIGH);}
  else { digitalWrite(ACTUATOR_PIN52, LOW);}}

*/

//    reading Input    ********************************************************************

CAYENNE_OUT(VIRTUAL_CHANNEL2)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL2, digitalRead(SENSOR_PIN2));
}

CAYENNE_OUT(VIRTUAL_CHANNEL3)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL3, digitalRead(SENSOR_PIN3));
}

CAYENNE_OUT(VIRTUAL_CHANNEL4)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL4, digitalRead(SENSOR_PIN4));
}

CAYENNE_OUT(VIRTUAL_CHANNEL5)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL5, digitalRead(SENSOR_PIN5));
}

CAYENNE_OUT(VIRTUAL_CHANNEL6)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL6, digitalRead(SENSOR_PIN6));
}

CAYENNE_OUT(VIRTUAL_CHANNEL7)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL7, digitalRead(SENSOR_PIN7));
}

CAYENNE_OUT(VIRTUAL_CHANNEL8)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL8, digitalRead(SENSOR_PIN8));
}

CAYENNE_OUT(VIRTUAL_CHANNEL9)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL9, digitalRead(SENSOR_PIN9));
}

//CAYENNE_OUT(VIRTUAL_CHANNEL10)
//{Cayenne.virtualWrite(VIRTUAL_CHANNEL10, digitalRead(SENSOR_PIN10));}

CAYENNE_OUT(VIRTUAL_CHANNEL11)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL11, digitalRead(SENSOR_PIN11));
}

CAYENNE_OUT(VIRTUAL_CHANNEL12)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL12, digitalRead(SENSOR_PIN12));
}

CAYENNE_OUT(VIRTUAL_CHANNEL13)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL13, digitalRead(SENSOR_PIN13));
}

CAYENNE_OUT(VIRTUAL_CHANNEL14)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL14, digitalRead(SENSOR_PIN14));
}

CAYENNE_OUT(VIRTUAL_CHANNEL15)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL15, digitalRead(SENSOR_PIN15));
}

CAYENNE_OUT(VIRTUAL_CHANNEL16)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL16, digitalRead(SENSOR_PIN16));
}

CAYENNE_OUT(VIRTUAL_CHANNEL17)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL17, digitalRead(SENSOR_PIN17));
}

CAYENNE_OUT(VIRTUAL_CHANNEL23)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL23, digitalRead(SENSOR_PIN23));
}

CAYENNE_OUT(VIRTUAL_CHANNEL25)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL25, digitalRead(SENSOR_PIN25));
}

CAYENNE_OUT(VIRTUAL_CHANNEL27)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL27, digitalRead(SENSOR_PIN27));
}

CAYENNE_OUT(VIRTUAL_CHANNEL29)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL29, digitalRead(SENSOR_PIN29));
}

CAYENNE_OUT(VIRTUAL_CHANNEL31)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL31, digitalRead(SENSOR_PIN31));
}

CAYENNE_OUT(VIRTUAL_CHANNEL33)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL33, digitalRead(SENSOR_PIN33));
}

CAYENNE_OUT(VIRTUAL_CHANNEL35)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL35, digitalRead(SENSOR_PIN35));
}

CAYENNE_OUT(VIRTUAL_CHANNEL37)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL37, digitalRead(SENSOR_PIN37));
}

CAYENNE_OUT(VIRTUAL_CHANNEL39)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL39, digitalRead(SENSOR_PIN39));
}

CAYENNE_OUT(VIRTUAL_CHANNEL41)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL41, digitalRead(SENSOR_PIN41));
}

CAYENNE_OUT(VIRTUAL_CHANNEL43)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL43, digitalRead(SENSOR_PIN43));
}

CAYENNE_OUT(VIRTUAL_CHANNEL45)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL45, digitalRead(SENSOR_PIN45));
}

CAYENNE_OUT(VIRTUAL_CHANNEL47)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL47, digitalRead(SENSOR_PIN47));
}

CAYENNE_OUT(VIRTUAL_CHANNEL49)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL49, digitalRead(SENSOR_PIN49));
}

CAYENNE_OUT(VIRTUAL_CHANNEL51)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL51, digitalRead(SENSOR_PIN51));
}

CAYENNE_OUT(VIRTUAL_CHANNEL53)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL53, digitalRead(SENSOR_PIN53));
}

#11

thanks now it works.

I can change x and y in:

int x32;
int x34;

CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %u”, request.channel, getValue.getId(), getValue.asInt());
switch (request.channel) {
case 32 :
x32 = getValue.asInt();
Serial.println(x32);
if (x32 == 1) {
digitalWrite(ACTUATOR_PIN32, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN32, LOW);
}
break;
case 34 :
x34 = getValue.asInt();
Serial.println(x34);
if (x34 == 1) {
digitalWrite(ACTUATOR_PIN34, HIGH);
}
else {
digitalWrite(ACTUATOR_PIN34, LOW);
}
break;
}
}

to avoid confusion by associating the variables with the output addresses?