|
| 1 | +/***************************************************************** |
| 2 | + * FPS_Serial_Passthrough.ino |
| 3 | + * |
| 4 | + * By: Ho Yun "Bobby" Chan @ SparkFun Electronics |
| 5 | + * Date: April 3rd, 2017 |
| 6 | + * Description: This is a basic serial passthrough code that sets |
| 7 | + * up a software serial port to pass data between the Fingerprint Scanner |
| 8 | + * and the SDK Demo Software (SDK_Demo.exe) provided by ADH-Tech. This |
| 9 | + * code should work with the any model of ADH-Tech's FPS as long as |
| 10 | + * you are within the minimum logic level threshold for the FPS serial UART. |
| 11 | + * This code has been tested with these models: |
| 12 | + * |
| 13 | + * GT-511C3 [ https://www.sparkfun.com/products/11792 ] |
| 14 | + * GT-511C1R [ https://www.sparkfun.com/products/13007 ] |
| 15 | + * |
| 16 | + * A WORD OF CAUTION: It is recommended to use a 3.3V FTDI basic breakout |
| 17 | + * board [ https://www.sparkfun.com/products/9873 ] and mini-b USB cable |
| 18 | + * [ https://www.sparkfun.com/products/11301 ]. There is a higher |
| 19 | + * probability of having problems when using an Arduino as an intermediate device |
| 20 | + * between the FPS and your computer. Using the FTDI as the USB-to-serial |
| 21 | + * converter is more realiable and easier to get started. Once you have |
| 22 | + * enrolled the fingerprints, Hawley's "FPS_IDFinger.ino" code should recognize |
| 23 | + * the fingerprint templates saved in memory. |
| 24 | +
|
| 25 | +-------------------- HARDWARE HOOKUP with 5V Arduino -------------------- |
| 26 | +
|
| 27 | +1.) Dedicated Bi-Directional Logic Level Converter (LLC) |
| 28 | +
|
| 29 | +It is recommended to use a dedicated bi-direcitonal LLC |
| 30 | +[ https://www.sparkfun.com/products/12009 ] for a reliable connection if you |
| 31 | +are using a 5V Arduino microcontroller: |
| 32 | +
|
| 33 | + Fingerprint Scanner (Pin #) <-> Logic Level Converter <-> 5V Arduino w/ Atmega328P |
| 34 | + UART_TX (3.3V TTL)(Pin 1) <-> LV4 <-> HV4 <-> RX (pin 4) |
| 35 | + UART_RX (3.3V TTL)(Pin 2) <-> LV1 <-> HV1 <-> TX (pin 5) |
| 36 | + GND (Pin 3) <-> GND <-> GND <-> GND |
| 37 | + Vin (3.3V~6V) (Pin 4) <-> HV <-> 5V |
| 38 | + LV <-> 3.3V |
| 39 | +
|
| 40 | +2.) Voltage Division w/ 3x 10kOhm Resistors |
| 41 | +
|
| 42 | +Otherwise, you could use 3x 10kOhm resistors [ https://www.sparkfun.com/products/11508 ] |
| 43 | +to divide the voltage from a 5V Arduino down to 3.3V FPS similar to the |
| 44 | +"Uni-Directional" application circuit on our old logic level converter |
| 45 | +[ https://cdn.sparkfun.com/assets/b/0/e/1/0/522637c6757b7f2b228b4568.png ]: |
| 46 | +
|
| 47 | + Voltage Divider <-> Fingerprint Scanner(Pin #) <-> Voltage Divider <-> 5V Arduino w/ Atmega328P |
| 48 | + <-> UART_TX (3.3V TTL) (Pin 1) <-> <-> RX (pin 4) |
| 49 | + GND <-> 10kOhm <-> 10kOhm <-> UART_RX (3.3V TTL) (Pin 2) <-> 10kOhm <-> TX (pin 5) |
| 50 | + GND <-> GND (Pin 3) <-> GND <-> GND |
| 51 | + <-> Vin (3.3V~6V) (Pin 4) <-> <-> 5V |
| 52 | +
|
| 53 | +Note: You can add the two 10kOhm resistors in series for 20kOhms. =) |
| 54 | +
|
| 55 | +-------------------------------------------------------------------------------- |
| 56 | +*****************************************************************/ |
| 57 | + |
| 58 | +// We'll use SoftwareSerial to communicate with the FPS: |
| 59 | +#include <SoftwareSerial.h> |
| 60 | + |
| 61 | +// set up software serial pins for Arduino's w/ Atmega328P's |
| 62 | +// FPS (TX) is connected to pin 4 (Arduino's Software RX) |
| 63 | +// FPS (RX) is connected through a converter to pin 5 (Arduino's Software TX) |
| 64 | +SoftwareSerial fps(4, 5); // (Arduino SS_RX = pin 4, Arduino SS_TX = pin 5) |
| 65 | + |
| 66 | +/*If using another Arduino microcontroller, try commenting out line 64 and |
| 67 | +uncommenting line 73 due to the limitations listed in the |
| 68 | +library's note => https://www.arduino.cc/en/Reference/softwareSerial . Do |
| 69 | +not forget to rewire the connection to the Arduino.*/ |
| 70 | + |
| 71 | +// FPS (TX) is connected to pin 10 (Arduino's Software RX) |
| 72 | +// FPS (RX) is connected through a converter to pin 11 (Arduino's Software TX) |
| 73 | +//SoftwareSerial fps(10, 11); // (Arduino SS_RX = pin 10, Arduino SS_TX = pin 11) |
| 74 | + |
| 75 | +void setup() |
| 76 | +{ |
| 77 | + // Set up both ports at 9600 baud since that is the FPS's default baud. |
| 78 | + // Make sure the baud rate matches the config setting of SDK demo software. |
| 79 | + Serial.begin(9600); //set up Arduino's hardware serial UART |
| 80 | + fps.begin(9600); //set up software serial UART for FPS |
| 81 | +} |
| 82 | + |
| 83 | +void loop() |
| 84 | +{ |
| 85 | + if (Serial.available()) |
| 86 | + { // If data comes in from serial monitor, send it out to FPS |
| 87 | + fps.write(Serial.read()); |
| 88 | + } |
| 89 | + if (fps.available()) |
| 90 | + { // If data comes in from FPS, send it out to serial monitor |
| 91 | + Serial.write(fps.read()); |
| 92 | + } |
| 93 | +} |
0 commit comments