Thanks for you, Please see the below MQTT code that I used, I put both the virtual and actual pins as 13 to exclude any misunderstanding from my side to the issue:-
It doesn’t work to trigger the pin 13 to HIGH:-
Cayenne Valve Switch Example
This sketch shows how to set up a Valve Switch with Cayenne. The Arduino cannot
drive a valve because it does not output the needed current. As a result, in order
to make this example work, various electronic components are necessary to connect
the valve. To keep it simple, you will need an external power source, transistor (eg. TIP120),
diode (eg. 1N4001), and a 1k ohm resistor. Alternatively you could also use a relay switch to
connect the valve.
The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.
- In the Cayenne Dashboard add a new Valve Switch widget.
- Select a virtual channel number for the widget.
- Set the VIRTUAL_CHANNEL value below to virtual channel you selected.
- Set up your valve schematic and attach it to a digital pin.
- Set the ACTUATOR_PIN value below to the digital pin number you selected.
- Set the Cayenne authentication info to match the authentication info from the Dashboard.
- Compile and upload this sketch.
- Once the Arduino connects to the Dashboard you can use the widget button to open and close the valve.
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “----";
char password = "";
char clientID = "----**”;
#define VIRTUAL_CHANNEL 13
#define ACTUATOR_PIN 13 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
Cayenne.begin(username, password, clientID);
// This function is called when data is sent from Cayenne.
int value = getValue.asInt();
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL, ACTUATOR_PIN, value);
// Write the value received to the digital pin.