---
title: 'Doorhacking: Opening a Door With Your Cellphone'
canonical: https://0110.be/posts/Doorhacking%3A_Opening_a_Door_With_Your_Cellphone
markdown_url: https://0110.be/posts/Doorhacking%3A_Opening_a_Door_With_Your_Cellphone.md
id: 71
published_at: '2010-04-22T00:00:00Z'
updated_at: '2013-12-05T18:19:15Z'
author: Joren
tags:
- name: 0110.be
  markdown_url: https://0110.be/tags/0110.be.md
- name: Code
  markdown_url: https://0110.be/tags/Code.md
- name: Hackerspace Ghent
  markdown_url: https://0110.be/tags/Hackerspace%20Ghent.md
- name: Projecten
  markdown_url: https://0110.be/tags/Projecten.md
---

# Doorhacking: Opening a Door With Your Cellphone

**The problem:** There is a group of people that want access to [Hackerspace Ghent](http://0x20.be) but there is only one remote to open the gate.

**The solution:** Build a system that reacts to a phone call by opening the gate if the number of the caller is whitelisted.

**What you need:**

-   A [BeagleBoard](http://beagleboard.org/) or some [BeagleBoard alternative](http://beagleboard.org/breeds) with a Linux distribution running on it. Any server running a unix like operating system should be usable.

-   A Huaweii e220 or an alternative GSM that supports (a subset of) AT commands and has a USB port.

-   A team of hackers that know how to solder something togeher. E.g. The hardware guys of hackerspace Ghent.

-   A "python script":\[gatekeeper.py\] that reacts to calls.

**The Hack**: First of all try to get caller id working by following the [Caller ID with Linux and Huawei e220 tutorial](http://0110.be/artikels/lees/Caller_ID_with_Linux_and_Huawei_e220). If this works you can listen to the serial communication using [pySerial](http://pyserial.sourceforge.net/) and react to a call. The following python code shows the wait for call method:

\`\`\`ruby\
def wait_for_call(self):\
self.data_channel.open()\
call_id_pattern = re.compile('.**CLIP.**"\\+(\[0-9\]+)",.\*')\
while True:\
bytes = self.data_channel.inWaiting()\
buffer = self.data_channel.readline(bytes)\
call_id_match = call_id_pattern.match(buffer)\
if call_id_match:\
number = call_id_match.group(1)\
self.handle_call(number)\
\`\`\`

The `handle_call` method ... handles the call.

The second thing that is needed is [a way to send a signal from the beagle board](http://blog.makezine.com/archive/2009/02/blinking_leds_with_the_beagle_board.html) to the remote. Sending a signal from the beagle board using Linux is really simple. The following bash commands initialize, activate and deactivate a pin.

\`\`\`ruby\
echo 168 \> /sys/class/gpio/export\
echo "high" \> /sys/class/gpio/gpio168/direction\
echo "low" \> /sys/class/gpio/gpio168/direction\
\`\`\`


![](https://0110.be/files/photos/71/setup.jpg)

![](https://0110.be/files/photos/71/remote.jpg)

![](https://0110.be/files/photos/71/remote_2.jpg)

- [gatekeeper.py](https://0110.be/files/attachments/71/gatekeeper.py)
