Timing the trigger

Hello everyone. I would need a lot of help. I realized the simple project with Arduino and the temperature sensor Dallas.ho the need to activate the alarm trigger with a certain time tolerance. example if the Dallas sensor senses a temperature below 5 degrees for more than one hour snaps the trigger. you can do what? Thanks

Hi marcoscalet,

In order to accomplish this sort of timed trigger with Cayenne you’ll need to wait for a couple of upcoming features that we’re going to introduce, like triggers allowing multiple conditional statements, or triggers being able to run custom Python code.

Both of these are on the product roadmap which we’re really starting to dig into now that the MQTT API has been released. I’ll update this thread when the feature set which allows you to accomplish this use case is available.

You can do this with an Arduino, we just need to create a manual trigger. In your loop function check the temp and if it’s in the range for your trigger call a function. Below that check if the timer is up and if it is execute your code. Doing it this way avoids using delays which stop all execution of the rest of the code.

if (temp < lowrange || temp > highrange){ //change lowrange and highrange to your actual values

Below that add an if statement to check if the timer is up

if (millis() - timer >= time){ //change time to your time length in miliseconds
  //add your code to do when the timer is up

Outside the loop function create your trigger function

void triggerfunction(){
  timer = millis();
  //you can add other code here too but this starts the "timer"

thanks for answers. so I might consider including a generic digital widget where if the value changes from 0 to 1 triggers the trigger? then I would have a normal temperature of a widget which I read the temperature in live and another in which I read only 0 and 1? It might work?

Using a virtual pin is a good way to create a trigger, however currently there are no timed triggers so you will have to take care of the timing part yourself.