This is the post regarding the Python-R305 package.
R305 is a very common finger print sensor. It is quite cheap, has a storage capacity of 250 fingerprints.
I came across this module about one and a half year ago. I had to use it in a small project with Raspberry-Pi. At that time I couldn’t find a python API that covers all of the functionality provided by the module.
So I started implementing the instructions from R305’s datasheet one by one in python.
For almost a year this project had a whole lot of crappy code and a lot of people who were trying to use it had a really bad time with it, but now everything is good; the code is okay (not very good, but understandable) and the documentation is also in place.
So let me give you a quick introduction to R305 and Python-R305 package.
The R305 module operates over UART or in other words a Serial port. To perform any operation with R305 you have to put a frame of bytes (command packet) on the serial port and in response to that you get another frame of bytes (response packet) from the module which contains the status of whether the command is executed successfully or not and few other things.
|Header||Addr||Package Identifire||Package Length||Package Content||Checksum|
|2 bytes||4 bytes||1 byte||2bytes||Data||2 bytes|
|Header||Addr||Package Identifire||Package Length||Confirmation Code||Response Data||Checksum|
|2 bytes||4 bytes||1 byte||2bytes||Data||Data||2 bytes|
The Command/Instructions codes can be found here
The Response/Confirmation Codes can be found here
What Python-R305 does is to generate the command packets for you and parse the response.
Connect the fingerprint module with USB to TTL convertor, the pin-out of R305 fingerprint module is as follows.
If you are using Raspberry/Orange/Banana Pi or any other board like that; you can use Tx and Rx Pins of the board itself instead of using USB to TTL.
To install the python package
$ pip install R305
To store the fingerprint into the module
from r305 import R305 import sys device = sys.argv # the serial port to which the module is connected baudrate = sys.argv # the default baudrate for this module is 57600 dev = R305(device, baudrate) def callback(data): """ This function is called when you are instructed to put the finger on the module the second time. """ x = raw_input(data) result = dev.StoreFingerPrint(IgnoreChecksum=True, callback=callback) print(result)
To search fingerprint in the module
from r305 import R305 import sys device = sys.argv # the serial port to which the module is connected baudrate = sys.argv # the default baudrate for this module is 57600 dev = R305(device, baudrate) result = dev.SearchFingerPrint() print(result)
Things to be implemented.
- Method to Create a .PNG from a character file of the fingerprint.
- Method for changing the default Address of the module.
- Method for changing the baud rate of the device
I’ll try to implement these things as soon as possible. If anyone has already implemented any of these functionalities already, feel free to send a PR; I would be more than happy to merge it.
Special thanks to
Nikhil the guy who forced me to use R305 with python.
Reserved-bit for making a new module available at the makerspace when I accidentally burnt my own 😅, So now on I’ll work on this project at Reserved-bit.