My Analogue sensor trigger is not working in Cayenne


#21

also PM me your email_id


#22

#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

char ssid = “”;
char wifiPassword = " ";

char username = " ";
char password = " ";
char clientID = " ";

int inPin = 5;
int vref = 3;
int Clm35 = 0;
int Press_bar = 0; //analog voltage reference ( 0- 3.3 volts ) sur le esp8266-E12 c’est 1 volt

int pressure;
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
pinMode(5, INPUT_PULLUP); // pin input
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
}

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

CAYENNE_OUT(0)
{
int val = digitalRead(inPin); // read the input pin
delay(100);
Cayenne.virtualWrite(0 ,val);
}
CAYENNE_OUT(1)
{
float Press_bar = (((analogRead(A0)*10)/ 1023) - 0.5); // read adc input pin = 30mv/mbar
// la valeur 0.6 is correction of pressure
Cayenne.virtualWrite(1 ,Press_bar, “analog_sensor”, “null”);
}

CAYENNE_IN(6)
{
int currentValue = getValue.asInt();
if (currentValue == 1)
{
//do whatever you want when you turn on the button on cayenne dashboard
digitalWrite(2, HIGH);
}
else
{
//do whatever you want when you turn off the button on cayenne dashboard
digitalWrite(2, LOW);
}
}
CAYENNE_IN(8)
{
int currentValue = getValue.asInt();
if (currentValue == 1)
{
//do whatever you want when you turn on the button on cayenne dashboard
digitalWrite(4, HIGH);
}
else
{
//do whatever you want when you turn off the button on cayenne dashboard
digitalWrite(4, LOW);
}
}


#24

i checked your account and there are 4 trigger out of which 3 are turned OFF and one which is ON has not run even once. so i guess you have not crossed the sensor set trigger value.


#25

I did cross the value many times but it is not triggering , I will send you screen shot of value above threshold value to trigger alarm


#26

the value is above threshold


#27

can you give it a try now?


#28

Other triggers are working fine , I intentionally turned off to check & verif this analogue trigger
Hope you got my point , ok sure


#29

Dear Now it worked
did you change any thing ?


#30

yup. i deleted the widget and re-added a new one. then added a new trigger for this widget.


#31

now that it is working you need to modify your code according to this post Sending MQTT messages within notification limit


#32

can you update this in my sketch and email me , it looks little confused
when you created new trigger - did you put the limits as before or any special settings , if i select analogue as unit then no reading appears


#33

the sketch from the topic is straight forward. you just need to make the changes required.


#34

OK Thanks Shramik , Great & enjoy Wish good day