adding a relay in the MQTT arduino is not easy for me.
I tried in some ways. including the cayenn example.
it is adding but not working. carries the writing but remains as unacceptable.
Cayenne Generic Digital Output Example
This sketch shows how to set up a Generic Digital Output with Cayenne.
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 Generic Digital Output widget.
- Select a virtual channel number for the widget.
- Set the VIRTUAL_CHANNEL value below to virtual channel you selected.
- Attach an output actuator (e.g. an LED) to a digital pin on your Arduino.
- Set the ACTUATOR_PIN value below to the pin number you used when connecting your output actuator.
- 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 send digital values.
#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 = “0000”;
char password = “0000”;
char clientID = “00000”;
#define VIRTUAL_CHANNEL 8
#define ACTUATOR_PIN 24 // 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.