but above code will always keep your led OFF, while will turn ON for very very little time. as once it is turn in
CAYENNE_IN(1)
{
digitalWrite(D2, getValue.asInt());
}
it will always turn OFF in main loop.
void loop() {
Cayenne.loop();
digitalWrite(D2, LOW);
so try this code and see if you trigger is working or not.
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
int relayPin = 4; // relay pin D2
// WiFi network info.
char ssid[] = "M";
char wifiPassword[] = "e";
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";
void setup() {
pinMode(D2, OUTPUT);
Serial.begin(115200);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}
void loop() {
Cayenne.loop();
}
CAYENNE_IN(1)
{
Serial.println("trigger activated");
}
open your serial monitor and check whether you are receiving the value on channel 1 when the trigger is activated. also you might want to change your code for PIR based on this Sending MQTT messages within notification limit or else you will hit the trigger limit for notification and it will stop,