Door Opener: Code and Documentation

The Code:

  1. Arduino #1: Controls the door. Accepts PIN numbers and RFID keys via HTTP. Checks PIN/RFID keys against MySQL server over HTTP. Code:
  2. Arduino #2: Controls the RFID reader. Passes any read RFID keys to Arduino #1 for processing. Code:
  3. PHP/MySQL: Stores the PIN numbers and RFID keys and all the logs of when the door was opened/closed and who did it. Code:
  4. Android Application: App you can install to open the door from your phone. Supports C2DM for push notification to mobiles when the door is opened. Code:

Important: If you wish to modify the Arduino code, please disconnect the working arduino and load new code onto a new arduino. This way if the code breaks you can always plug the old working arduino back in and our door system will continue to operate.

Arduino #1 Wiring Diagram:

can someone take a photo of it please?

Arduino #2 Wiring Diagram:

can someone take a photo of it please?

Opening door with PIN number from Web App:

  1. Member visits door open page:
  2. Member types in their unique pin number.
  3. Pin number is checked against c.php ( )
  4. If the PIN number is correct, and the user wishes to trigger the door (rather than checkin) then c.php will send a GET request to Arduino #1 like this: http://arduinos_ip_address:80/triggerdoor?pin=12345&go (where 12345 is users pin number)
  5. Arduino #1 will receive this request, grab the pin number out ( 12345 ) and then send it BACK to the web server ( see postback_server_door_trigger function ). It will send the PIN number in a URL like this: postback.php?door=open&trigger=1&pin=12345 ( postback.php is here: )
  6. postback.php will verify the pin number (12345) against the local mysql server and return a http status of 200 if the pin number is correct, or a http status of 40x if the pin number is wrong. (postback.php will also log this door open request in the system.)
  7. If a successful 200 http response is found by Arduino #1 then it will trigger the button on the door remote for 1 second which will open the garage door.
  8. The reed switch will break the Arduino #1 will detect this ( see check_door_state function ) and it will post this status change to the web server like this: postback.php?door=open or postback.php?door=closed

Opening door with RFID key:

  1. Member swipes their RFID key
  2. Arduino #2 reads this RFID key from the RFID reader.
  3. Arduino #2 passes this RFID key to Arduino #1 via HTTP request (like this: http://arduino_ip:80/triggerdoor?pin=RFIDKEYHERE )
  4. Arduino #1 waits for the response (http 200) and if it’s valid it will open the door (as explained above).


If you’d like to write your own door app, here’s the basic API:

IMPORTANT: you must be connected to the local wifi network in order for this API to work.

To trigger the door (ie: open / close, or stop halfway up or down) send your pin number to this URL:

  • Where XXXX is your 4 digit pin number
  • Y is either 1 or 2. 1 will trigger the door, 2 will “checkin”

Return status:

  • HTTP status of 405 will get sent if you have the wrong pin number.
  • HTTP status of 406 will get sent if you have an invalid pin (ie: no pin provided)
  • A normal HTTP status of 200 will return if the pin is correct and the door has been triggered. You’ll also get some string output that you can ignore.
  • HTTP status of 407 will get send if you have been banned (ie: too many incorrect attempts)

To get the door status as a string get this URL: