Open Apartment and Condo Doors Over the Web with your Smart Phone

Like many buildings, the building we live in has a panel at the main entrance which allows guests to call their hosts.  The guest initiates the call by looking up and dialing a apartment specific buzzer code, and the host can remotely unlock the front door by dialing 9 on their phone.

Occasionally, we’ve had the need for an extra set of keys when guests are visiting.  Given the ubiquity of smart phones, I’ve thought: Wouldn’t it be great to build a web interface which would essentially pick up the phone and dial 9, permitting entrance to the building without a set of keys?

The easiest way to do this was to write an application that uses an analog modem, which can detect a ring, pick up the phone, and generate tones.  Finding a suitable modem was the hardest part, given that there are so few applications for analog modems since the widespread use of broadband Internet in the late 1990s.  Further complicating things was I was looking to use a Raspberry Pi – this meant I needed a modem with a USB interface that works with Linux.  From my research, the  TRENDnet TFM-561U modem seemed to be the best fit for this purpose – testing has since confirmed it works great.

Lock and Key - Admin Screen
Lock and Key – Admin Screen

I wrote the application itself in NodeJS.  Using the administrative page (behind a firewall) the Host sets up a password, has the option of adding a note, and must set dates for when the password starts and stops working.  Note that there’s no login – it’s hard enough to remember a password, let alone the corresponding login.  The passwords are stored hashed (using bcrypt) – it’s assumed that there are very few logins setup, so when the guest logs in, the password they enter is compared against the hash of every password in the system.

Lock and Key - Public Screen
Lock and Key – Public Screen

The Internet facing, or guest page, is simply a passphrase box.  When a guest enters a correct password, the system will wait for a “ring”  (for up to 5 minutes by default).  The guest can then dial the buzzer code.  When the modem detects the ring from the main entrance, the application will instruct it to answer the phone, dial 9, and hang up.  The building’s entry system will then unlock the door, permitting the guest to enter.

Requirements:

  • I’ve only tested with my primary PC (Ubuntu Linux / Intel x86)
  • Node runtime
  • I’ve only tested with a TRENDnet TFM-561U modem
  • I’ve only tested in my building

Setup and Run:

  1. Get the code! You can download from GitHub, or clone the repository https://github.com/raudette/lockandkey.git
  2. Install Node and the required modules.  In an Ubuntu Linux environment, this can be done as follows:
    sudo apt-get install nodejs
    sudo npm install express sqlite3 bcrypt-nodejs node-validator fs body-parser serialport
  3. You may also want to look at the PM2 process manager for Node – it makes it really easy to automatically start Node applications on boot up, and a dynamic DNS service such as the one provided by dyn.com to access your
  4. Review the lockandkeyconfig.json configuration file.
    1. port: The port used by the public web interface (configure your router to expose this port to the Internet)
    2. adminport: The port used by the administrative interface.  This is used to configure accounts
    3. unlocktimeout: Length of time, following a successful login, for which the system will pick up the phone and dial 9.
    4. modemmanufacturerstring: The string used to identify the modem which should be used by the application.  Use the Linux dmesg command after plugging in a USB modem to see the manufacture string associated with your device. Use Conexant for the TRENDnet TFM-561U.
  5. You can start the program by running
    node lockandkey.js
  6. With the default values, to setup accounts, you can access the administrative interface at:
    http://localhost:3001/
    and the door opening interface at:
    http://localhost:3000/

Complete source code and build details: lockandkey.zip

Future Improvements:

I can see this particular project being useful to others – let me know if you have any suggestions.  For example, let me know if there is interest in a Raspberry Pi SD card image, a simple phone Android/iPhone app to avoid book marking the website, improvements to security, mandatory HTTPS, or eliminating the need for a dynamic DNS service in a home environment.

Update – March 27, 2017

One of my friends needed a solution to provide his clients with access to a condo unit he is renting over Airbnb.  He’s now using this solution, which is running on a Raspberry Pi.

One thought on “Open Apartment and Condo Doors Over the Web with your Smart Phone”

  1. I’m about to solve this exact same problem and stumbled upon your blog by fluke. My TFM-561U just arrived and I’m hoping to get it working with a Raspberry Pi for low power consumption.

    I like how you went a kinda of secret port knocking technique. I’m thinking of using a push type notification so that my phone can be alerted when someone has buzzed in.

    Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *