Serial Connection to Fingerprint sensor works only with PC.

Hello,

I am using Arduino YUN to experiment a fingerprint sensor based switch to ON/OFF a circuit. I was able to accomplish the result only with the serial monitor open.

What I need is a standalone connection from YUN board to the fingerprint sensor. As of now the fingerprint sensor only powers on if the serial monitor is open. Please help I am new to Arduino.

Thanks,

Nithin Dandamudi

No link to that fingerprint sensor, no wiring diagram of your current setup, based on which information should we help you?

I can make a wild guess: there is no power supply for the Arduino if you don't connect the USB to the PC. I may be wrong but you wrote nothing about a second power supply you're using so I assume you don't have one.

Thank you for the reply.
I am using a basic Arduino compatible adafruit sensor.

The communication between Arduino and the fingerprint sensor starts only if the Arduino is connected to PC AND the serial monitor is opened. The sensor doesn’t even power on until then.

Even if the Arduino YUN is connected to a wall adapter or if it is connected to a PC without the serial monitor open, the communication doesn’t start and the sensor doesn’t power on.
I am using the example named ‘fingerprint’ in the adafruit finger sensor library.

I hope this make it clear. Please advise.

The communication between Arduino and the fingerprint sensor starts only if the Arduino is connected to PC AND the serial monitor is opened. The sensor doesn't even power on until then.

How do you know?

Page 13 of the manual:

It is normal for the sensor to blink the LED quickly once powered, after that the LED will be off until you've
started to request data from it

BTW: Still no wiring diagram. And you know that the Yun has a ATmega32U4, so it's hardware serial interface is theoretically available if the Linux part is not used or converted to use the SPI interface. So you're able to eliminate the horrible SoftwareSerial class.

I know it because I have added in code for the LED to blink in a pattern for some time if the fingerprint is matched. This works as expected with the serial monitor open.

In the other case when I connect it to wall adapter or don’t open the serial monitor(if I connect to PC), even the sensor won’t power on.

When connected to PC, the sensor takes input only after I open the serial monitor.

The wiring is as mentioned in the tutorial below except that I have used YUN instead of UNO.

I know it because I have added in code for the LED to blink in a pattern for some time if the fingerprint is matched. This works as expected with the serial monitor open.

That means you use some other sketch than the example you mentioned. Post your complete code!

In the other case when I connect it to wall adapter or don't open the serial monitor(if I connect to PC), even the sensor won't power on.

I ask again: how do you know that? Did you measure the voltage on the sensor?

The wiring is as mentioned in the tutorial below except that I have used YUN instead of UNO.

I want to see your wiring! In the linked tutorial they have no power supply connected. As you tell us that you have power issues, the power supply connection might be important.

Hello, Thank you for the reply.
Below is the code as requested.

#include <Adafruit_Fingerprint.h>

// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
// uncomment this line:
// #define mySerial Serial1

// 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)
// comment these two lines if using hardware serial
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()
{
Serial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
Serial.println("\n\nAdafruit finger detect test");

// 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) { delay(1); }
}
Serial.println("Waiting for valid finger...");
}

void loop() // run over and over again
{
getFingerprintIDez();
delay(50); //don't ned to run this at full speed.
}

uint8_t getFingerprintID() {
uint8_t p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.println("No finger detected");
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");
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);

return finger.fingerID;
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
uint8_t p = finger.getImage();
if (p != FINGERPRINT_OK) return -1;

p = finger.image2Tz();
if (p != FINGERPRINT_OK) return -1;

p = finger.fingerFastSearch();
if (p != FINGERPRINT_OK) return -1;

// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
return finger.fingerID;
}

These are the photos of wiring.

Attached are the wiring photos.

Archive.zip (437 KB)

How to post images.
Not many members will want to download and unzip a file in order to help you. Please read the "how to use this forum-please read" stickies to see how to format and post code.

These are the photos of wiring.

On these pictures I cannot see a power supply connected to the YUN. The only power come from your Mac.

Your Yun has a power LED. So you can check if your Yun has power by looking at this LED. Does it light up if you have the Yun connected to your MAC but the serial monitor is not open? If yes, then the fingerprint sensor is also powered on.

@groundFungus: Thank you for guiding me. Now I know how to post photos.

@pylon: Thank you very much for the reply. I think you are getting my problem wrong. Sorry for the confusion I might have created.

Below is what I did:

Case1:

  1. Uploaded the code from previous post to YUN board and connected the finger sensor as shown in the photos. Connected power source is Computer.

  2. Power LED on YUN is already turned on and Finger sensor DOESN'T blink green.

  3. Opened the serial monitor in Arduino software. Finger sensor starts blinking green after opening serial monitor and its waiting for the finger detection.

  4. Placed my finger on the sensor. It reads and blinks the onboard red LED as per the program uploaded.

Case2:

  1. Uploaded the code from previous post to YUN board and connected the finger sensor as shown in the photos. Connected power source is a 5V adapter.

  2. Power LED on YUN is turned on and Finger sensor DOESN'T blink green.

  3. Waited for a good amount of time. Clicked the onboard RESET. Nothing happens.

  4. Then changed the power source to Computer.

  5. Opened Serial Monitor in Arduino software. Now the finger sensor blinks green waiting for the finger to be detected.

  6. Placed my finger on the sensor. It reads and blinks the onboard red LED as per the program uploaded.

Please advise. I could send a video of this but the forum doesn't allow more than 1 MB. Thank you so much in advance.

Here is the video link. I have uploaded to Google drive.

https://goo.gl/w5SQdg

Connected power source is a 5V adapter.

In the video it's still you computer.

The fingerprint sensor is powered but it's not activated because you told the Arduino to wait for your PC to be connected. Remove the following line and it will probably run. If not, remove all lines which uses the Serial object.

while (!Serial);  // For Yun/Leo/Micro/Zero/...