Hello, I have a problem using 2 AS608 fingerprint sensors in 1 Arduino UNO. if only 1 sensor is activated, the sensor can be read on the serial monitor and can be used. but if 2 sensors are activated, the sensors are not read (device not found) and cannot be used.
And I have problem also about fingerprint reset using button.
Can anyone help me? Here is my program for these 2 fingerprint sensors
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 5);
SoftwareSerial mySerial2(2, 3); // Define another SoftwareSerial instance for the second fingerprint module
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
Adafruit_Fingerprint finger2 = Adafruit_Fingerprint(&mySerial2); // Create an instance for the second fingerprint module
const int buttonPin = 4; // Assign the button switch to pin 4
void setup()
{
Serial.begin(9600);
while (!Serial);
delay(100);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
Serial.println("Program Dasar Akses Sidik Jari Arduino");
finger.begin(57600);
finger2.begin(57600); // Initialize the second fingerprint module
if (finger.verifyPassword() && finger2.verifyPassword())
{
Serial.println("Found fingerprint sensors!");
}
else
{
Serial.println("Did not find fingerprint sensors :(");
while (1) { delay(1); }
}
Serial.println("Waiting for valid finger...");
}
void loop()
{
if (digitalRead(buttonPin) == LOW)
{
addFingerprint();
delay(1000); // Debounce delay to avoid multiple reads
}
else
{
getFingerprintID();
}
}
uint8_t getFingerprintID()
{
uint8_t p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
//Serial.println(".");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
return p;
default:
Serial.println("Unknown error");
return p;
}
// OK success!
p = finger.image2Tz();
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
return p;
default:
Serial.println("Unknown error");
return p;
}
// OK converted!
p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK)
{
Serial.println("Found a print match!");
}
else if (p == FINGERPRINT_PACKETRECIEVEERR)
{
Serial.println("Communication error");
return p;
}
else if (p == FINGERPRINT_NOTFOUND)
{
Serial.println("Did not find a match");
delay(1000);
return p;
}
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);
digitalWrite(13, HIGH);
delay(3000);
digitalWrite(13, LOW);
return finger.fingerID;
}
void addFingerprint()
{
Serial.println("Put your finger on the sensor to add a new fingerprint...");
while (!finger.getImage())
{
// Wait until a finger is placed on the sensor
}
int fingerprintID = -1;
uint8_t p = finger.image2Tz(1);
if (p == FINGERPRINT_OK)
{
Serial.println("Image captured. Remove your finger.");
delay(2000);
Serial.println("Place the same finger again...");
while (!finger.getImage())
{
// Wait until the same finger is placed on the sensor
}
p = finger.image2Tz(2);
if (p == FINGERPRINT_OK)
{
Serial.println("Fingerprints matched!");
// Store the fingerprint template on the sensor
p = finger.createModel();
if (p == FINGERPRINT_OK)
{
fingerprintID = finger.storeModel(1);
if (fingerprintID != FINGERPRINT_OK)
{
Serial.println("Failed to add fingerprint!");
}
else
{
Serial.print("Fingerprint successfully added! ID: ");
Serial.println(finger.fingerID);
digitalWrite(13, HIGH);
delay(2000);
digitalWrite(13, LOW);
}
}
else
{
Serial.println("Failed to create fingerprint template!");
}
}
else
{
Serial.println("Fingerprints did not match!");
}
}
else
{
Serial.println("Failed to capture image!");
}
}
Help me, please. Thanks