Write template on Fingerprint sensor R305/R307

Hi Guys,

Used the "show_fingerprint_template" function on adafruit library to get the fingerprint templates of fingerprint stored in the module...489byte each. However, i am unable to write these templates on other sensor. Motive is to avoid duplicate enrollmet of fingerprint on multiple sensor. Once I enroll on one device..I want to extract the template and write the same onto other sensors...let me know who this can be done.

have you explored the section 6 of the documentation?

Thanks for the documentation.
However for testing purpose...how can i use the serial monitor on arduino to directly type the commands and check weather the sensor responds in the way its intended?

nimit393:
how can i use the serial monitor on arduino to directly type the commands and check weather the sensor responds in the way its intended?

Well, by writing such a program... :wink:

(There are many test examples in the library)

Well...none of them are helpful in writing template back to device. Neither do i see that library has functions defined to get the part of the code working for writing a template.

nimit393:
Well...none of them are helpful in writing template back to device. Neither do i see that library has functions defined to get the part of the code working for writing a template.

sure, library might be incomplete but what is not helpful in section 6? you can extend the library...

6.2.3 Download the image: DownImage
Description: to download image from upper computer to Img_Buffer. Refer to 1.1.1 for more about the image buffer.

I am not aware how the library is sending out commands in hex...if you can let me know who I can directly type in commands in hex over serial, then that would be helpful in creating and extending the existing library for writing template.
In short if I can directly type serially, then i can observe how the sensor is reacting and verify weather the commands sent by my is correct or not.

nimit393:
I am not aware how the library is sending out commands in hex...if you can let me know who I can directly type in commands in hex over serial, then that would be helpful in creating and extending the existing library for writing template.

It’s in the code of the library.

#if ARDUINO >= 100
  #define SERIAL_WRITE(...) mySerial->write(__VA_ARGS__)
#else
  #define SERIAL_WRITE(...) mySerial->write(__VA_ARGS__, BYTE)
#endif

#define SERIAL_WRITE_U16(v) SERIAL_WRITE((uint8_t)(v>>8)); SERIAL_WRITE((uint8_t)(v & 0xFF));

#define GET_CMD_PACKET(...) \
  uint8_t data[] = {__VA_ARGS__}; \
  Adafruit_Fingerprint_Packet packet(FINGERPRINT_COMMANDPACKET, sizeof(data), data); \
  writeStructuredPacket(packet); \
  if (getStructuredPacket(&packet) != FINGERPRINT_OK) return FINGERPRINT_PACKETRECIEVEERR; \
  if (packet.type != FINGERPRINT_ACKPACKET) return FINGERPRINT_PACKETRECIEVEERR;

#define SEND_CMD_PACKET(...) GET_CMD_PACKET(__VA_ARGS__); return packet.data[0];

And see how SEND_CMD_PACKET is used for various cases.

To send stuff from your computer you need either a terminal app that lets you send binary or write your own small app (using Processing for example)

I do not completely understand the commands...a bit difficult to understand.

Menawhile, using Coolterm to test weather my commands are correct or not. Sending EF01FFFFFFFF0100041700001C as hex...the sensor is not responding. What might be the issue?

So you are sending a handshake

  • are you sure baud rates are set correctly?
  • can you check if your module address is really 0xFFFFFFFF ? (this is the default but can be changed)

Yes..I am sending standard handshake message with blank sketch loaded on arduino uno. Using Coolterm to send Hex data over serial bus.

Baud rate used is 9600 and password is standard 0xFFFFFFFF.

nimit393:
Baud rate used is 9600 and password is standard 0xFFFFFFFF.

  • default baud rate is 57600 (N=6)
  • 0xFFFFFFFF is not a password but the Chip address

How did you wire things? Blank sketch does not do anything

Here is how to proceed if you have a module that looks like mine (otherwise adjust wires):

Wire this way:
fingerSensor.png

Connect Vcc to your Arduino 5V, GND to GND, Sensor Tx to Arduino Rx for Serial3,, Sensor Rx to Arduino Tx for Serial3 - the two other wires don't need to be connected

Upload this code to an Arduino Mega (to have 2 hardware Serial):

#define fingerSerial Serial3

void setup() {
  Serial.begin(115200);
  fingerSerial.begin(57600);
  delay(1000);  // one second delay to let the sensor 'boot up'
}

void printHex2Digit(byte b)
{
  if (b <= 0xF) Serial.print("0");
  Serial.print(b, HEX);
}

void loop() {
  static unsigned long tSerial = 0;
  static unsigned long tFinger = 0;

  while (Serial.available()) {
    int r = Serial.read();
    if (millis() - tSerial >= 100) Serial.print(F("\nSending to Sensor: "));
    tSerial = millis();
    printHex2Digit((byte) r);
    if (r != -1) fingerSerial.write((byte) r);
  }

  while (fingerSerial.available()) {
    if (millis() - tFinger >= 100) Serial.print(F("\nReceived from Sensor: "));
    tFinger = millis();
    int r = fingerSerial.read();
    if (r != -1) printHex2Digit((byte) r);
  }
}

Open CoolTerm and connect at 115200 bauds to your Arduino
Open the SendString panel from the Connection menu
paste in that window the [color=purple]EF01FFFFFFFF0100041700001C[/color] handshake message
send that HEX message

if all is wired appropriately you will see in the serial terminal

[color=purple]Sending to Sensor: EF01FFFFFFFF0100041700001C
Received from Sensor:EF01FFFFFFFF07000300000A[/color]

if you decode the received message: [color=purple]EF01FFFFFFFF07000300000A[/color]

EF01 --> Start Header
FFFFFFFF --> Adder
07 --> Acknowledge packet
0003 --> length including command packets, data packets and 2 bytes Checksum
00 --> DATA = Port operation complete
000A --> Checksum 7 + 3 + 10 = 0x0A, all correct

this is indeed the expected confirmation message as per the documentation (chapter 6.1.1)

Hey,

The code posted by you works. Thanks a million for the help.

I was assuming that the default baud must be 9600 which was incorrect.

Also I used blank sketch to pass through the serial commands which did not work...what might be the issue?...because I did not authenticate with password first?

Earlier the connections for Rx and Tx of fingerprint sensor were directly connected to Rx Tx of the board...effectively connecting it to UART of my laptop.

Great

the bank sketch would work by kinda bypassing Serial and connecting directly to pins 0 and 1... of course need to cross cables TX to RX and RX to TX and the challenge is the default 57600 bauds... a small program such as the one I wrote reads from one side and sends it to the other

Blank sketch with Rx Tx correctly connected to that of fingerprint sensor would not work? The code posted by you does a very similar task, with not directly bypassing the UART commands but relaying it to different serial port.
What might be the reason for this?

Baud rate for Cool Term can be updated to 57600.

I’ve seen boards behave differently when trying to use pin 0 and 1 and also have usb connected... so I’m always careful on such setup

I extracted fingerprint template using the standard extract feature in Ada fruit library. Received template as

"FFFFFFFFFFFFFFFFFF0165159200FFFEFFFEFFFEFFFEF80EC00680008000800080000000000000000000000000008000000000000000000000000000000020AB78324242982B0DEF01FFFFFFFF0200825E1F56592A3ED8D9674201F90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056CEF01FFFFFFFF02008203015E169700FFFEFFFEFFFEFF1EC006C002C0008000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFF98415E1BA41ADE49A4431E6BA481FE2E26047E60AB033E0AAD845E59B2DC5E45B39ADE0AB604BE09BADC5E1F3D9ABE553F04FE48C29ADE3898031F26AD843F53AF44FF71B81F9F2AF9EF01FFFFFFFF08008239C306376297D71C659B2C7C2E394416000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000618FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"

However, I can find 3 header message within the templates. I tried other fingerprint in the same device...all 3 have 3 header section embedded into it and long series of 0 and F. Which part of the message is actually the template which I can use and write it on to other fingerprint sensor.

Motive is to extract template and store in a central repository...which can be transmitted on to multiple sensors as the network get expanded.

1 Like

Any updates?