2

I'm trying to connect a fingerprint sensor (Adafruit type) to my ESP32 (DOIT ESP32 Devkit V1), but the Serial Monitor remains completely blank, even though I'm using Serial.begin(9600) and printing debug messages like "Starting setup...".

Here's what I have:

Board: DOIT ESP32 Devkit V1

Port: COM6 (shows up as "Silicon Labs CP210x USB to UART Bridge")

Wiring:

  • 3.3V → VCC

  • GND → GND

  • GPIO16 (RX2) → TX of sensor

  • GPIO17 (TX2) → RX of sensor

Code :

#include <Adafruit_Fingerprint.h>
#include <HardwareSerial.h>
#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)
// Set up the serial port to use softwareserial..
HardwareSerial mySerial(2);
#else
// On Leonardo/M0/etc, others with hardware serial, use hardware serial!
// #0 is green wire, #1 is white
#define mySerial Serial1
#endif
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()
{
 Serial.begin(9600);
 Serial.println("התחלתי את setup");
 delay(100);
 Serial.println("\n\nAdafruit finger detect test");
 mySerial.begin(57600, SERIAL_8N1, 16, 17);
 // set the data rate for the sensor serial port
 finger.begin(57600);
 delay(5);
 if (finger.verifyPassword()) {
 Serial.println("Found fingerprint sensor!");
 } else {
 Serial.println("Did not find fingerprint sensor :(");
 while (1) { delay(1); }
 }
 Serial.println(F("Reading sensor parameters"));
 finger.getParameters();
 Serial.print(F("Status: 0x")); Serial.println(finger.status_reg, HEX);
 Serial.print(F("Sys ID: 0x")); Serial.println(finger.system_id, HEX);
 Serial.print(F("Capacity: ")); Serial.println(finger.capacity);
 Serial.print(F("Security level: ")); Serial.println(finger.security_level);
 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");
 }
}
void loop() // run over and over again
{
 getFingerprintID();
 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.fingerSearch();
 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);
 return finger.fingerID;
}

I verified the port is correct and the board is selected properly in the Arduino IDE. But the Serial Monitor stays empty. I even added early Serial.println() calls, and nothing appears.

What could be causing this issue?

Greenonline
3,1527 gold badges36 silver badges48 bronze badges
asked May 5 at 15:29
2
  • 3
    disconnect everything ... then run a simple sketch that prints a message to the serial monitor Commented May 5 at 16:36
  • 1
    1) Your #ifdef ... #else ... #endif logic is wrong. 2) For ESP32, PIn 16 and 17 is not Serial1, it is Serial2. So delete the entire #ifdef ... #endif, and simply use HardwareSerial mySerial(2); // use UART2. Commented May 5 at 22:53

1 Answer 1

1

The ESP32 boot mode is affected by certain GPIO states during power-up. GPIOs 0, 2, and 15 are especially sensitive. In your case:

You're using:

GPIO16 (RX2) → TX of sensor 
GPIO17 (TX2) → RX of sensor

That's fine after boot, but some fingerprint sensors pull RX low, which could cause boot to hang if certain GPIOs are affected. Try this test: Disconnect the fingerprint sensor from the ESP32. Then press the Reset (EN) button on the ESP32. See if you get Serial Monitor output now. If text appears after disconnecting the sensor, then the fingerprint module is holding the ESP32 in the wrong boot mode.

Since you are working with ESP32 and a fingerprint sensor, you can also see this Time clock with a fingerprint IoT module project.

answered Jun 17 at 18:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.