Compare commits
53 commits
refactor_g
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e9b2cdeac | ||
|
|
c127475615 | ||
|
|
9d51eb5e32 | ||
|
|
e5c63cccfb | ||
|
|
5f4324cadf | ||
|
|
f9a49801f8 | ||
|
|
df94f5b6a0 | ||
|
|
d909c6673e | ||
|
|
b9175cb792 | ||
|
|
358c6c9e43 | ||
|
|
98df1bbdfc | ||
|
|
ff739da402 | ||
|
|
4c8e80560d | ||
|
|
ca104a93f4 | ||
|
|
8331a47ad7 | ||
|
|
9bee650682 | ||
|
|
235659d917 | ||
|
|
b966a01062 | ||
|
|
da24fee6ea | ||
|
|
212431922a | ||
|
|
bd0419c070 | ||
|
|
46fb651f19 | ||
|
|
296b36fef4 | ||
|
|
0a64b4db9b | ||
|
|
09356393df | ||
|
|
83711f6aed | ||
|
|
8d4535982b | ||
|
|
a419ade34d | ||
|
|
2225c23f7f | ||
|
|
9a34f466c1 | ||
|
|
e17cac2e2f | ||
|
|
0722ddf8aa | ||
|
|
6511150e48 | ||
|
|
e9ef326a1e | ||
|
|
e2eb06d8a5 | ||
|
|
b8899d93d3 | ||
|
|
4627e57209 | ||
|
|
9beed22ac4 | ||
|
|
68041678ac | ||
|
|
e36e76834a | ||
|
|
72f17ac250 | ||
|
|
1991a0d604 | ||
|
|
be5e5b3a0d | ||
|
|
9713dbfec3 | ||
|
|
9e2ab6584e | ||
|
|
59acece7b9 | ||
|
|
dae2db6857 | ||
|
|
6b0a056422 | ||
|
|
71f89d5dd9 | ||
|
|
7592218bcc | ||
|
|
95159512c3 | ||
|
|
f38ea6bd8b | ||
|
|
3438817c51 |
13 changed files with 261 additions and 139 deletions
14
.github/workflows/githubci.yml
vendored
14
.github/workflows/githubci.yml
vendored
|
|
@ -5,13 +5,17 @@ on: [pull_request, push, repository_dispatch]
|
|||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arduino-platform: ["uno", "leonardo", "mega2560", "zero", "esp8266", "esp32", "metro_m4", "trinket_m0"]
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v1
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
|
@ -20,7 +24,7 @@ jobs:
|
|||
run: bash ci/actions_install.sh
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py main_platforms
|
||||
run: python3 ci/build_platform.py ${{ matrix.arduino-platform }}
|
||||
|
||||
- name: clang
|
||||
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
|
|
|||
|
|
@ -93,6 +93,27 @@ Adafruit_Fingerprint::Adafruit_Fingerprint(HardwareSerial *hs,
|
|||
mySerial = hwSerial;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Instantiates sensor with a stream for Serial
|
||||
@param serial Pointer to a Stream object
|
||||
@param password 32-bit integer password (default is 0)
|
||||
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
Adafruit_Fingerprint::Adafruit_Fingerprint(Stream *serial, uint32_t password) {
|
||||
|
||||
thePassword = password;
|
||||
theAddress = 0xFFFFFFFF;
|
||||
|
||||
hwSerial = NULL;
|
||||
#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
|
||||
swSerial = NULL;
|
||||
#endif
|
||||
mySerial = serial;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initializes serial interface and baud rate
|
||||
|
|
@ -346,8 +367,8 @@ uint8_t Adafruit_Fingerprint::LEDcontrol(uint8_t control, uint8_t speed,
|
|||
/**************************************************************************/
|
||||
uint8_t Adafruit_Fingerprint::fingerSearch(uint8_t slot) {
|
||||
// search of slot starting thru the capacity
|
||||
GET_CMD_PACKET(FINGERPRINT_SEARCH, slot, 0x00, 0x00, capacity >> 8,
|
||||
capacity & 0xFF);
|
||||
GET_CMD_PACKET(FINGERPRINT_SEARCH, slot, 0x00, 0x00, (uint8_t)(capacity >> 8),
|
||||
(uint8_t)(capacity & 0xFF));
|
||||
|
||||
fingerID = 0xFFFF;
|
||||
confidence = 0xFFFF;
|
||||
|
|
@ -391,10 +412,64 @@ uint8_t Adafruit_Fingerprint::getTemplateCount(void) {
|
|||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_Fingerprint::setPassword(uint32_t password) {
|
||||
SEND_CMD_PACKET(FINGERPRINT_SETPASSWORD, (password >> 24), (password >> 16),
|
||||
(password >> 8), password);
|
||||
SEND_CMD_PACKET(FINGERPRINT_SETPASSWORD, (uint8_t)(password >> 24),
|
||||
(uint8_t)(password >> 16), (uint8_t)(password >> 8),
|
||||
(uint8_t)(password & 0xFF));
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Writing module registers
|
||||
@param regAdd 8-bit address of register
|
||||
@param value 8-bit value will write to register
|
||||
@returns <code>FINGERPRINT_OK</code> on success
|
||||
@returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
|
||||
@returns <code>FINGERPRINT_ADDRESS_ERROR</code> on register address error
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_Fingerprint::writeRegister(uint8_t regAdd, uint8_t value) {
|
||||
|
||||
SEND_CMD_PACKET(FINGERPRINT_WRITE_REG, regAdd, value);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Change UART baudrate
|
||||
@param baudrate 8-bit Uart baudrate
|
||||
@returns <code>FINGERPRINT_OK</code> on success
|
||||
@returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_Fingerprint::setBaudRate(uint8_t baudrate) {
|
||||
|
||||
return (writeRegister(FINGERPRINT_BAUD_REG_ADDR, baudrate));
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Change security level
|
||||
@param level 8-bit security level
|
||||
@returns <code>FINGERPRINT_OK</code> on success
|
||||
@returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_Fingerprint::setSecurityLevel(uint8_t level) {
|
||||
|
||||
return (writeRegister(FINGERPRINT_SECURITY_REG_ADDR, level));
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Change packet size
|
||||
@param size 8-bit packet size
|
||||
@returns <code>FINGERPRINT_OK</code> on success
|
||||
@returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_Fingerprint::setPacketSize(uint8_t size) {
|
||||
|
||||
return (writeRegister(FINGERPRINT_PACKET_REG_ADDR, size));
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Helper function to process a packet and send it over UART to the
|
||||
|
|
@ -537,6 +612,9 @@ Adafruit_Fingerprint::getStructuredPacket(Adafruit_Fingerprint_Packet *packet,
|
|||
break;
|
||||
}
|
||||
idx++;
|
||||
if ((idx + 9) >= sizeof(packet->data)) {
|
||||
return FINGERPRINT_BADPACKET;
|
||||
}
|
||||
}
|
||||
// Shouldn't get here so...
|
||||
return FINGERPRINT_BADPACKET;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,40 @@
|
|||
#define FINGERPRINT_LED_GRADUAL_OFF 0x06 //!< Gradually off
|
||||
#define FINGERPRINT_LED_RED 0x01 //!< Red LED
|
||||
#define FINGERPRINT_LED_BLUE 0x02 //!< Blue LED
|
||||
#define FINGERPRINT_LED_PURPLE 0x03 //!< Purple LED
|
||||
#define FINGERPRINT_LED_PURPLE 0x03 //!< Purple LEDpassword
|
||||
|
||||
#define FINGERPRINT_REG_ADDR_ERROR 0x1A //!< shows register address error
|
||||
#define FINGERPRINT_WRITE_REG 0x0E //!< Write system register instruction
|
||||
|
||||
#define FINGERPRINT_BAUD_REG_ADDR 0x4 //!< BAUDRATE register address
|
||||
#define FINGERPRINT_BAUDRATE_9600 0x1 //!< UART baud 9600
|
||||
#define FINGERPRINT_BAUDRATE_19200 0x2 //!< UART baud 19200
|
||||
#define FINGERPRINT_BAUDRATE_28800 0x3 //!< UART baud 28800
|
||||
#define FINGERPRINT_BAUDRATE_38400 0x4 //!< UART baud 38400
|
||||
#define FINGERPRINT_BAUDRATE_48000 0x5 //!< UART baud 48000
|
||||
#define FINGERPRINT_BAUDRATE_57600 0x6 //!< UART baud 57600
|
||||
#define FINGERPRINT_BAUDRATE_67200 0x7 //!< UART baud 67200
|
||||
#define FINGERPRINT_BAUDRATE_76800 0x8 //!< UART baud 76800
|
||||
#define FINGERPRINT_BAUDRATE_86400 0x9 //!< UART baud 86400
|
||||
#define FINGERPRINT_BAUDRATE_96000 0xA //!< UART baud 96000
|
||||
#define FINGERPRINT_BAUDRATE_105600 0xB //!< UART baud 105600
|
||||
#define FINGERPRINT_BAUDRATE_115200 0xC //!< UART baud 115200
|
||||
|
||||
#define FINGERPRINT_SECURITY_REG_ADDR 0x5 //!< Security level register address
|
||||
// The safety level is 1 The highest rate of false recognition , The rejection
|
||||
// rate is the lowest . The safety level is 5 The lowest tate of false
|
||||
// recognition, The rejection rate is the highest .
|
||||
#define FINGERPRINT_SECURITY_LEVEL_1 0X1 //!< Security level 1
|
||||
#define FINGERPRINT_SECURITY_LEVEL_2 0X2 //!< Security level 2
|
||||
#define FINGERPRINT_SECURITY_LEVEL_3 0X3 //!< Security level 3
|
||||
#define FINGERPRINT_SECURITY_LEVEL_4 0X4 //!< Security level 4
|
||||
#define FINGERPRINT_SECURITY_LEVEL_5 0X5 //!< Security level 5
|
||||
|
||||
#define FINGERPRINT_PACKET_REG_ADDR 0x6 //!< Packet size register address
|
||||
#define FINGERPRINT_PACKET_SIZE_32 0X0 //!< Packet size is 32 Byte
|
||||
#define FINGERPRINT_PACKET_SIZE_64 0X1 //!< Packet size is 64 Byte
|
||||
#define FINGERPRINT_PACKET_SIZE_128 0X2 //!< Packet size is 128 Byte
|
||||
#define FINGERPRINT_PACKET_SIZE_256 0X3 //!< Packet size is 256 Byte
|
||||
|
||||
//#define FINGERPRINT_DEBUG
|
||||
|
||||
|
|
@ -132,6 +165,7 @@ public:
|
|||
Adafruit_Fingerprint(SoftwareSerial *ss, uint32_t password = 0x0);
|
||||
#endif
|
||||
Adafruit_Fingerprint(HardwareSerial *hs, uint32_t password = 0x0);
|
||||
Adafruit_Fingerprint(Stream *serial, uint32_t password = 0x0);
|
||||
|
||||
void begin(uint32_t baud);
|
||||
|
||||
|
|
@ -155,6 +189,10 @@ public:
|
|||
uint8_t LEDcontrol(uint8_t control, uint8_t speed, uint8_t coloridx,
|
||||
uint8_t count = 0);
|
||||
|
||||
uint8_t setBaudRate(uint8_t baudrate);
|
||||
uint8_t setSecurityLevel(uint8_t level);
|
||||
uint8_t setPacketSize(uint8_t size);
|
||||
|
||||
void writeStructuredPacket(const Adafruit_Fingerprint_Packet &p);
|
||||
uint8_t getStructuredPacket(Adafruit_Fingerprint_Packet *p,
|
||||
uint16_t timeout = DEFAULTTIMEOUT);
|
||||
|
|
@ -178,6 +216,7 @@ public:
|
|||
|
||||
private:
|
||||
uint8_t checkPassword(void);
|
||||
uint8_t writeRegister(uint8_t regAdd, uint8_t value);
|
||||
uint32_t thePassword;
|
||||
uint32_t theAddress;
|
||||
uint8_t recvPacket[20];
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
# Adafruit-Fingerprint-Sensor-Library [](https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library/actions)[](http://adafruit.github.io/Adafruit-Fingerprint-Sensor-Library/html/index.html)
|
||||
|
||||
<img src="https://cdn-shop.adafruit.com/970x728/751-03.jpg" height="300"/>
|
||||
<img src="https://cdn-shop.adafruit.com/1200x900/4651-00.jpg" height="300"/>
|
||||
|
||||
Secure your project with biometrics - this all-in-one optical fingerprint sensor will make adding fingerprint detection and verification super simple. These modules are typically used in safes - there's a high powered DSP chip that does the image rendering, calculation, feature-finding and searching. Connect to any microcontroller or system with TTL serial, and send packets of data to take photos, detect prints, hash and search. You can also enroll new fingers directly - up to 162 finger prints can be stored in the onboard FLASH memory. There's a red LED in the lens that lights up during a photo so you know its working.
|
||||
|
||||
The Rugged Panel Mount Fingerprint Sensor with Bi-Color LED Ring even has an LED ring built around the detection pad, which can be set to red, blue or purple (as well as some fading/blinking effects) for a great user experience.
|
||||
|
||||
Designed specifically to work with the Adafruit Fingerprint sensor
|
||||
|
||||
Designed specifically to work with the Adafruit Fingerprint sensors
|
||||
* http://www.adafruit.com/products/751
|
||||
* https://www.adafruit.com/product/4651
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,20 +1,20 @@
|
|||
/***************************************************
|
||||
/***************************************************
|
||||
This is an example sketch for our optical Fingerprint sensor
|
||||
Designed specifically to work with the Adafruit Fingerprint sensor
|
||||
----> http://www.adafruit.com/products/751
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Adafruit_Fingerprint.h>
|
||||
|
||||
|
||||
#if defined(__AVR__) || defined(ESP8266)
|
||||
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
|
||||
// For UNO and others without hardware serial, we must use software serial...
|
||||
// pin #2 is IN from sensor (GREEN wire)
|
||||
// pin #3 is OUT from arduino (WHITE wire)
|
||||
|
|
@ -34,16 +34,16 @@ Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
|
|||
// Using sensor with password
|
||||
//Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial, 1337);
|
||||
|
||||
void setup()
|
||||
void setup()
|
||||
{
|
||||
while (!Serial); // For Yun/Leo/Micro/Zero/...
|
||||
|
||||
|
||||
Serial.begin(9600);
|
||||
Serial.println("Adafruit fingerprint sensor, change password example");
|
||||
|
||||
// set the data rate for the sensor serial port
|
||||
finger.begin(19200);
|
||||
|
||||
|
||||
if (finger.verifyPassword()) {
|
||||
Serial.println("Found fingerprint sensor!");
|
||||
} else {
|
||||
|
|
@ -64,4 +64,4 @@ void loop()
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
/***************************************************
|
||||
/***************************************************
|
||||
This is an example sketch for our optical Fingerprint sensor
|
||||
|
||||
Designed specifically to work with the Adafruit Fingerprint sensor
|
||||
----> http://www.adafruit.com/products/751
|
||||
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Adafruit_Fingerprint.h>
|
||||
|
||||
|
||||
#if defined(__AVR__) || defined(ESP8266)
|
||||
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
|
||||
// For UNO and others without hardware serial, we must use software serial...
|
||||
// pin #2 is IN from sensor (GREEN wire)
|
||||
// pin #3 is OUT from arduino (WHITE wire)
|
||||
|
|
@ -34,7 +34,7 @@ SoftwareSerial mySerial(2, 3);
|
|||
|
||||
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
|
||||
|
||||
void setup()
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
while (!Serial); // For Yun/Leo/Micro/Zero/...
|
||||
|
|
@ -43,7 +43,7 @@ void setup()
|
|||
|
||||
// set the data rate for the sensor serial port
|
||||
finger.begin(57600);
|
||||
|
||||
|
||||
if (finger.verifyPassword()) {
|
||||
Serial.println("Found fingerprint sensor!");
|
||||
} else {
|
||||
|
|
@ -55,7 +55,7 @@ void setup()
|
|||
|
||||
uint8_t readnumber(void) {
|
||||
uint8_t num = 0;
|
||||
|
||||
|
||||
while (num == 0) {
|
||||
while (! Serial.available());
|
||||
num = Serial.parseInt();
|
||||
|
|
@ -73,28 +73,26 @@ void loop() // run over and over again
|
|||
|
||||
Serial.print("Deleting ID #");
|
||||
Serial.println(id);
|
||||
|
||||
|
||||
deleteFingerprint(id);
|
||||
}
|
||||
|
||||
uint8_t deleteFingerprint(uint8_t id) {
|
||||
uint8_t p = -1;
|
||||
|
||||
|
||||
p = finger.deleteModel(id);
|
||||
|
||||
if (p == FINGERPRINT_OK) {
|
||||
Serial.println("Deleted!");
|
||||
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
|
||||
Serial.println("Communication error");
|
||||
return p;
|
||||
} else if (p == FINGERPRINT_BADLOCATION) {
|
||||
Serial.println("Could not delete in that location");
|
||||
return p;
|
||||
} else if (p == FINGERPRINT_FLASHERR) {
|
||||
Serial.println("Error writing to flash");
|
||||
return p;
|
||||
} else {
|
||||
Serial.print("Unknown error: 0x"); Serial.println(p, HEX);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
/***************************************************
|
||||
/***************************************************
|
||||
This is an example sketch for our optical Fingerprint sensor
|
||||
Designed specifically to work with the Adafruit Fingerprint sensor
|
||||
----> http://www.adafruit.com/products/751
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Adafruit_Fingerprint.h>
|
||||
|
||||
|
||||
#if defined(__AVR__) || defined(ESP8266)
|
||||
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
|
||||
// For UNO and others without hardware serial, we must use software serial...
|
||||
// pin #2 is IN from sensor (GREEN wire)
|
||||
// pin #3 is OUT from arduino (WHITE wire)
|
||||
|
|
@ -31,7 +31,7 @@ SoftwareSerial mySerial(2, 3);
|
|||
|
||||
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
|
||||
|
||||
void setup()
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
while (!Serial); // For Yun/Leo/Micro/Zero/...
|
||||
|
|
@ -48,14 +48,14 @@ void setup()
|
|||
|
||||
// set the data rate for the sensor serial port
|
||||
finger.begin(57600);
|
||||
|
||||
|
||||
if (finger.verifyPassword()) {
|
||||
Serial.println("Found fingerprint sensor!");
|
||||
} else {
|
||||
Serial.println("Did not find fingerprint sensor :(");
|
||||
while (1);
|
||||
}
|
||||
|
||||
|
||||
finger.emptyDatabase();
|
||||
|
||||
Serial.println("Now database is empty :)");
|
||||
|
|
|
|||
|
|
@ -1,23 +1,25 @@
|
|||
/***************************************************
|
||||
/***************************************************
|
||||
This is an example sketch for our optical Fingerprint sensor
|
||||
|
||||
Designed specifically to work with the Adafruit BMP085 Breakout
|
||||
Designed specifically to work with the Adafruit BMP085 Breakout
|
||||
----> http://www.adafruit.com/products/751
|
||||
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Small bug-fix by Michael cochez
|
||||
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Adafruit_Fingerprint.h>
|
||||
|
||||
|
||||
#if defined(__AVR__) || defined(ESP8266)
|
||||
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
|
||||
// For UNO and others without hardware serial, we must use software serial...
|
||||
// pin #2 is IN from sensor (GREEN wire)
|
||||
// pin #3 is OUT from arduino (WHITE wire)
|
||||
|
|
@ -36,7 +38,7 @@ Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
|
|||
|
||||
uint8_t id;
|
||||
|
||||
void setup()
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
while (!Serial); // For Yun/Leo/Micro/Zero/...
|
||||
|
|
@ -45,7 +47,7 @@ void setup()
|
|||
|
||||
// set the data rate for the sensor serial port
|
||||
finger.begin(57600);
|
||||
|
||||
|
||||
if (finger.verifyPassword()) {
|
||||
Serial.println("Found fingerprint sensor!");
|
||||
} else {
|
||||
|
|
@ -66,7 +68,7 @@ void setup()
|
|||
|
||||
uint8_t readnumber(void) {
|
||||
uint8_t num = 0;
|
||||
|
||||
|
||||
while (num == 0) {
|
||||
while (! Serial.available());
|
||||
num = Serial.parseInt();
|
||||
|
|
@ -84,8 +86,8 @@ void loop() // run over and over again
|
|||
}
|
||||
Serial.print("Enrolling ID #");
|
||||
Serial.println(id);
|
||||
|
||||
while (! getFingerprintEnroll() );
|
||||
|
||||
while (! getFingerprintEnroll() );
|
||||
}
|
||||
|
||||
uint8_t getFingerprintEnroll() {
|
||||
|
|
@ -99,7 +101,7 @@ uint8_t getFingerprintEnroll() {
|
|||
Serial.println("Image taken");
|
||||
break;
|
||||
case FINGERPRINT_NOFINGER:
|
||||
Serial.println(".");
|
||||
Serial.print(".");
|
||||
break;
|
||||
case FINGERPRINT_PACKETRECIEVEERR:
|
||||
Serial.println("Communication error");
|
||||
|
|
@ -136,7 +138,7 @@ uint8_t getFingerprintEnroll() {
|
|||
Serial.println("Unknown error");
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
Serial.println("Remove finger");
|
||||
delay(2000);
|
||||
p = 0;
|
||||
|
|
@ -190,10 +192,10 @@ uint8_t getFingerprintEnroll() {
|
|||
Serial.println("Unknown error");
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
// OK converted!
|
||||
Serial.print("Creating model for #"); Serial.println(id);
|
||||
|
||||
|
||||
p = finger.createModel();
|
||||
if (p == FINGERPRINT_OK) {
|
||||
Serial.println("Prints matched!");
|
||||
|
|
@ -206,8 +208,8 @@ uint8_t getFingerprintEnroll() {
|
|||
} else {
|
||||
Serial.println("Unknown error");
|
||||
return p;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Serial.print("ID "); Serial.println(id);
|
||||
p = finger.storeModel(id);
|
||||
if (p == FINGERPRINT_OK) {
|
||||
|
|
@ -224,7 +226,7 @@ uint8_t getFingerprintEnroll() {
|
|||
} else {
|
||||
Serial.println("Unknown error");
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/***************************************************
|
||||
/***************************************************
|
||||
This is an example sketch for our optical Fingerprint sensor
|
||||
|
||||
Designed specifically to work with the Adafruit BMP085 Breakout
|
||||
Designed specifically to work with the Adafruit BMP085 Breakout
|
||||
----> http://www.adafruit.com/products/751
|
||||
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
#include <Adafruit_Fingerprint.h>
|
||||
|
||||
|
||||
#if defined(__AVR__) || defined(ESP8266)
|
||||
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
|
||||
// For UNO and others without hardware serial, we must use software serial...
|
||||
// pin #2 is IN from sensor (GREEN wire)
|
||||
// pin #3 is OUT from arduino (WHITE wire)
|
||||
|
|
@ -35,7 +35,7 @@ SoftwareSerial mySerial(2, 3);
|
|||
|
||||
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
|
||||
|
||||
void setup()
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
while (!Serial); // For Yun/Leo/Micro/Zero/...
|
||||
|
|
@ -61,12 +61,12 @@ void setup()
|
|||
Serial.print(F("Device address: ")); Serial.println(finger.device_addr, HEX);
|
||||
Serial.print(F("Packet len: ")); Serial.println(finger.packet_len);
|
||||
Serial.print(F("Baud rate: ")); Serial.println(finger.baud_rate);
|
||||
|
||||
|
||||
finger.getTemplateCount();
|
||||
|
||||
if (finger.templateCount == 0) {
|
||||
Serial.print("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
Serial.println("Waiting for valid finger...");
|
||||
Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
|
||||
|
|
@ -122,7 +122,7 @@ uint8_t getFingerprintID() {
|
|||
Serial.println("Unknown error");
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
// OK converted!
|
||||
p = finger.fingerSearch();
|
||||
if (p == FINGERPRINT_OK) {
|
||||
|
|
@ -136,11 +136,11 @@ uint8_t getFingerprintID() {
|
|||
} else {
|
||||
Serial.println("Unknown error");
|
||||
return p;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// found a match!
|
||||
Serial.print("Found ID #"); Serial.print(finger.fingerID);
|
||||
Serial.print(" with confidence of "); Serial.println(finger.confidence);
|
||||
Serial.print("Found ID #"); Serial.print(finger.fingerID);
|
||||
Serial.print(" with confidence of "); Serial.println(finger.confidence);
|
||||
|
||||
return finger.fingerID;
|
||||
}
|
||||
|
|
@ -155,9 +155,9 @@ int getFingerprintIDez() {
|
|||
|
||||
p = finger.fingerFastSearch();
|
||||
if (p != FINGERPRINT_OK) return -1;
|
||||
|
||||
|
||||
// found a match!
|
||||
Serial.print("Found ID #"); Serial.print(finger.fingerID);
|
||||
Serial.print("Found ID #"); Serial.print(finger.fingerID);
|
||||
Serial.print(" with confidence of "); Serial.println(finger.confidence);
|
||||
return finger.fingerID;
|
||||
return finger.fingerID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
/***************************************************
|
||||
/***************************************************
|
||||
This is an example sketch for our optical Fingerprint sensor with LED ring
|
||||
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
These displays use TTL Serial to communicate, 2 pins are required to
|
||||
interface
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
|
||||
|
||||
#if defined(__AVR__) || defined(ESP8266)
|
||||
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
|
||||
// For UNO and others without hardware serial, we must use software serial...
|
||||
// pin #2 is IN from sensor (GREEN wire)
|
||||
// pin #3 is OUT from arduino (WHITE wire)
|
||||
|
|
@ -32,7 +32,7 @@ SoftwareSerial mySerial(2, 3);
|
|||
|
||||
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
|
||||
|
||||
void setup()
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
while (!Serial); // For Yun/Leo/Micro/Zero/...
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/***************************************************
|
||||
/***************************************************
|
||||
This is an example sketch for our optical Fingerprint sensor
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
|
||||
#include <Adafruit_Fingerprint.h>
|
||||
|
||||
#if defined(__AVR__) || defined(ESP8266)
|
||||
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
|
||||
// For UNO and others without hardware serial, we must use software serial...
|
||||
// pin #2 is IN from sensor (GREEN wire)
|
||||
// pin #3 is OUT from arduino (WHITE wire)
|
||||
|
|
@ -31,15 +31,15 @@ Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
|
|||
|
||||
int getFingerprintIDez();
|
||||
|
||||
void setup()
|
||||
void setup()
|
||||
{
|
||||
while(!Serial);
|
||||
while (!Serial);
|
||||
Serial.begin(9600);
|
||||
Serial.println("Fingerprint template extractor");
|
||||
|
||||
// set the data rate for the sensor serial port
|
||||
finger.begin(57600);
|
||||
|
||||
|
||||
if (finger.verifyPassword()) {
|
||||
Serial.println("Found fingerprint sensor!");
|
||||
} else {
|
||||
|
|
@ -78,11 +78,11 @@ uint8_t downloadFingerprintTemplate(uint16_t id)
|
|||
case FINGERPRINT_OK:
|
||||
Serial.print("Template "); Serial.print(id); Serial.println(" transferring:");
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
Serial.print("Unknown error "); Serial.println(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
// one data packet is 267 bytes. in one data packet, 11 bytes are 'usesless' :D
|
||||
uint8_t bytesReceived[534]; // 2 data packets
|
||||
memset(bytesReceived, 0xff, 534);
|
||||
|
|
@ -90,9 +90,9 @@ uint8_t downloadFingerprintTemplate(uint16_t id)
|
|||
uint32_t starttime = millis();
|
||||
int i = 0;
|
||||
while (i < 534 && (millis() - starttime) < 20000) {
|
||||
if (mySerial.available()) {
|
||||
bytesReceived[i++] = mySerial.read();
|
||||
}
|
||||
if (mySerial.available()) {
|
||||
bytesReceived[i++] = mySerial.read();
|
||||
}
|
||||
}
|
||||
Serial.print(i); Serial.println(" bytes read.");
|
||||
Serial.println("Decoding packet...");
|
||||
|
|
@ -102,42 +102,41 @@ uint8_t downloadFingerprintTemplate(uint16_t id)
|
|||
|
||||
// filtering only the data packets
|
||||
int uindx = 9, index = 0;
|
||||
while (index < 534) {
|
||||
while (index < uindx) ++index;
|
||||
uindx += 256;
|
||||
while (index < uindx) {
|
||||
fingerTemplate[index++] = bytesReceived[index];
|
||||
}
|
||||
uindx += 2;
|
||||
while (index < uindx) ++index;
|
||||
uindx = index + 9;
|
||||
}
|
||||
memcpy(fingerTemplate + index, bytesReceived + uindx, 256); // first 256 bytes
|
||||
uindx += 256; // skip data
|
||||
uindx += 2; // skip checksum
|
||||
uindx += 9; // skip next header
|
||||
index += 256; // advance pointer
|
||||
memcpy(fingerTemplate + index, bytesReceived + uindx, 256); // second 256 bytes
|
||||
|
||||
for (int i = 0; i < 512; ++i) {
|
||||
//Serial.print("0x");
|
||||
printHex(fingerTemplate[i], 2);
|
||||
//Serial.print(", ");
|
||||
//Serial.print("0x");
|
||||
printHex(fingerTemplate[i], 2);
|
||||
//Serial.print(", ");
|
||||
}
|
||||
Serial.println("\ndone.");
|
||||
|
||||
return p;
|
||||
|
||||
/*
|
||||
uint8_t templateBuffer[256];
|
||||
memset(templateBuffer, 0xff, 256); //zero out template buffer
|
||||
int index=0;
|
||||
uint32_t starttime = millis();
|
||||
while ((index < 256) && ((millis() - starttime) < 1000))
|
||||
{
|
||||
uint8_t templateBuffer[256];
|
||||
memset(templateBuffer, 0xff, 256); //zero out template buffer
|
||||
int index=0;
|
||||
uint32_t starttime = millis();
|
||||
while ((index < 256) && ((millis() - starttime) < 1000))
|
||||
{
|
||||
if (mySerial.available())
|
||||
{
|
||||
templateBuffer[index] = mySerial.read();
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
Serial.print(index); Serial.println(" bytes read");
|
||||
|
||||
//dump entire templateBuffer. This prints out 16 lines of 16 bytes
|
||||
for (int count= 0; count < 16; count++)
|
||||
{
|
||||
}
|
||||
|
||||
Serial.print(index); Serial.println(" bytes read");
|
||||
|
||||
//dump entire templateBuffer. This prints out 16 lines of 16 bytes
|
||||
for (int count= 0; count < 16; count++)
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
Serial.print("0x");
|
||||
|
|
@ -145,22 +144,21 @@ uint8_t downloadFingerprintTemplate(uint16_t id)
|
|||
Serial.print(", ");
|
||||
}
|
||||
Serial.println();
|
||||
}*/
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void printHex(int num, int precision) {
|
||||
char tmp[16];
|
||||
char format[128];
|
||||
|
||||
sprintf(format, "%%.%dX", precision);
|
||||
|
||||
sprintf(tmp, format, num);
|
||||
Serial.print(tmp);
|
||||
char tmp[16];
|
||||
char format[128];
|
||||
|
||||
sprintf(format, "%%.%dX", precision);
|
||||
|
||||
sprintf(tmp, format, num);
|
||||
Serial.print(tmp);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name=Adafruit Fingerprint Sensor Library
|
||||
version=1.1.8
|
||||
version=2.1.3
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Arduino library for interfacing to the fingerprint sensor in the Adafruit shop
|
||||
|
|
@ -7,4 +7,3 @@ paragraph=Arduino library for interfacing to the fingerprint sensor in the Adafr
|
|||
category=Sensors
|
||||
url=https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library
|
||||
architectures=*
|
||||
depends=Adafruit ILI9341, Adafruit GFX Library
|
||||
|
|
|
|||
Loading…
Reference in a new issue