Okay, thats fine, board connects with cayenne and i can see thae values that i need.
I’ve a button, for turn on/off led from cayenne and value widget for see the led state.
My problem, is that when i set up a trigger only works when its refere to button, if i set it for the value isnt works
delete the widget associate with channel 2 from the cayenne dashboard. then change Cayenne.virtualWrite(2, i) to Cayenne.virtualWrite(2, i, "digital_sensor", "d") . Next delete the trigger from the cayenne dashboard. Now, upload the code which will generate a new two state widget. Add it by clicking on the +. Now add trigger to this widget.
Perfect!, great shramik… perfect. But, right now i’ve a doubt… Before, the status change was inmediatly, but right now, I need chage 2 times LED_switch (web button) for change value.
I explain:
push one time cayenne button: Phisical LED change (great!), but Led_status value not (bad)
push again cayenne button: Phisical LED change (great!), Led_status value change
The value change at the second time.
And another… I’m reciving notifications each X secons while conditions is true (Led:status value = 1 > notf…notf…notf…) every time. How I can change it for only recive notifiactions one time (only with value change)?
place publish line in main loop but only publish once. Use some kind of variable to set true or false the case to send the data only once. Something like this.
int previousState = -1;
int i = -1;
void loop()
{
Cayenne.loop();
if (i != previousState) {
Cayenne.virtualWrite(2, i, "digital_sensor", "d")
previousState = i;
}
}
Use the first code you submitted. With the change Shramik suggested. This will update the led status when changed without extra pushes for the mqtt server
Cayenne.virtualWrite(2, i, “digital_sensor”, “d”)
In
Cayenne default IN