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;
}
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.
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