Reed switch as input device on pi3 with cayenne

Thank you for your help! Got it working!

Excellent to hear!

Don’t forget to enter your project in the contest. Especially now that it is working :wink:

Even if you don’t enter, we would love to see pictures.


Another question, if you don’t mind? Is there a way to make a button a momentary event instead of a full on-off switch?
When I toggle the button on the iphone dashboard, I’d like it to be like pushing the garage door openener button rather than turning on and off a light switch. I will obviously have to remember to push the button twice with the current situation so that the relay ends up “off” again - I fear that if there is a network error or if I just forget, I will leave the relay controlling the garage door in the “on” position (for who knows how long) and I don’t know what deleterious effect this would have on the opener unit itself. Thanks again.

Great question!

This subject has been brought up before,

But it has been almost 3 weeks since we’ve heard anything from the mothership (@bestes) on this subject, so its good to remind him that there is still a concern.


@bmeriwether tutorial for digital input feedback.

Great question, and a totally valid use case that we want Cayenne to be able to handle!

So you brought up two really good points.

A momentary type push button

Ian linked to the topic that was already brought up, so we’re aware and it’s in our product backlog. We do have plans to improve this. We need to make some changes that will take time though. At least as of now, this is farther down the road map than other features, such as the timer functionality below.

Timer Functionality

Set a predetermined time for an actuator to turn on/off. For example, you would be able to set the actuator to turn on for 3 seconds and then turn off. You can read about it (linked below) and please offer your input as we are using the conversation to help spec out the feature.

FYI, I’ve have been working on a similar issue with my garage door. After researching timing and latching relays the light went on. I added a generic relay actuator (named Garage Door Opener) then added a new trigger event ( When the Garage Door Relay is On, Then turn the Garage Door Relay Off). Within seconds of the relay turning on, the logic turns it back off. This seems to work pretty well until some timers are added. By the way, I Love this Cayenne Product. Hope this helps.
Jason W.

1 Like

…there’s a contest? :slight_smile:



Is there a contest for next year?

August 2

…there’s a contest?


Win a Trip to Maker Faire 2016! Announcements

Hello Cayenne Community! In honor of Pi Day (March 14th…3.14), we are
sponsoring a Pi Day competition, in which the maker of the winning project
will provided an all-expenses paid trip* to demonstrate their project in
the Cayenne booth at Maker Faire San Francisco on May 21-22. To enter:
Build a Raspberry Pi project using any variety of sensors, actuators, and
extensions. Incorporate Cayenne features such as the customizable
dashboard, scheduling, and triggers & alerts. Provide a 150-w…

Meh- I live in the Bay Area. I’ll crash the party! :slight_smile:

Probably. There will likely be more contests upcoming too. :slight_smile:

I have an issue with my magnetic switch. When I have the garage door up, the sensor on my dashboard shows a status of 1 but it flickers to 0 and then back to 1 repeatedly. Any idea what iI need to do to fix it so that it’s constantly either 1 or 0 depending on the position of the door? I have the magnetic switch hooked up to the ground pin & pin 26. When the door is down it consistently stays at 0.


Are you seeing this in Cayenne? Have you tried making a python script to see if you get the same results? Sounds like you are getting interference from something. I’m currently dealing with the same thing on a project I’m working on. In my case the interference is coming from a 240v motor driven with a VFD. I’ve tried everything I could think of to get rid of it, next step is to use fiber optic cables. Maybe someone else has some ideas? @kreggly


How long is your wire between the Pi and the door?

Also, please share the part number of your magnetic sensor.



@kreggly The wire is about 15 feet from the Pi to the sensor on the door rail.

Here is the model I have from Amazon.


@adam Yes its flickering within Cayenne, but only when the door is open. When its closed its acting as expected and returns a 0 status. I haven’t tried a python script yet, but i did have this same sensor hooked up and working using this door project but the sensor was being used as an analog input instead of digital. I’m sure that’s the issue since im using a GPIO pin.

Ok, so it is not a magnetic switch per say, it is a mechanical read switch that is engaged by a magnet.

You are relying on the the weak pull-up inside the Pi to maintain a high level. The capacitance of that long a run, plus the fact that 3 meters is pretty much the FM radio band, can Trump you :stuck_out_tongue:

What I would do is drop a 4.7K resistor from your input pin to the 3V3 rail, but I’d also put a small value resistor of around 330 ohms in series from your pin to your switch to snub interference.



1 Like

Thanks a lot for the help! :+1: I was finally able to break out the breadboard tonight and got it working, so i soldered it up on a prototyping board and have it all wired up.

I do have one additional question though - I am using a relay to control the garage door, but it doesn’t respond to only clicking the button once. What I mean by that is if I hit the button to open the door, you can hear the relay click and the door moves. If you hit the button again the relay opens up and nothing happens, so you have to hit it a third time and then the door will then move. Is there anyway to make the relay close/open in one button press so that the 2nd time I hit the button (on the dashboard) it makes the door move?

A little background on the setup, I have a wire from my Pi’s GPIO spliced into the wire that was run from my garage door wall button to the door motor unit and when they are connected the door will go up or down, depending on the last movement.



You can create whatever sequence you want in a virtual function triggered by a button change. I have an example on here using the pulse () function of the timer library so you don’t need to be stuck using delays.