I'm new to the ESP32 world and currently working on a university project where I need to use the AS608 fingerprint sensor with my ESP32 (ESP-32S with CP2102 driver). I have tried various configurations using different UART pins, but no matter what I try, I always get the following message in the serial monitor:
Adafruit Fingerprint sensor enrollment
Did not find fingerprint sensor :(
I am using the example code from the Adafruit Fingerprint Library, as shown below:
No matter which GPIO pins I try, it always gives the same result: "Did not find fingerprint sensor :(". I have also double-checked my wiring, and the baud rate seems to be correctly set at 57600.
Has anyone experienced a similar issue, or is there something I might be missing? I would really appreciate any advice, as this is for a university project, and I am running out of time.
I moved your topic to a more appropriate forum category @gregorynunez.
The Nano ESP32 category you chose is only used for discussions directly related to the Arduino Nano ESP32 board.
In the future, please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.
Software serial does not work on an ESP processor because all the registers it uses are different. So you will have to use the hardware UART pins that the processor does have. Search for examples of this on line, or look at the data sheet for the specific sort of ESP32 you have.
Also the ESP32 is a 3V3 processor and as such will only produce 3V3 signals. Will your finger print sensor work at such a low voltage or will the signals from the processor need level shifting?
UART1 has non-usable pins by default, so even though you can map those pins, chances are your library will overwrite those definitions. For now just use UART2 on it's default pins (rx = 16 & tx = 17)
#if (defined(__AVR__) || defined(ESP8266)) && !defined(__AVR_ATmega2560__)
SoftwareSerial mySerial(2, 3); // this won't be compiled on an ESP32
#else
#define mySerial Serial2 // but this will be used instead
#endif
UART1 can be used, but it is a tad more complex to do so.
Nice picture but I cannot tell anything from it, it looks like some parts and wire on a table.
Provide Clear Documentation: Since we can’t see your project, share an annotated schematic (best) or a clear drawing of your setup. Pictures are welcome, but avoid using Fritzing diagrams as they are wiring diagrams, not schematics, and are not ideal for troubleshooting.
Include Technical Details: If there is specific hardware involved, include links to technical information. There are often many versions of similar components, so precise details are essential.
I was trying to use an ESP32 with an AS608 fingerprint sensor using the Adafruit example code, which utilizes SoftwareSerial. However, the code wasn't working because SoftwareSerial isn't compatible with my ESP32.
Someone on a forum suggested not using SoftwareSerial with ESP32 since it has multiple hardware UARTs. Here's how I resolved the issue:
Removed SoftwareSerial
Used ESP32's Hardware Serial (Serial2):
utilized the built-in Serial2 hardware serial port of the ESP32.
Assigned GPIO Pins for RX and TX
Initialized Serial2 with Correct Settings
Modified the Adafruit_Fingerprint object to use Serial2
here is the code whise work fort me
(Note 1. remember im no good on this, maybe it is better way for do it.)
(Note 2. the code have some word's on Spanish because its my main lenguage, but maybe it work for some people)
The code:
#include <Adafruit_Fingerprint.h>
// Definir los pines para RX y TX
#define RXD2 16 // Pin RX2 del ESP32 (conectar al TX del sensor)
#define TXD2 17 // Pin TX2 del ESP32 (conectar al RX del sensor)
// Utilizar la instancia predefinida de Serial2
// No necesitamos crear una nueva instancia de HardwareSerial
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2);
uint8_t id;
void setup() {
Serial.begin(115200);
while (!Serial); // Esperar a que se abra el puerto serie
delay(100);
Serial.println("\n\nRegistro de huellas dactilares con sensor Adafruit");
// Inicializar Serial2 con los pines especificados
Serial2.begin(57600, SERIAL_8N1, RXD2, TXD2);
// Iniciar el sensor de huellas dactilares
finger.begin(57600);
if (finger.verifyPassword()) {
Serial.println("¡Sensor de huellas dactilares encontrado!");
} else {
Serial.println("No se encontró el sensor de huellas dactilares :(");
while (1) { delay(1); }
}
Serial.println(F("Leyendo parámetros del sensor"));
finger.getParameters();
Serial.print(F("Estado: 0x")); Serial.println(finger.status_reg, HEX);
Serial.print(F("ID del sistema: 0x")); Serial.println(finger.system_id, HEX);
Serial.print(F("Capacidad: ")); Serial.println(finger.capacity);
Serial.print(F("Nivel de seguridad: ")); Serial.println(finger.security_level);
Serial.print(F("Dirección del dispositivo: ")); Serial.println(finger.device_addr, HEX);
Serial.print(F("Longitud del paquete: ")); Serial.println(finger.packet_len);
Serial.print(F("Velocidad en baudios: ")); Serial.println(finger.baud_rate);
}
uint8_t readnumber(void) {
uint8_t num = 0;
while (num == 0) {
while (!Serial.available());
num = Serial.parseInt();
}
return num;
}
void loop() {
Serial.println("¡Listo para registrar una huella dactilar!");
Serial.println("Por favor, escribe el ID # (de 1 a 127) donde deseas guardar esta huella...");
id = readnumber();
if (id == 0) { // ID #0 no permitido, intenta de nuevo
return;
}
Serial.print("Registrando ID #");
Serial.println(id);
while (!getFingerprintEnroll());
}
uint8_t getFingerprintEnroll() {
int p = -1;
Serial.print("Esperando una huella válida para registrar como #"); Serial.println(id);
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Imagen tomada");
break;
case FINGERPRINT_NOFINGER:
Serial.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Error de comunicación");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Error al capturar imagen");
break;
default:
Serial.println("Error desconocido");
break;
}
}
// Imagen capturada correctamente
p = finger.image2Tz(1);
switch (p) {
case FINGERPRINT_OK:
Serial.println("Imagen convertida");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Imagen muy desordenada");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Error de comunicación");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("No se pudieron encontrar características de la huella");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("No se pudieron encontrar características de la huella");
return p;
default:
Serial.println("Error desconocido");
return p;
}
Serial.println("Retira el dedo");
delay(2000);
p = 0;
while (p != FINGERPRINT_NOFINGER) {
p = finger.getImage();
}
Serial.print("ID "); Serial.println(id);
p = -1;
Serial.println("Coloca el mismo dedo nuevamente");
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Imagen tomada");
break;
case FINGERPRINT_NOFINGER:
Serial.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Error de comunicación");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Error al capturar imagen");
break;
default:
Serial.println("Error desconocido");
break;
}
}
// Segunda imagen capturada correctamente
p = finger.image2Tz(2);
switch (p) {
case FINGERPRINT_OK:
Serial.println("Imagen convertida");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Imagen muy desordenada");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Error de comunicación");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("No se pudieron encontrar características de la huella");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("No se pudieron encontrar características de la huella");
return p;
default:
Serial.println("Error desconocido");
return p;
}
// Crear modelo a partir de las dos imágenes
Serial.print("Creando modelo para #"); Serial.println(id);
p = finger.createModel();
if (p == FINGERPRINT_OK) {
Serial.println("¡Huellas coinciden!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Error de comunicación");
return p;
} else if (p == FINGERPRINT_ENROLLMISMATCH) {
Serial.println("Las huellas no coinciden");
return p;
} else {
Serial.println("Error desconocido");
return p;
}
// Almacenar el modelo en la posición especificada
Serial.print("ID "); Serial.println(id);
p = finger.storeModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("¡Guardado!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Error de comunicación");
return p;
} else if (p == FINGERPRINT_BADLOCATION) {
Serial.println("No se pudo guardar en esa ubicación");
return p;
} else if (p == FINGERPRINT_FLASHERR) {
Serial.println("Error al escribir en la memoria flash");
return p;
} else {
Serial.println("Error desconocido");
return p;
}
return true;
}
Thank you all for the help, I have to admit in these last few days I was very stressed because my project was not working, and as I said at the beginning of the post it is for a university project, y'll are great people and with people like you the community only gets better <3