esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

GROW R503 Fingerprint reader keep restarting once I scan a finger #6095

Open azen0k opened 1 month ago

azen0k commented 1 month ago

The problem

Hi! I'm encourtering an issue with the GROW Fingerprint reader R503. It make the ESP32 reboot when scanning a finger. When I unplug the UART BUS the board doesn't restart when I start scanning but obviously it doesn't work either.

It restart only with the UART connected.

The logs reports a CORRUPTED address.

I tried 4 boards (ESP32 WROOM 32 USBC or USB micro / Nodemcu v2 / Nodemcu V3) and i always have the same behaviour.

The fingerprint is recognized and seems to be correctly wired (Aura LED working as intended)

Which version of ESPHome has the issue?

2024.7.2

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.7.2

What platform are you using?

ESP32

Board

Generic AliExpress ESP32 WROOM 32 USBC

Component causing the issue

UART?

Example YAML snippet

substitutions:
  name: cabane-a-velo
  friendly_name: Cabane-a-velo

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  min_version: 2024.6.0
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'

esp32:
  board: esp32dev
  framework: 
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  services:
  - service: enroll
    variables:
      finger_id: int
      num_scans: int
    then:
      - fingerprint_grow.enroll:
          finger_id: !lambda 'return finger_id;'
          num_scans: !lambda 'return num_scans;'
  - service: cancel_enroll
    then:
      - fingerprint_grow.cancel_enroll:
  - service: delete
    variables:
      finger_id: int
    then:
      - fingerprint_grow.delete:
          finger_id: !lambda 'return finger_id;'
  - service: delete_all
    then:
      - fingerprint_grow.delete_all:
# Allow Over-The-Air updates
ota:
- platform: esphome

wifi:
  ssid: "****"
  password: "****"

# Set up a wifi access point
  ap: {}

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.

# To have a "next url" for improv serial
web_server:

#UART 2 !!    
uart:
  rx_pin: GPIO16
  tx_pin: GPIO17
  baud_rate: 57600

fingerprint_grow:
  sensing_pin: GPIO4

  on_finger_scan_start:
    - fingerprint_grow.aura_led_control:
        state: BREATHING
        color: PURPLE
        speed: 250
        count: 5

  on_finger_scan_invalid:
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Invalid finger"
    - fingerprint_grow.aura_led_control:
        state: FLASHING
        color: RED
        speed: 25
        count: 5

  on_finger_scan_matched:
    #- homeassistant.event:
    #    event: esphome.cabane_finger_scan_matched
    #    data:
    #      finger_id: !lambda 'return finger_id;'
    #      confidence: !lambda 'return confidence;'
    - fingerprint_grow.aura_led_control: 
        state: FLASHING
        color: GREEN
        speed: 25
        count: 5
    - text_sensor.template.publish:
        id: fingerprint_state
        state: !lambda 'return "Authorized finger " + to_string(finger_id) + ", confidence " + to_string(confidence);'
  # Pushing a tag_scanned event based on finger_id only if confidence is greater than 50
    - if:
        condition:
          lambda: 'return confidence > 50;'
        then:
        - homeassistant.tag_scanned: !lambda |-
            switch (finger_id) {
              case 0:
                return "person_a";
              case 1:
                return "person_b";
              default:
                return "person_unknown";
            }
        - switch.turn_off: relay
        - delay: 15s
        - switch.turn_on: relay

  on_finger_scan_unmatched:
    - fingerprint_grow.aura_led_control: 
        state: FLASHING
        speed: 25
        color: RED
        count: 2

  on_finger_scan_misplaced:
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Misplaced finger"
    - fingerprint_grow.aura_led_control: 
        state: BREATHING
        color: PURPLE
        speed: 250
        count: 5

  on_enrollment_scan:
    #- homeassistant.event:
    #    event: esphome.cabane_finger_enrollment_scan
    #    data:
    #      finger_id: !lambda 'return finger_id;'
    #      scan_num: !lambda 'return scan_num;'
    - fingerprint_grow.aura_led_control: 
        state: FLASHING
        speed: 25
        color: BLUE
        count: 2
    - fingerprint_grow.aura_led_control:
        state: ALWAYS_ON
        speed: 0
        color: PURPLE
        count: 0

  on_enrollment_done:
    #- homeassistant.event:
    #    event: esphome.cabane_finger_enrollment_done
    #    data:
    #      finger_id: !lambda 'return finger_id;'
    - fingerprint_grow.aura_led_control:
        state: BREATHING
        speed: 250
        color: GREEN
        count: 2

  on_enrollment_failed:
    #- homeassistant.event:
    #    event: esphome.cabane_finger_enrollment_failed
    #    data:
    #      finger_id: !lambda 'return finger_id;'
    - fingerprint_grow.aura_led_control:
        state: BREATHING
        speed: 25
        color: RED
        count: 4

switch:
  - platform: gpio
    id: relay
    pin: GPIO23
    restore_mode: ALWAYS_ON
    name: "Relay 12V"

  - platform: restart
    name: "Cabanavelo Restart"

button:
  - platform: template
    id: button_relay
    on_press: 
      then:
        - switch.turn_off: relay
        - delay: 15s
        - switch.turn_on: relay

text_sensor:
  - platform: template
    id: fingerprint_state
    name: "${friendly_name} State"
  - platform: version
    name: "${friendly_name} ESPHome Version"    

binary_sensor:
  - platform: fingerprint_grow
    id: fingerprint_enrolling
    name: "${friendly_name} Enrolling"

# Status de connection
  - platform: status
    name: "${friendly_name} Status"

# Intégration des entités capteur pour Lovelace
sensor:
  - platform: fingerprint_grow
    fingerprint_count:
      name: "${friendly_name} Count"
    last_finger_id:
      name: "${friendly_name} Last Finger ID"
    last_confidence:
      name: "${friendly_name} Last Confidence"
    status:
      name: "${friendly_name} Status"
    capacity:
      name: "${friendly_name} Capacity"
    security_level:
      name: "${friendly_name} Security Level"
  - platform: wifi_signal
    name: "${friendly_name} WiFi Signal"
    update_interval: 60s

Anything in the logs that might be useful for us?

[12:12:43][I][logger:156]: Log initialized
[12:12:43][C][safe_mode:079]: There have been 3 suspected unsuccessful boot attempts
[12:12:43][D][esp32.preferences:114]: Saving 1 preferences to flash...
[12:12:43][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[12:12:43][I][app:029]: Running through setup()...
[12:12:43][C][uart.arduino_esp32:077]: Setting up UART...
[12:12:43][C][switch.gpio:011]: Setting up GPIO Switch 'Relay 12V'...
[12:12:43][D][switch:012]: 'Relay 12V' Turning ON.
[12:12:43][D][switch:055]: 'Relay 12V': Sending state ON
[12:12:43][D][switch:012]: 'Relay 12V' Turning ON.
[12:12:43][C][fingerprint_grow:060]: Setting up Grow Fingerprint Reader...
[12:12:43][D][fingerprint_grow:232]: Checking password
[12:12:43][D][fingerprint_grow:237]: Password verified
[12:12:43][D][fingerprint_grow:260]: Getting parameters
[12:12:43][D][fingerprint_grow:263]: Got parameters
[12:12:43][D][sensor:094]: 'Cabane-a-velo Status': Sending state 4.00000  with 0 decimals of accuracy
[12:12:43][D][sensor:094]: 'Cabane-a-velo Capacity': Sending state 200.00000  with 0 decimals of accuracy
[12:12:43][D][sensor:094]: 'Cabane-a-velo Security Level': Sending state 3.00000  with 0 decimals of accuracy
[12:12:43][D][binary_sensor:036]: 'Cabane-a-velo Enrolling': Sending state OFF
[12:12:43][D][fingerprint_grow:285]: Getting fingerprint count
[12:12:43][D][fingerprint_grow:288]: Got fingerprint count
[12:12:43][D][sensor:094]: 'Cabane-a-velo Count': Sending state 0.00000  with 0 decimals of accuracy
[12:12:43][D][text_sensor:064]: 'Cabane-a-velo ESPHome Version': Sending state '2024.7.2 Jul 28 2024, 11:52:05'
[12:12:43][D][binary_sensor:034]: 'Cabane-a-velo Status': Sending initial state OFF
[12:12:43][C][wifi:047]: Setting up WiFi...
[12:12:43][C][wifi:060]: Starting WiFi...
[12:12:43][C][wifi:061]:   Local MAC: 08:D1:F9:E1:64:B0
[12:12:43][D][wifi:481]: Starting scan...
[12:12:43][D][fingerprint_grow:348]: Setting Aura LED
[12:12:43][D][fingerprint_grow:352]: Aura LED set
[12:12:43][D][fingerprint_grow:125]: Scan and match
[12:12:43][D][fingerprint_grow:156]: Getting image 1
[12:12:43][D][fingerprint_grow:168]: Finger Misplaced
[12:12:43][D][text_sensor:064]: 'Cabane-a-velo State': Sending state 'Misplaced finger'
[12:12:48]E (10927) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
[12:12:48]E (10927) task_wdt:  - loopTask (CPU 1)
[12:12:48]E (10927) task_wdt: Tasks currently running:
[12:12:48]E (10927) task_wdt: CPU 0: IDLE
[12:12:48]E (10927) task_wdt: CPU 1: IDLE
[12:12:48]E (10927) task_wdt: Aborting.
[12:12:48]
[12:12:48]abort() was called at PC 0x400fd388 on core 0
[12:12:48]
[12:12:48]
[12:12:48]Backtrace:0x400837f5:0x3ffbe9bc |<-CORRUPTED
[12:12:48]
[12:12:48]
[12:12:48]
[12:12:48]
[12:12:48]ELF file SHA256: 0000000000000000
[12:12:48]
[12:12:48]Rebooting...
[12:12:48]ets Jul 29 2019 12:21:46
[12:12:48]
[12:12:48]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[12:12:48]configsip: 0, SPIWP:0xee
[12:12:48]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[12:12:48]mode:DIO, clock div:2
[12:12:48]load:0x3fff0030,len:1184
[12:12:48]load:0x40078000,len:13132
[12:12:48]load:0x40080400,len:3036
[12:12:48]entry 0x400805e4
[12:12:48][I][logger:156]: Log initialized
[12:12:48][C][safe_mode:079]: There have been 4 suspected unsuccessful boot attempts
[12:12:48][D][esp32.preferences:114]: Saving 1 preferences to flash...
[12:12:48][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[12:12:48][I][app:029]: Running through setup()...
[12:12:48][C][uart.arduino_esp32:077]: Setting up UART...
[12:12:48][C][switch.gpio:011]: Setting up GPIO Switch 'Relay 12V'...
[12:12:49][D][switch:012]: 'Relay 12V' Turning ON.
[12:12:49][D][switch:055]: 'Relay 12V': Sending state ON
[12:12:49][D][switch:012]: 'Relay 12V' Turning ON.
[12:12:49][C][fingerprint_grow:060]: Setting up Grow Fingerprint Reader...
[12:12:49][D][fingerprint_grow:232]: Checking password
[12:12:49][D][fingerprint_grow:237]: Password verified
[12:12:49][D][fingerprint_grow:260]: Getting parameters
[12:12:49][D][fingerprint_grow:263]: Got parameters
[12:12:49][D][sensor:094]: 'Cabane-a-velo Status': Sending state 4.00000  with 0 decimals of accuracy
[12:12:49][D][sensor:094]: 'Cabane-a-velo Capacity': Sending state 200.00000  with 0 decimals of accuracy
[12:12:49][D][sensor:094]: 'Cabane-a-velo Security Level': Sending state 3.00000  with 0 decimals of accuracy
[12:12:49][D][binary_sensor:036]: 'Cabane-a-velo Enrolling': Sending state OFF
[12:12:49][D][fingerprint_grow:285]: Getting fingerprint count
[12:12:49][D][fingerprint_grow:288]: Got fingerprint count
[12:12:49][D][sensor:094]: 'Cabane-a-velo Count': Sending state 0.00000  with 0 decimals of accuracy
[12:12:49][D][text_sensor:064]: 'Cabane-a-velo ESPHome Version': Sending state '2024.7.2 Jul 28 2024, 11:52:05'
[12:12:49][D][binary_sensor:034]: 'Cabane-a-velo Status': Sending initial state OFF
[12:12:49][C][wifi:047]: Setting up WiFi...
[12:12:49][C][wifi:060]: Starting WiFi...
[12:12:49][C][wifi:061]:   Local MAC: 08:D1:F9:E1:64:B0
[12:12:49][D][wifi:481]: Starting scan...
[12:12:49][D][fingerprint_grow:348]: Setting Aura LED
[12:12:49][D][fingerprint_grow:352]: Aura LED set
[12:12:49][D][fingerprint_grow:125]: Scan and match
[12:12:49][D][fingerprint_grow:156]: Getting image 1
[12:12:49][D][fingerprint_grow:168]: Finger Misplaced
[12:12:49][D][text_sensor:064]: 'Cabane-a-velo State': Sending state 'Misplaced finger'
[12:12:53]E (10927) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
[12:12:53]E (10927) task_wdt:  - loopTask (CPU 1)
[12:12:54]E (10927) task_wdt: Tasks currently running:
[12:12:54]E (10927) task_wdt: CPU 0: IDLE
[12:12:54]E (10927) task_wdt: CPU 1: IDLE
[12:12:54]E (10927) task_wdt: Aborting.
[12:12:54]
[12:12:54]abort() was called at PC 0x400fd388 on core 0
[12:12:54]
[12:12:54]
[12:12:54]Backtrace:0x400837f5:0x3ffbe9bc |<-CORRUPTED
[12:12:54]
[12:12:54]
[12:12:54]
[12:12:54]
[12:12:54]ELF file SHA256: 0000000000000000
[12:12:54]
[12:12:54]Rebooting...
[12:12:54]ets Jul 29 2019 12:21:46
[12:12:54]
[12:12:54]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[12:12:54]configsip: 0, SPIWP:0xee
[12:12:54]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[12:12:54]mode:DIO, clock div:2
[12:12:54]load:0x3fff0030,len:1184
[12:12:54]load:0x40078000,len:13132
[12:12:55]load:0x40080400,len:3036
[12:12:55]entry 0x400805e4
[12:12:55][I][logger:156]: Log initialized
[12:12:55][C][safe_mode:079]: There have been 5 suspected unsuccessful boot attempts
[12:12:55][D][esp32.preferences:114]: Saving 1 preferences to flash...
[12:12:55][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[12:12:55][I][app:029]: Running through setup()...
[12:12:55][C][uart.arduino_esp32:077]: Setting up UART...
[12:12:55][C][switch.gpio:011]: Setting up GPIO Switch 'Relay 12V'...
[12:12:55][D][switch:012]: 'Relay 12V' Turning ON.
[12:12:55][D][switch:055]: 'Relay 12V': Sending state ON
[12:12:55][D][switch:012]: 'Relay 12V' Turning ON.
[12:12:55][C][fingerprint_grow:060]: Setting up Grow Fingerprint Reader...
[12:12:55][D][fingerprint_grow:232]: Checking password
[12:12:55][D][fingerprint_grow:237]: Password verified
[12:12:55][D][fingerprint_grow:260]: Getting parameters
[12:12:55][D][fingerprint_grow:263]: Got parameters
[12:12:55][D][sensor:094]: 'Cabane-a-velo Status': Sending state 4.00000  with 0 decimals of accuracy
[12:12:55][D][sensor:094]: 'Cabane-a-velo Capacity': Sending state 200.00000  with 0 decimals of accuracy
[12:12:56][D][sensor:094]: 'Cabane-a-velo Security Level': Sending state 3.00000  with 0 decimals of accuracy
[12:12:56][D][binary_sensor:036]: 'Cabane-a-velo Enrolling': Sending state OFF
[12:12:56][D][fingerprint_grow:285]: Getting fingerprint count
[12:12:56][D][fingerprint_grow:288]: Got fingerprint count
[12:12:56][D][sensor:094]: 'Cabane-a-velo Count': Sending state 0.00000  with 0 decimals of accuracy
[12:12:56][D][text_sensor:064]: 'Cabane-a-velo ESPHome Version': Sending state '2024.7.2 Jul 28 2024, 11:52:05'
[12:12:56][D][binary_sensor:034]: 'Cabane-a-velo Status': Sending initial state OFF
[12:12:56][C][wifi:047]: Setting up WiFi...
[12:12:56][C][wifi:060]: Starting WiFi...
[12:12:56][C][wifi:061]:   Local MAC: 08:D1:F9:E1:64:B0
[12:12:56][D][wifi:481]: Starting scan...
[12:12:56][D][fingerprint_grow:348]: Setting Aura LED
[12:12:56][D][fingerprint_grow:352]: Aura LED set
[12:12:56][D][fingerprint_grow:125]: Scan and match
[12:12:56][D][fingerprint_grow:156]: Getting image 1
[12:12:56][D][fingerprint_grow:168]: Finger Misplaced
[12:12:56][D][text_sensor:064]: 'Cabane-a-velo State': Sending state 'Misplaced finger'

Additional information

With the latest board I have also a continuous fingerprint read. The Grow R503 seems to detect a finger on its own.

azen0k commented 1 month ago

On every board I get the "CORRUPTED" log

I also tried the external components as mentionned in Issues 5502

external_components:
  - source: github://alexborro/esphome@Sleep_mode_rebase
    refresh: 0s
    components: [ fingerprint_grow ]

Same behaviour

azen0k commented 1 month ago

I just tried to compile firmware with older version 2024.3.2 (HA Community topic)

Same issue

nguyenquangduc commented 1 month ago

i also faced the same problem.i am using r303 fingerprint which has no touch detection output and my esp hangs very often and won't restart

azen0k commented 1 month ago

Just tried to compile with ESP-IDF. Same result.

logs (1).txt

azen0k commented 1 month ago

Just received an ESP32-S3-WROOM-1 and it works.

Edit: After some testing it crashes too but I think I might have found where the issue is. The setting of an aura led colour/speed/count is in fact a delay before any other operation. If I had the same delay equal to the speed count 10ms. The board don't crash. As I don't master coding. Maybe a hint ?