pawl / Chinese-RFID-Access-Control-Library

A python library for interfacing with one of the most common RFID Access Control Systems sold in China.
MIT License
43 stars 13 forks source link

Chinese RFID Access Control Library

This library allows python to control one of the most common RFID Access Control Systems sold in China. Now you can integrate an access control system with your software to do things like remove an user when they haven't paid their bill.

The goal of this project is to provide the ability to automate an inexpensive, out-of-the-box RFID Access Control solution. This is especially made for businesses that rely on access control + monthly billing (hackerspaces, makerspaces, and gyms).

Main Features

Hardware Requirement

This library currently only works with a single type of controller which goes by a wide variety of model numbers. The controller can be found by searching for "TCP access control" on Ebay, Aliexpress, and Amazon. It costs around $30-85 (depending on the number of doors). You can know which one to buy by looking for one that looks like this:

alt tag

One of the awesome things this controller has is a web interface. You can also add users, remove users, view logs, and change settings manually through that interface. Pictures of the interface are available here: http://imgur.com/a/Mw04Y

RFID Card Number Explanation

alt tag

There are usually two sets of numbers on the 125kHz EM4100 RFID cards. Key fobs usually only have a single 10-digit number.

The number on the right, "comma format":

The number on the left, "10-digit format":

My usage example below shows an example of a function which converts the 10-digit format to the comma format, and vice versa.

Usage

Install:

pip install Chinese-RFID-Access-Control-Library

Add user (using 10-digit format RFID number):

from rfid import ten_digit_to_comma_format, RFIDClient

ip_address = '192.168.1.20' # IP address of the controller
controller_serial = 123106461 # serial number written on the controller
client = RFIDClient(ip_address, controller_serial)

badge = ten_digit_to_comma_format(11111111) # badge number needs to be converted to "comma format"

client.add_user(badge, [1, 2]) # add privileges for door 1 & 2

Remove user (using 10-digit format RFID number):

from rfid import ten_digit_to_comma_format, RFIDClient

ip_address = '192.168.1.20' # IP address of the controller
controller_serial = 123106461 # serial number written on the controller
client = RFIDClient(ip_address, controller_serial)

badge = ten_digit_to_comma_format(11111111) # badge number needs to be converted to "comma format"

client.remove_user(badge)

Open door #1:

from rfid import RFIDClient

ip_address = '192.168.1.20'
controller_serial = 123106461
client = RFIDClient(ip_address, controller_serial)

client.open_door(1)

Running Tests

python setup.py test

TODO

Special Thanks