How to connect AS608 Fingerprint Sensor to ESP32

Good Day! I have this project where I need to connect my AS608 Fingerprint sensor to my ESP32 38 pins. I was able to successfully connect the sensor using an Arduino Uno, but now when I tried the code to ESP32, the sensor is not found.

I connected the RX and TX Pins of the AS608 to the GPIO 18 and 19 of ESP32, I tried coding hardware serial for it but it still does not work and the sensor can't be found. Any help, tips, or fixes for those who encountered this? Thank you!

The following is a snippet of my code:

#include <Adafruit_Fingerprint.h>
#include <HardwareSerial.h>

#define RX_PIN GPIO_NUM_18
#define TX_PIN GPIO_NUM_19

HardwareSerial mySerial(1);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

uint8_t id;

void setup()
{
  Serial.begin(9600);
  mySerial.begin(57600, SERIAL_8N1, RX_PIN, TX_PIN);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit Fingerprint sensor enrollment");

  // 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(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);
}

uint8_t readnumber(void) {
  uint8_t num = 0;

  while (num == 0) {
    while (! Serial.available());
    num = Serial.parseInt();
  }
  return num;
}

what about GND and power ?

Connected it as well, used 3.3v for the Power. It's powered up, which is why the serial monitor is able to print "fingerprint sensor not found." Sorry didn't clarify it.

which ESP32 do you have?

you configure the library on serial #1

UART1 is usually on GPIO9 and GPIO10 (with GPIO6 as CTS and GPIO11 as RTS)

you set other pins here
mySerial.begin(57600, SERIAL_8N1, RX_PIN, TX_PIN);
and start up the Hardware Serial instance

and then you call finger.begin(57600); which likely starts the port again. Not sure that's the intended way.

I'm using this and it is registered as ESP32 DEV MODULE in Arduino IDE.

With regards to what you have said, even if I don't call the "mySerial.begin(......)", it still results in fingerprint sensor not found.

Using hardware serial I am able to map UART 1 to the GPIO 18 and 19 right? Do you have any idea on why it is not working?

I would suggest to try to use UART2 with GPIO16 (Rx) and GPIO17(Tx) with the ESP32 WROOM.

#include <HardwareSerial.h>
HardwareSerial SerialPort(2)

and then

Adafruit_Fingerprint finger = Adafruit_Fingerprint(& SerialPort);

and in the setup try with just the

  finger.begin(57600);

and don't do the

  SerialPort.begin(57600, SERIAL_8N1, 16, 17); 

I've not looked into Adafruit's library but 16 and 17 are the defaults pins, SERIAL_8N1 is the default mode and so with a bit of luck, what Adafruit does in their begin() function is enough to setup the port once, correctly.

No need to create your own HardwareSerial object. In fact it may cause problems as the current ESP32 core already has all three UARTS pre-assigned to Serial, Serial1, and Serial2. See HardwareSerial.cpp:

#if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC
HardwareSerial Serial0(0);
#else
HardwareSerial Serial(0);
#endif
#if SOC_UART_NUM > 1
HardwareSerial Serial1(1);
#endif
#if SOC_UART_NUM > 2
HardwareSerial Serial2(2);
#endif

true indeed

@kwetes

then get rid of

#include <HardwareSerial.h>
HardwareSerial SerialPort(2)

just try with just

Adafruit_Fingerprint finger = Adafruit_Fingerprint(& Serial2);

and in the setup try with just the

  finger.begin(57600);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.