0

I am working in ArduinoIDE with ESP32 and TFP625A fingerprint sensor. The sensor is connected to UART2 and served by the FPM library using HardwareSerial. Everything works fine until a programmatically reboot is performed - ESP.restart(). After this command, the microcontroller reboots and stucks at the place of sensor initialization. I inserted some Serial.print() into the HardwareSerial source code file and saw that in the HardwareSerial::begin() function, the code does not go further than this place

_uart = uartBegin(_uart_nr, baud ? baud : 9600, config, rxPin, txPin, 256, invert);

As I understand it, after rebooting the microcontroller, information about the previously configured UART2 remains in its registers. Attempts to zero the UART before rebooting the microcontroller do not correct the situation. If I make hardware restart the microcontroller by the reset button, then everything works fine.

How to overcome ESP32 stuck?

Snippets of code:

#include <HardwareSerial.h>
#include <FPM.h>

HardwareSerial mySerial(2);
FPM fpm(&mySerial);
...
void freeFPM()
{
    fpm = 0;
    mySerial.end();
    mySerial = 0;
}

bool fpm_setup()
{
    freeFPM();
    mySerial = HardwareSerial(2);
    finger = FPM(&mySerial);
    mySerial.begin(57600);
    fpm.begin(0);
}

void restartESP()
{
    freeFPM();
    ESP.restart();
}
Olejan
  • 183
  • 3
  • 9

1 Answers1

0

I think you need to include a hard reset of the sensor when the ESP32 restarts. I am not familiar with that particular sensor but I've had similar issues. What I did was to wire the reset input of the sensor to a GPIO output on the ESP32 and then one of the first steps in the code is to pull down that pin for a short while to reset it.

I think what is happening is that when you first switch on the project the sensor is reset by its own power on reset mechanism but when you do the software reset of the ESP32 the sensor is not also reset, hence why I think you need to do it as I described above.

Christian
  • 187
  • 5