Any way to get a timed button?


I looking forward to the same, maybe adding even logic gates to cover almost all options:

  • AND
  • OR
  • NOT
  • NAND
  • NOR
  • XOR
  • XNOR



Access to some virtual variables in a py sandpit would solve it all for me.
Once you have python than anything can be scripted up.
Nearly all my practical IoT projects connect to the Pi over radio.
~ Andrew


MQTT support is very close.

Then I’m assuming you just do something like this, with some sort of authentication, and bob’s your uncle.




Yes, with a local mqtt server you can run python scripts based on the message received :grin:


As Bill says, if you want the client side behavior to be predictable, then a function within the device should handle the off.

Here’s what I was thinking. If you guys handle a button that resets itself graphically, and offer up some sample code when adding the object, then golden.

The pulse function looks like it would do the trick.

int pulse(int pin, long period, int startingValue)




A few lines of py in a sand box and ability for maker / programmers / students to home bake or be challenged with real world IoT timing issues via some virtual generic I/O variables would be great :slight_smile:
~ Andrew


Now that MQTT is out we can easily do timed buttons with a local MQTT server. I’ll try to get this working over the weekend and post a write up.


I had a chance to test the pulse function of the Timer library, and it works as expected. Give it a try.

Every time you toggle the virtual button V0, the LED turns on, and then off after 1 second.


//#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

#include <Timer.h> //
#include <WiFi101.h> //
#include <CayenneWiFi101.h> //

#define LED 2
Timer t;

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "your_token"; 
// Your network name and password.
char ssid[] = "your_ssid";
char password[] = "your_pw";

void setup()
  Cayenne.begin(token, ssid, password);

void loop()

  t.pulse(LED, 1000, 1); //pin, time(milliseconds), initial state

There's a need for a relay button that returns to the original position after a chosen time limit
Reed switch as input device on pi3 with cayenne
Activate GPIO in Monostable mode (Timer) possible?
Open and close a damper
Irrigation cycle by pressing a button
Push Button Support
Please Add Delay & Push Button Support
Trouble with turning off a pin using millis

Hi Bestes,

I hope you are very well, do you have any update with this feature?

Thanks in advance.


I have my garage door controlled by my Pi and i did the same thing a few weeks ago to reset the relay and it works perfectly.


Gonna try this next…
Is that code for Pi or Arduino?
I need the ArduinoIDE to do this-
I’m a programming ignoramus, but I try to understand.


That’s arduino code


Hi, that was a really nice idea, I will try it in my ESP8266 and let you know.


looking forward for this feature, and location fencing :slight_smile:


Yeah, this is one of big features on our roadmap and I am also very excited for it. The design is done, we are waiting for some resources to free up to work on this :slight_smile:



any updates on this topic? i’m currently trying to use raspberry pi zero/cayenne to remotely reset or power on/off a PC directly on the motherboard header. using a trigger that turns the reset relay output back off after it is triggered on works, but when it comes to powering the PC on, the trigger and relay don’t close and re-open quickly enough. what ends up happening is that the power on signal is sent, is held to long, and once released, the PC powers back off.


Hmm I see. We’re planning on doing this feature in the next months :slight_smile:



If you scroll up a little bit to @kreggly’s post you can see his code there. It uses the Pulse function.


I see that, thank you. I will try to dig deeper on how to configure that into a usable interface. My knowledge of Pi, Cayenne and coding in general is very minimal, but I might be able to figure it out with a little google-fu. Thanks and I’ll get back if I need further guidance.


I’ve had a chance to review @kreggly 's post and it appears that it’s for arduino. I’m trying to perform a momentary contact closure from a pi wireless zero. Please correct me if I misunderstood.