Trigger does not work with temperature


#1

T
Trigger does not work
it should turn on the light switch if the temperature was higher than 23 C
But nothing happens. I have already tried several possibilities


#2

is your trigger counter incrementing? have you hit the trigger limit?


#3

Hello

what do you mean with “incrementing” ?

Yes, trigger limit is done


#4

in trigger tag below the trigger, there is counter which shows the number of times the trigger has run.


#5

the trigger tag shows “0”


#6

that either means that you have not used the correct data type or has made some error while adding the trigger. can you share the code you are using.


#7

How can I send a screenshot ?
In the arduino code I haven’t done anything


#8

you can copy and paste the code here.


#9

which code ?


#10

the code which you uploaded on Arduino.


#11

I will copy it some hours later.
If I turned on the light switch manually, it would work.
The correct temperature is also shown on the mydevices.com site.
Does the trigger really depend on the arduino code?


#12

it depends on the data type.


#13

Which data type do I have to use ?


#14

#15

hello
here is the code:

#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <OneWire.h>
#include <DallasTemperature.h>
#include <CayenneMQTTEthernet.h>

//---usercode-password--//

#define SENSOR_PIN 2 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL1 7
#define VIRTUAL_CHANNEL 6
#define ACTUATOR_PIN 4 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define SENSOR_PIN2 7 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL2 5
OneWire oneWire(SENSOR_PIN);
DallasTemperature sensors(&oneWire);

void setup()
{
  Serial.begin(9600);
 pinMode(ACTUATOR_PIN, OUTPUT);
  Cayenne.begin(username, password, clientID);
  sensors.begin();

}

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

// This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL)
{
  // Send the command to get temperatures.
  sensors.requestTemperatures();
  // This command writes the temperature in Celsius to the Virtual Channel.
  Cayenne.celsiusWrite(VIRTUAL_CHANNEL, sensors.getTempCByIndex(0));
  // To send the temperature in Fahrenheit use the corresponding code below.
  //Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL, sensors.getTempFByIndex(0));
}
CAYENNE_IN(VIRTUAL_CHANNEL)
{
  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.
  digitalWrite(ACTUATOR_PIN, value);
}
CAYENNE_IN(VIRTUAL_CHANNEL1)
{
  // Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
  if (getValue.asInt() == 1) {
    digitalWrite(ACTUATOR_PIN, HIGH);
  }
  else {
    digitalWrite(ACTUATOR_PIN, LOW);
  }
}
CAYENNE_OUT(VIRTUAL_CHANNEL2)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL2, digitalRead(SENSOR_PIN2));
}

#16

can you PM me your email_id. when did you add this device? Have you set the trigger for VIRTUAL_CHANNEL2?


#17

Hello,

the email id is:

see screenshot


#18

can you PM me you emai_id?


#19

do you mean the password ?


#20

i do not see your email_id in any of your posts.