With Raspberry pi based door controller,never get locked outside your apartment

 Have you ever locked yourself out of you apartment? I always do such things. What a scatterbrain! I bet there are many of you have had , too. But you can rest assured now; our savior has come to us. a guy who has suffered the same experience many times created a project——Raspberry pi and web based door control to get rid of the awkward situation.

Raspberry_Pi controlled door2

He decided to make a keyless entry system. He looked for a project to use a Raspberry Pi in for awhile, and this seemed like a good fit.

Here is how to make it.

The basic set up was pretty straight forward, a buzzer, so you may be able to switch on the Buzzer through your LAN.

 Since the buzzer is medium voltage AC, you can use a relay as the switch. He went with a g5le-1-g dc5. The important stats were that it supported the voltage and current the buzzer used, and that the coil was 5V and draws about 80 mA. Unfortunately, the GPIO pins on the Raspberry Pi are 3.3V and can only output a max of about 16mA. This meant a transistor must be used to drive the relay. A bunch of 2N4401 is what can be used. The following is the circuit:

Raspberry_Pi controlled door1 

Details on this circuit can be found here.

The basic theory of this circuit is that a small current will go from the input through the base of the transistor and out the emitter to ground. This current allows a much larger current to flow from the transistors collector to ground, driving the coil of the relay. Rb should be chosen so that the current coming from the input is within the Raspberry Pi’s GPIO spec, but the amplified current going through the coil can still close the relay.

 Since the gain of the transistor hfe is at least 20, you just need a current through the base of 4mA. This meant that you needed an Rb between 637 and 160 Ohms.

Initially test this out on a breadboard and confirmed that the relay closed when you connect the input to 3.3V (or 5V for that matter).

 Then solder the circuit together onto a protoboard.

Raspberry_Pi controlled door3

Use jumper cables to connect this board to the Raspberry Pi.

 To get the hardware working, you should also work on the software.

To control the GPIO pins you should follow the guide found here. Basically install wiringPi to provide the control interface. To figure out what pins on the header to use, look at here .  Since you need 5V, GND, and a GPIO pin you can chose pins 4, 6, and 8 and directly connect a 3 pin jumper. It is important to note that the GPIO pin (pin 8 on the header) is named pin 15 in wiringPi.

 At this point you are able to confirm that the Raspberry Pi is able to control the relay when connected to the circuit. Mount the protoboard to the Raspberry Pi board with a spacer and connect the whole thing to the buzzer.

 You may need to add some extra wires to the buzzer and connect them to the relay.

Raspberry_Pi controlled door2

Lastly, work on setting up the relay to be able to be controlled through the LAN. Use a small WiFi dongle for the board, so it was already connected to your network. set up apache and wrote a simple perl script to trigger the relay.

Raspberry_Pi controlled door5

With the script saved in /usr/lib/cgi-bin/you just need to connect to your LAN and go to the right URL for the door to open for 10 seconds. You can also do the whole thing by making a Python servlet, or any number of other ways, but this was quick and easy.

 Since the URL would only be available from you LAN, there is at least a minimum level of security. Though you would probably need to add some authentication if you ever want to make the Raspberry Pi’s web server accessible over the internet.

 Now if you forget/grab the wrong keys you can get back in with your phone, or in the worst case you can find someone to help to unlock the door without needing to resort to a lock smith.

Aweb based door controller with Raspberry pi has complete. Go and make one for your own.

 

For the original article, refer to  http://www.robopenguins.com/hardware/web-based-door-control/

Written By

More From Author

You May Also Like