thedarkknight228
Posts: 2
Joined: Thu Oct 24, 2013 12:30 pm

Raspberry Pi and Door Sensor

Thu Oct 24, 2013 12:34 pm

Hi all,

I just wanted to ask a question to see if this was possible. I am attaching a door sensor to a door which will be wired to a raspberry pi. I need the Pi to send data to my database every time the door opens. Is this possible to do?

If so does anyone know what type of information is triggered in the Pi when the door is opened?

Thanks in advance.

User avatar
ZacharyI123
Posts: 263
Joined: Sun Jun 17, 2012 1:09 pm
Location: Ilford, Essex
Contact: Website

Re: Raspberry Pi and Door Sensor

Thu Oct 24, 2013 7:39 pm

thedarkknight228 wrote:Hi all,

I just wanted to ask a question to see if this was possible. I am attaching a door sensor to a door which will be wired to a raspberry pi. I need the Pi to send data to my database every time the door opens. Is this possible to do?

If so does anyone know what type of information is triggered in the Pi when the door is opened?

Thanks in advance.
Can you tell us more about your door switch? Is it a simple reed switch? How have you connected it? Straight to the GPIO?

If so, you will need to keep checking the state of the reed switch. When you detect that the state is not the same as the last time you checked, the door has clearly opened or closed, and you can do what you want in code.
Don't be mean, I'm only thirteen 8-)

kghunt
Posts: 383
Joined: Sun Mar 04, 2012 9:28 am

Re: Raspberry Pi and Door Sensor

Thu Oct 24, 2013 7:51 pm

Use an interrupt instead of constant checking.

beardedgeek
Posts: 3
Joined: Sat Apr 20, 2013 11:21 am

Re: Raspberry Pi and Door Sensor

Mon Dec 02, 2013 11:19 pm

kghunt wrote:Use an interrupt instead of constant checking.
How would you do it this way rather than constantly checking?

User avatar
ZacharyI123
Posts: 263
Joined: Sun Jun 17, 2012 1:09 pm
Location: Ilford, Essex
Contact: Website

Re: Raspberry Pi and Door Sensor

Tue Dec 03, 2013 7:36 am

beardedgeek wrote:
kghunt wrote:Use an interrupt instead of constant checking.
How would you do it this way rather than constantly checking?
You probably want to use the built in GPIO interrupt of the RPi.GPIO framework: http://pythonhosted.org/RPIO/rpio_py.html
Don't be mean, I'm only thirteen 8-)

User avatar
williamhbell
Posts: 291
Joined: Mon Dec 26, 2011 5:13 pm
Contact: Website Twitter

Re: Raspberry Pi and Door Sensor

Fri Dec 27, 2013 8:47 am

In case it is useful, try looking at:
http://www.raspberrypi.org/forum/viewto ... 90#p475190
The logic needs to be flipped if you're interested in checking when the door is opened.

Regards,

Will

Piminiuser
Posts: 73
Joined: Wed May 30, 2012 1:15 pm

Re: Raspberry Pi and Door Sensor

Wed Jan 08, 2014 8:36 pm

I used wiringpi with command gpio wfi 4 rising (gpio 4) to check if it's up or down. For my doorbell project: http://raspberrypihelp.net/tutorials/38 ... e-doorbell

Return to “Staffroom, classroom and projects”