ESPHOME Fingerprint Reader and NFC Tag Reader issues

Hi,
I have an ESPHOME project ongoing for my garage control using a NFC Reader and Fingerprint reader (a rotary encoder for reading the garage doorsw position and some other digital IOs)

Generically it works, but I have response issues with the NFC and Fingerprint reader and the publishing of the NFC text sensor to HA

NFC Reader PN532 connected via I2C

  • it seems sometimes to not recognize the NFC tag (If I hold the NFC tag in front of the reader every 3 seconds it only recognizes sometime only one Tag)
  • Message “Component pn532 took a long time for an operation (68 ms).”
  • although the log shows detecting a NFC reader with the ID - the corresponing text sensor in HA is not always updated (sometimes not within 5 minutes)

Fingerprint Reader R307 connected via serial

  • repeated message: “Component fingerprint_grow took a long time for an operation (324 ms).”

I don’t know if this is a too complex setup, but the from memory perspective is seems OK.
#RAM: [= ] 7.8% (used 41472 bytes from 532480 bytes)
#Flash: [===== ] 54.5% (used 1000705 bytes from 1835008 bytes)

Has someone an suggestion what to do to debug further?

Many thanks,
Rainer

YAML ---------------------------

#ESPHOME Garagentorsteuerung
#Stand 01.04.2025
# Konfiguration:
#	 Digital Input 2x
#	 - Reed Relay 
#      GPIO34
#      GPIO35
#  - Rotary Encoder
#	   GPIO13 # cable white
#    GPIO14 # cable green
#	 Digital Output 2x
#	 - Relay
#      GPIO26
#      GPIO27
#   - LED
#      GPIO25 #Status Alive LED
#   I2C
#      sda: GPIO21
#      scl: GPIO22
#	    - devices
#       Luminescent sensor bh1750 0x23
#       NFC Reader PN532-Mod #adresse 0x24
#   Uart:
#     tx_pin: GPIO17 #cable green
#     rx_pin: GPIO16 #cabe yellow
#     -devices
#       Fingerprint Reader R307

esphome:
  name: garagentorsteuerung
  friendly_name: Garagentorsteuerung
  on_boot:
    priority: -100
    then:
      - output.turn_on: StatusLED_slow_blink
      - output.set_level:
          id: StatusLED_slow_blink
          level: "50%"

esp32:
  # https://registry.platformio.org/platforms/platformio/espressif32/boards?version=5.3.0
  board: az-delivery-devkit-v4
  framework:
    type: arduino

# Enable logging
logger: 
    level: debug # keep empty otherwise

# Enable Home Assistant API
api:
  encryption:
    key: !secret GS_api_key
  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: enroll_next # Idea by Ralf Klüber (thanks!)
    variables:
      num_scans: int
    then:
      - fingerprint_grow.enroll:
          finger_id: !lambda 'return id(fingerprint_count).state;'
          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:

ota:
  - platform: esphome
    password: !secret GS_ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "GSFallbackHotspot"
    password: !secret GS_ap_password

captive_portal:

# https://esphome.io/components/i2c
# https://lastminuteengineers.com/esp32-pinout-reference/
i2c:
  - id: i2c0
    sda: GPIO21
    scl: GPIO22
    scan: true  
    frequency: 400kHz # 10 kHz Minimale Frequenz möglich-------------------------------

# https://github.com/esphome/esphome-docs/blob/59eaa4f9ff7a9c84b30aaadd9f40f3fd3defeeb2/components/sensor/sht4x.rst  
# Address 0x70
# https://esphome.io/components/sensor/bh1750
# Address 0x23
# https://esphome.io/components/sensor/tof10120.html
# Address: 0x52
# Outputs
# https://esphome.io/components/switch/gpio.html
# Inputs
# https://esphome.io/components/binary_sensor/gpio.html#


# -------------------------------
# https://esphome.io/components/binary_sensor/pn532.html
pn532_i2c:
  update_interval: 1s
  on_tag:
    then:
    - text_sensor.template.publish:
        id: rfid_tag
        state: !lambda 'return x;'

# -------------------------------

#--------------------------------
# https://community.home-assistant.io/t/garage-fingerprint-sensor/312977
# https://esphome.io/components/fingerprint_grow.html
uart:
  tx_pin: GPIO17 #green
  rx_pin: GPIO16 # yellow
  baud_rate: 57600

fingerprint_grow:
  sensing_pin: GPIO5 # blue
  update_interval: 0.5s #https://github.com/esphome/issues/issues/5608
  sensor_power_pin:
    number: GPIO18 # white 
    inverted: true
  idle_period_to_sleep: 5s
  on_finger_scan_matched:
    - switch.turn_on: GS_Ouput_GPIO27
    - fingerprint_grow.aura_led_control:
        state: BREATHING
        speed: 200
        color: BLUE
        count: 1
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Authorized finger"
    - delay: 1s
    - switch.turn_off: GS_Ouput_GPIO27
  on_finger_scan_unmatched:
    - fingerprint_grow.aura_led_control:
        state: FLASHING
        speed: 25
        color: BLUE #RED
        count: 2
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Unauthorized finger"
  on_enrollment_scan:
    - 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
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Finger scanned"
  on_enrollment_done:
    - fingerprint_grow.aura_led_control:
        state: BREATHING
        speed: 100
        color: BLUE
        count: 2
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Enrolled fingerprint"
  on_enrollment_failed:
    - fingerprint_grow.aura_led_control:
        state: FLASHING
        speed: 25
        color: RED
        count: 4
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Failed to enroll fingerprint"

text_sensor:
  - platform: template
    id: fingerprint_state
    name: "Garage Fingerprint State"
  - platform: template
    name: "RFID Tag"
    id: rfid_tag



#--------------------------------------------------
# Output
# https://lastminuteengineers.com/esp32-pinout-reference/

output:
  - platform: gpio
    pin: GPIO27
    id: 'GPIO027'
  - platform: gpio
    pin: GPIO26
    id: 'GPIO026'
  - platform: slow_pwm
    pin: GPIO25
    id: StatusLED_slow_blink
    period: 2s

switch:
  - platform: output
    name: "GS Ouput GPIO27"
    id: GS_Ouput_GPIO27
    output: 'GPIO027'
  - platform: output
    name: "GS Output GPIO26"
    id: GS_Ouput_GPIO26
    output: 'GPIO026'


# Inputs
binary_sensor:
  - platform: gpio
    pin: GPIO34
    name: "GS Input DPIO34"
    id: GS_Input_GPIO34
    device_class: door
    on_release:  # change from  logic 1 to 0, "on_press" is 0 to 1
      then: 
        - sensor.rotary_encoder.set_value: 
            id: GS_Rotary_Encoder
            value: 0
      # - below: 0.5 # or reset below bottom end stop
      #   then:
      #     - sensor.rotary_encoder.set_value: 
      #         id: GS_Rotary_Encoder
      #         value: 0
  - platform: gpio
    pin: GPIO35
    name: "GS Input DPIO35"
    id: GS_Input_GPIO35
    device_class: door
    

sensor:
  - platform: rotary_encoder
    name: "GS Rotary Encoder"
    id: GS_Rotary_Encoder
    pin_a: GPIO13 # white
    pin_b: GPIO14 # green
    on_clockwise:
      - logger.log: "Turned Clockwise"
    on_anticlockwise:
      - logger.log: "Turned Anticlockwise"
    filters:
    - or:
      - throttle: 30s
      - delta: 10
  - platform: bh1750
    name: "BH1750 Illuminance"
    id: GS_I2C_BH1750_Illuminance
    address: 0x23
    update_interval: 60s
#sensor:
  - platform: fingerprint_grow
    fingerprint_count:
      name: "Garage Fingerprint Count"
      id: fingerprint_count
    last_finger_id:
      name: "Garage Fingerprint Last Finger ID"
    last_confidence:
      name: "Garage Fingerprint Last Confidence"
    status:
      name: "Garage Fingerprint Status"
    capacity:
      name: "Garage Fingerprint Capacity"
    security_level:
      name: "Garage Fingerprint Security Level"

Debugger LOG output ---------------------------

INFO ESPHome 2025.3.3
INFO Reading configuration /config/esphome/garagentorsteuerung.yaml...
WARNING GPIO5 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Starting log output from 192.168.1.181 using esphome API
INFO Successfully connected to garagentorsteuerung @ 192.168.1.181 in 0.049s
INFO Successful handshake with garagentorsteuerung @ 192.168.1.181 in 0.091s
[10:07:52][I][app:100]: ESPHome version 2025.3.3 compiled on Apr  1 2025, 09:33:21
[10:07:52][C][wifi:600]: WiFi:
[10:07:52][C][wifi:428]:   Local MAC: D8:BC:38:E4:6C:C8
[10:07:52][C][wifi:433]:   SSID: '217x205'[redacted]
[10:07:52][C][wifi:436]:   IP Address: 192.168.1.181
[10:07:52][C][wifi:440]:   BSSID: 44:4E:6D:14:E2:24[redacted]
[10:07:52][C][wifi:441]:   Hostname: 'garagentorsteuerung'
[10:07:52][C][wifi:443]:   Signal strength: -28 dB ▂▄▆█
[10:07:52][C][wifi:447]:   Channel: 6
[10:07:52][C][wifi:448]:   Subnet: 255.255.255.0
[10:07:52][C][wifi:449]:   Gateway: 192.168.1.1
[10:07:52][C][wifi:450]:   DNS1: 192.168.1.1
[10:07:52][C][wifi:451]:   DNS2: 0.0.0.0
[10:07:52][C][logger:177]: Logger:
[10:07:52][C][logger:178]:   Max Level: DEBUG
[10:07:52][C][logger:179]:   Initial Level: DEBUG
[10:07:52][C][logger:181]:   Log Baud Rate: 115200
[10:07:52][C][logger:182]:   Hardware UART: UART0
[10:07:52][C][i2c.arduino:071]: I2C Bus:
[10:07:52][C][i2c.arduino:072]:   SDA Pin: GPIO21
[10:07:52][C][i2c.arduino:073]:   SCL Pin: GPIO22
[10:07:52][C][i2c.arduino:074]:   Frequency: 400000 Hz
[10:07:52][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[10:07:52][I][i2c.arduino:096]: Results from i2c bus scan:
[10:07:52][I][i2c.arduino:102]: Found i2c device at address 0x23
[10:07:52][I][i2c.arduino:102]: Found i2c device at address 0x24
[10:07:52][C][uart.arduino_esp32:151]: UART Bus 1:
[10:07:52][C][uart.arduino_esp32:152]:   TX Pin: GPIO17
[10:07:52][C][uart.arduino_esp32:153]:   RX Pin: GPIO16
[10:07:52][C][uart.arduino_esp32:155]:   RX Buffer Size: 256
[10:07:52][C][uart.arduino_esp32:157]:   Baud Rate: 57600 baud
[10:07:52][C][uart.arduino_esp32:158]:   Data Bits: 8
[10:07:52][C][uart.arduino_esp32:159]:   Parity: NONE
[10:07:52][C][uart.arduino_esp32:160]:   Stop bits: 1
[10:07:52][C][template.text_sensor:020]: Template Sensor 'Garage Fingerprint State'
[10:07:52][C][template.text_sensor:020]: Template Sensor 'RFID Tag'
[10:07:52][C][gpio.output:010]: GPIO Binary Output:
[10:07:52][C][gpio.output:011]:   Pin: GPIO27
[10:07:52][C][gpio.output:010]: GPIO Binary Output:
[10:07:52][C][gpio.output:011]:   Pin: GPIO26
[10:07:52][C][output.slow_pwm:054]: Slow PWM Output:
[10:07:52][C][output.slow_pwm:055]:   Pin: GPIO25
[10:07:52][C][output.slow_pwm:065]:   Period: 2000 ms
[10:07:52][C][output.slow_pwm:066]:   Restart cycle on state change: NO
[10:07:52][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'GS Input DPIO35'
[10:07:52][C][gpio.binary_sensor:015]:   Device Class: 'door'
[10:07:52][C][gpio.binary_sensor:016]:   Pin: GPIO35
[10:07:52][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'GS Input DPIO34'
[10:07:52][C][gpio.binary_sensor:015]:   Device Class: 'door'
[10:07:52][C][gpio.binary_sensor:016]:   Pin: GPIO34
[10:07:52][C][output.switch:068]: Output Switch 'GS Ouput GPIO27'
[10:07:52][C][output.switch:091]:   Restore Mode: always OFF
[10:07:52][C][output.switch:068]: Output Switch 'GS Output GPIO26'
[10:07:52][C][output.switch:091]:   Restore Mode: always OFF
[10:07:52][C][pn532:431]: PN532:
[10:07:52][C][pn532:443]:   Update Interval: 1.0s
[10:07:52][C][pn532_i2c:125]:   Address: 0x24
[10:07:52][C][fingerprint_grow:537]: GROW_FINGERPRINT_READER:
[10:07:52][C][fingerprint_grow:538]:   System Identifier Code: 0x0200
[10:07:52][C][fingerprint_grow:540]:   Touch Sensing Pin: GPIO5
[10:07:52][C][fingerprint_grow:542]:   Sensor Power Pin: GPIO18
[10:07:52][C][fingerprint_grow:544]:   Idle Period to Sleep: 5000 ms
[10:07:52][C][fingerprint_grow:548]:   Update Interval: 0.5s
[10:07:52][C][fingerprint_grow:550]:   Fingerprint Count 'Garage Fingerprint Count'
[10:07:52][C][fingerprint_grow:550]:     State Class: ''
[10:07:52][C][fingerprint_grow:550]:     Unit of Measurement: ''
[10:07:52][C][fingerprint_grow:550]:     Accuracy Decimals: 0
[10:07:52][C][fingerprint_grow:550]:     Icon: 'mdi:fingerprint'
[10:07:52][C][fingerprint_grow:551]:     Current Value: 1
[10:07:52][C][fingerprint_grow:554]:   Status 'Garage Fingerprint Status'
[10:07:52][C][fingerprint_grow:554]:     State Class: ''
[10:07:52][C][fingerprint_grow:554]:     Unit of Measurement: ''
[10:07:52][C][fingerprint_grow:554]:     Accuracy Decimals: 0
[10:07:52][C][fingerprint_grow:555]:     Current Value: 2
[10:07:52][C][fingerprint_grow:558]:   Capacity 'Garage Fingerprint Capacity'
[10:07:52][C][fingerprint_grow:558]:     State Class: ''
[10:07:52][C][fingerprint_grow:558]:     Unit of Measurement: ''
[10:07:52][C][fingerprint_grow:558]:     Accuracy Decimals: 0
[10:07:52][C][fingerprint_grow:558]:     Icon: 'mdi:database'
[10:07:52][C][fingerprint_grow:559]:     Current Value: 1000
[10:07:52][C][fingerprint_grow:562]:   Security Level 'Garage Fingerprint Security Level'
[10:07:52][C][fingerprint_grow:562]:     State Class: ''
[10:07:52][C][fingerprint_grow:562]:     Unit of Measurement: ''
[10:07:52][C][fingerprint_grow:562]:     Accuracy Decimals: 0
[10:07:52][C][fingerprint_grow:562]:     Icon: 'mdi:security'
[10:07:52][C][fingerprint_grow:563]:     Current Value: 3
[10:07:52][C][fingerprint_grow:566]:   Last Finger ID 'Garage Fingerprint Last Finger ID'
[10:07:52][C][fingerprint_grow:566]:     State Class: ''
[10:07:52][C][fingerprint_grow:566]:     Unit of Measurement: ''
[10:07:52][C][fingerprint_grow:566]:     Accuracy Decimals: 0
[10:07:52][C][fingerprint_grow:566]:     Icon: 'mdi:account'
[10:07:52][C][fingerprint_grow:567]:     Current Value: 4294967295
[10:07:52][C][fingerprint_grow:570]:   Last Confidence 'Garage Fingerprint Last Confidence'
[10:07:52][C][fingerprint_grow:570]:     State Class: ''
[10:07:52][C][fingerprint_grow:570]:     Unit of Measurement: ''
[10:07:52][C][fingerprint_grow:570]:     Accuracy Decimals: 0
[10:07:52][C][fingerprint_grow:570]:     Icon: 'mdi:account-check'
[10:07:52][C][fingerprint_grow:571]:     Current Value: 4294967295
[10:07:52][C][rotary_encoder:164]: Rotary Encoder 'GS Rotary Encoder'
[10:07:52][C][rotary_encoder:164]:   State Class: ''
[10:07:52][C][rotary_encoder:164]:   Unit of Measurement: 'steps'
[10:07:52][C][rotary_encoder:164]:   Accuracy Decimals: 0
[10:07:52][C][rotary_encoder:164]:   Icon: 'mdi:rotate-right'
[10:07:52][C][rotary_encoder:165]:   Pin A: GPIO13
[10:07:52][C][rotary_encoder:166]:   Pin B: GPIO14
[10:07:52][C][rotary_encoder:180]:   Restore Mode: Restore (Defaults to zero)
[10:07:52][C][rotary_encoder:184]:   Resolution: 1 Pulse Per Cycle
[10:07:52][C][bh1750.sensor:118]: BH1750 'BH1750 Illuminance'
[10:07:52][C][bh1750.sensor:118]:   Device Class: 'illuminance'
[10:07:52][C][bh1750.sensor:118]:   State Class: 'measurement'
[10:07:52][C][bh1750.sensor:118]:   Unit of Measurement: 'lx'
[10:07:52][C][bh1750.sensor:118]:   Accuracy Decimals: 1
[10:07:52][C][bh1750.sensor:119]:   Address: 0x23
[10:07:52][C][bh1750.sensor:124]:   Update Interval: 60.0s
[10:07:52][C][captive_portal:089]: Captive Portal:
[10:07:52][C][mdns:116]: mDNS:
[10:07:52][C][mdns:117]:   Hostname: garagentorsteuerung
[10:07:52][C][esphome.ota:073]: Over-The-Air updates:
[10:07:52][C][esphome.ota:074]:   Address: garagentorsteuerung.local:3232
[10:07:52][C][esphome.ota:075]:   Version: 2
[10:07:52][C][esphome.ota:078]:   Password configured
[10:07:52][C][safe_mode:018]: Safe Mode:
[10:07:52][C][safe_mode:020]:   Boot considered successful after 60 seconds
[10:07:53][C][safe_mode:021]:   Invoke after 10 boot attempts
[10:07:53][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[10:07:53][C][api:140]: API Server:
[10:07:53][C][api:141]:   Address: garagentorsteuerung.local:6053
[10:07:53][C][api:143]:   Using noise encryption: YES
[10:07:56][D][fingerprint_grow:533]: Fingerprint sensor is now in sleep mode.
[10:07:57][D][fingerprint_grow:125]: Scan and match
[10:07:57][D][fingerprint_grow:156]: Getting image 1
[10:07:58][E][fingerprint_grow:509]: Timed out waiting for sensor wake-up
[10:07:58][D][fingerprint_grow:168]: Finger Misplaced
[10:07:58][W][component:237]: Component fingerprint_grow took a long time for an operation (320 ms).
[10:07:58][W][component:238]: Components should block for at most 30 ms.
[10:08:03][D][fingerprint_grow:533]: Fingerprint sensor is now in sleep mode.
[10:08:04][D][fingerprint_grow:125]: Scan and match
[10:08:04][D][fingerprint_grow:156]: Getting image 1
[10:08:04][E][fingerprint_grow:509]: Timed out waiting for sensor wake-up
[10:08:04][D][fingerprint_grow:168]: Finger Misplaced
[10:08:04][W][component:237]: Component fingerprint_grow took a long time for an operation (383 ms).
[10:08:04][W][component:238]: Components should block for at most 30 ms.
[10:08:09][D][pn532:364]: Mifare classic
[10:08:09][E][pn532.mifare_classic:101]: Authentication failed - Block 0x04
[10:08:09][D][text_sensor:064]: 'RFID Tag': Sending state 'FE-4C-FD-EC'
[10:08:09][D][pn532:200]: Found new tag 'FE-4C-FD-EC'
[10:08:09][D][pn532:379]: Waiting to read next tag
[10:08:09][W][component:237]: Component pn532 took a long time for an operation (121 ms).
[10:08:09][W][component:238]: Components should block for at most 30 ms.
[10:08:09][D][fingerprint_grow:533]: Fingerprint sensor is now in sleep mode.
[10:08:10][D][fingerprint_grow:125]: Scan and match
[10:08:10][D][fingerprint_grow:156]: Getting image 1
[10:08:11][E][fingerprint_grow:509]: Timed out waiting for sensor wake-up
[10:08:11][D][fingerprint_grow:168]: Finger Misplaced
[10:08:11][W][component:237]: Component fingerprint_grow took a long time for an operation (323 ms).
[10:08:11][W][component:238]: Components should block for at most 30 ms.
[10:08:13][D][pn532:364]: Mifare classic
[10:08:13][E][pn532.mifare_classic:101]: Authentication failed - Block 0x04
[10:08:13][D][text_sensor:064]: 'RFID Tag': Sending state 'FE-4C-FD-EC'
[10:08:13][D][pn532:200]: Found new tag 'FE-4C-FD-EC'
[10:08:13][D][pn532:379]: Waiting to read next tag
[10:08:13][W][component:237]: Component pn532 took a long time for an operation (110 ms).
[10:08:13][W][component:238]: Components should block for at most 30 ms.
[10:08:16][D][fingerprint_grow:533]: Fingerprint sensor is now in sleep mode.
[10:08:17][D][fingerprint_grow:125]: Scan and match
[10:08:17][D][fingerprint_grow:156]: Getting image 1
[10:08:17][E][fingerprint_grow:509]: Timed out waiting for sensor wake-up
[10:08:17][D][fingerprint_grow:168]: Finger Misplaced
[10:08:17][W][component:237]: Component fingerprint_grow took a long time for an operation (383 ms).
[10:08:17][W][component:238]: Components should block for at most 30 ms.
[10:08:22][D][fingerprint_grow:533]: Fingerprint sensor is now in sleep mode.
[10:08:23][D][fingerprint_grow:125]: Scan and match
[10:08:23][D][fingerprint_grow:156]: Getting image 1
[10:08:24][E][fingerprint_grow:509]: Timed out waiting for sensor wake-up
[10:08:24][D][fingerprint_grow:168]: Finger Misplaced
[10:08:24][W][component:237]: Component fingerprint_grow took a long time for an operation (324 ms).
[10:08:24][W][component:238]: Components should block for at most 30 ms.
[10:08:29][D][fingerprint_grow:533]: Fingerprint sensor is now in sleep mode.
[10:08:30][D][fingerprint_grow:125]: Scan and match
[10:08:30][D][fingerprint_grow:156]: Getting image 1
[10:08:30][E][fingerprint_grow:509]: Timed out waiting for sensor wake-up
[10:08:30][D][fingerprint_grow:168]: Finger Misplaced
[10:08:30][W][component:237]: Component fingerprint_grow took a long time for an operation (383 ms).
[10:08:30][W][component:238]: Components should block for at most 30 ms.
[10:08:35][D][bh1750.sensor:159]: 'BH1750 Illuminance': Got illuminance=151.4lx
[10:08:35][D][sensor:094]: 'BH1750 Illuminance': Sending state 151.44684 lx with 1 decimals of accuracy

These messages are quite “normal”, doesn’t mean that the component have problem.

That clearly tells that there is problem with HA or with connection between esphome and HA.

See two reading of tag with two sendings of text_sensor. So far looks it working as expected.
Beware - second one sent same value, means no change in sensor state in HA happened.

To catch every tag scan, even if same tag scanned can use:

    - homeassistant.tag_scanned: !lambda |-
        return x;

then in catch events as decribed here: Tags - Home Assistant

@Masterzz
Many thanks.

That could be indeed be the reason why the text sensor was not updated as
I was alswyys using the same tag.

But even after adding your recommended line (did I place it right - see snipped below) - HA text sensor is not udpated.

See picture for the text sensor and log output where I scanned several times the same tag, text sensor only shows it once.

Did I do someting wrong?

Many thanks,
Rainer

YAML snippt ------------------

pn532_i2c:
  update_interval: 1s
  on_tag:
    then:
    - text_sensor.template.publish:
        id: rfid_tag
        state: !lambda 'return x;'
    - homeassistant.tag_scanned: !lambda |-
        return x;

Log --------------------------

INFO ESPHome 2025.3.3
INFO Reading configuration /config/esphome/garagentorsteuerung.yaml...
WARNING GPIO5 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Compiling app...
Processing garagentorsteuerung (board: az-delivery-devkit-v4; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 520KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.1.4
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.3.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- Wire @ 2.0.0
|-- noise-c @ 0.1.6
Compiling .pioenvs/garagentorsteuerung/src/main.cpp.o
Linking .pioenvs/garagentorsteuerung/firmware.elf
RAM:   [=         ]   7.8% (used 41480 bytes from 532480 bytes)
Flash: [=====     ]  54.7% (used 1003989 bytes from 1835008 bytes)
Building .pioenvs/garagentorsteuerung/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/garagentorsteuerung/firmware.bin"], [".pioenvs/garagentorsteuerung/firmware.elf"])
SHA digest in image updated
Wrote 0x106860 bytes to file /data/build/garagentorsteuerung/.pioenvs/garagentorsteuerung/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/garagentorsteuerung/firmware.bin"], [".pioenvs/garagentorsteuerung/firmware.elf"])
========================= [SUCCESS] Took 14.67 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.1.181 port 3232...
INFO Connected to 192.168.1.181
INFO Uploading /data/build/garagentorsteuerung/.pioenvs/garagentorsteuerung/firmware.bin (1009760 bytes)
Uploading: [============================================================] 100% Done...

INFO Upload took 8.56 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.1.181 using esphome API
INFO Successfully connected to garagentorsteuerung @ 192.168.1.181 in 7.210s
INFO Successful handshake with garagentorsteuerung @ 192.168.1.181 in 0.116s
[12:15:01][I][app:100]: ESPHome version 2025.3.3 compiled on Apr  1 2025, 12:14:32
[12:15:01][C][wifi:600]: WiFi:
[12:15:01][C][wifi:428]:   Local MAC: D8:BC:38:E4:6C:C8
[12:15:01][C][wifi:433]:   SSID: '217x205'[redacted]
[12:15:01][C][wifi:436]:   IP Address: 192.168.1.181
[12:15:01][C][wifi:440]:   BSSID: 44:4E:6D:14:E2:24[redacted]
[12:15:01][C][wifi:441]:   Hostname: 'garagentorsteuerung'
[12:15:01][C][wifi:443]:   Signal strength: -31 dB ▂▄▆█
[12:15:01][C][wifi:447]:   Channel: 6
[12:15:01][C][wifi:448]:   Subnet: 255.255.255.0
[12:15:01][C][wifi:449]:   Gateway: 192.168.1.1
[12:15:01][C][wifi:450]:   DNS1: 192.168.1.1
[12:15:01][C][wifi:451]:   DNS2: 0.0.0.0
[12:15:01][C][logger:177]: Logger:
[12:15:01][C][logger:178]:   Max Level: DEBUG
[12:15:01][C][logger:179]:   Initial Level: DEBUG
[12:15:01][C][logger:181]:   Log Baud Rate: 115200
[12:15:01][C][logger:182]:   Hardware UART: UART0
[12:15:01][C][i2c.arduino:071]: I2C Bus:
[12:15:01][C][i2c.arduino:072]:   SDA Pin: GPIO21
[12:15:01][C][i2c.arduino:073]:   SCL Pin: GPIO22
[12:15:01][C][i2c.arduino:074]:   Frequency: 400000 Hz
[12:15:01][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[12:15:01][I][i2c.arduino:096]: Results from i2c bus scan:
[12:15:01][I][i2c.arduino:102]: Found i2c device at address 0x23
[12:15:01][I][i2c.arduino:102]: Found i2c device at address 0x24
[12:15:01][C][uart.arduino_esp32:151]: UART Bus 1:
[12:15:01][C][uart.arduino_esp32:152]:   TX Pin: GPIO17
[12:15:01][C][uart.arduino_esp32:153]:   RX Pin: GPIO16
[12:15:01][C][uart.arduino_esp32:155]:   RX Buffer Size: 256
[12:15:01][C][uart.arduino_esp32:157]:   Baud Rate: 57600 baud
[12:15:01][C][uart.arduino_esp32:158]:   Data Bits: 8
[12:15:01][C][uart.arduino_esp32:159]:   Parity: NONE
[12:15:01][C][uart.arduino_esp32:160]:   Stop bits: 1
[12:15:01][C][template.text_sensor:020]: Template Sensor 'Garage Fingerprint State'
[12:15:01][C][template.text_sensor:020]: Template Sensor 'RFID Tag'
[12:15:01][C][gpio.output:010]: GPIO Binary Output:
[12:15:01][C][gpio.output:011]:   Pin: GPIO27
[12:15:01][C][gpio.output:010]: GPIO Binary Output:
[12:15:01][C][gpio.output:011]:   Pin: GPIO26
[12:15:01][C][output.slow_pwm:054]: Slow PWM Output:
[12:15:01][C][output.slow_pwm:055]:   Pin: GPIO25
[12:15:02][C][output.slow_pwm:065]:   Period: 2000 ms
[12:15:02][C][output.slow_pwm:066]:   Restart cycle on state change: NO
[12:15:02][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'GS Input DPIO35'
[12:15:02][C][gpio.binary_sensor:015]:   Device Class: 'door'
[12:15:02][C][gpio.binary_sensor:016]:   Pin: GPIO35
[12:15:02][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'GS Input DPIO34'
[12:15:02][C][gpio.binary_sensor:015]:   Device Class: 'door'
[12:15:02][C][gpio.binary_sensor:016]:   Pin: GPIO34
[12:15:02][C][output.switch:068]: Output Switch 'GS Ouput GPIO27'
[12:15:02][C][output.switch:091]:   Restore Mode: always OFF
[12:15:02][C][output.switch:068]: Output Switch 'GS Output GPIO26'
[12:15:02][C][output.switch:091]:   Restore Mode: always OFF
[12:15:02][C][pn532:431]: PN532:
[12:15:02][C][pn532:443]:   Update Interval: 1.0s
[12:15:02][C][pn532_i2c:125]:   Address: 0x24
[12:15:02][C][fingerprint_grow:537]: GROW_FINGERPRINT_READER:
[12:15:02][C][fingerprint_grow:538]:   System Identifier Code: 0x0200
[12:15:02][C][fingerprint_grow:540]:   Touch Sensing Pin: GPIO5
[12:15:02][C][fingerprint_grow:542]:   Sensor Power Pin: GPIO18
[12:15:02][C][fingerprint_grow:544]:   Idle Period to Sleep: 5000 ms
[12:15:02][C][fingerprint_grow:548]:   Update Interval: 0.5s
[12:15:02][C][fingerprint_grow:550]:   Fingerprint Count 'Garage Fingerprint Count'
[12:15:02][C][fingerprint_grow:550]:     State Class: ''
[12:15:02][C][fingerprint_grow:550]:     Unit of Measurement: ''
[12:15:02][C][fingerprint_grow:550]:     Accuracy Decimals: 0
[12:15:02][C][fingerprint_grow:550]:     Icon: 'mdi:fingerprint'
[12:15:02][C][fingerprint_grow:551]:     Current Value: 1
[12:15:02][C][fingerprint_grow:554]:   Status 'Garage Fingerprint Status'
[12:15:02][C][fingerprint_grow:554]:     State Class: ''
[12:15:02][C][fingerprint_grow:554]:     Unit of Measurement: ''
[12:15:02][C][fingerprint_grow:554]:     Accuracy Decimals: 0
[12:15:02][C][fingerprint_grow:555]:     Current Value: 2
[12:15:02][C][fingerprint_grow:558]:   Capacity 'Garage Fingerprint Capacity'
[12:15:02][C][fingerprint_grow:558]:     State Class: ''
[12:15:02][C][fingerprint_grow:558]:     Unit of Measurement: ''
[12:15:02][C][fingerprint_grow:558]:     Accuracy Decimals: 0
[12:15:02][C][fingerprint_grow:558]:     Icon: 'mdi:database'
[12:15:02][C][fingerprint_grow:559]:     Current Value: 1000
[12:15:02][C][fingerprint_grow:562]:   Security Level 'Garage Fingerprint Security Level'
[12:15:02][C][fingerprint_grow:562]:     State Class: ''
[12:15:02][C][fingerprint_grow:562]:     Unit of Measurement: ''
[12:15:02][C][fingerprint_grow:562]:     Accuracy Decimals: 0
[12:15:02][C][fingerprint_grow:562]:     Icon: 'mdi:security'
[12:15:02][C][fingerprint_grow:563]:     Current Value: 3
[12:15:02][C][fingerprint_grow:566]:   Last Finger ID 'Garage Fingerprint Last Finger ID'
[12:15:02][C][fingerprint_grow:566]:     State Class: ''
[12:15:02][C][fingerprint_grow:566]:     Unit of Measurement: ''
[12:15:02][C][fingerprint_grow:566]:     Accuracy Decimals: 0
[12:15:02][C][fingerprint_grow:566]:     Icon: 'mdi:account'
[12:15:02][C][fingerprint_grow:567]:     Current Value: 4294967295
[12:15:02][C][fingerprint_grow:570]:   Last Confidence 'Garage Fingerprint Last Confidence'
[12:15:02][C][fingerprint_grow:570]:     State Class: ''
[12:15:02][C][fingerprint_grow:570]:     Unit of Measurement: ''
[12:15:02][C][fingerprint_grow:570]:     Accuracy Decimals: 0
[12:15:02][C][fingerprint_grow:570]:     Icon: 'mdi:account-check'
[12:15:02][C][fingerprint_grow:571]:     Current Value: 4294967295
[12:15:02][C][rotary_encoder:164]: Rotary Encoder 'GS Rotary Encoder'
[12:15:02][C][rotary_encoder:164]:   State Class: ''
[12:15:02][C][rotary_encoder:164]:   Unit of Measurement: 'steps'
[12:15:02][C][rotary_encoder:164]:   Accuracy Decimals: 0
[12:15:02][C][rotary_encoder:164]:   Icon: 'mdi:rotate-right'
[12:15:02][C][rotary_encoder:165]:   Pin A: GPIO13
[12:15:02][C][rotary_encoder:166]:   Pin B: GPIO14
[12:15:02][C][rotary_encoder:180]:   Restore Mode: Restore (Defaults to zero)
[12:15:02][C][rotary_encoder:184]:   Resolution: 1 Pulse Per Cycle
[12:15:02][C][bh1750.sensor:118]: BH1750 'BH1750 Illuminance'
[12:15:02][C][bh1750.sensor:118]:   Device Class: 'illuminance'
[12:15:02][C][bh1750.sensor:118]:   State Class: 'measurement'
[12:15:02][C][bh1750.sensor:118]:   Unit of Measurement: 'lx'
[12:15:02][C][bh1750.sensor:118]:   Accuracy Decimals: 1
[12:15:02][C][bh1750.sensor:119]:   Address: 0x23
[12:15:02][C][bh1750.sensor:124]:   Update Interval: 60.0s
[12:15:02][C][captive_portal:089]: Captive Portal:
[12:15:02][C][mdns:116]: mDNS:
[12:15:02][C][mdns:117]:   Hostname: garagentorsteuerung
[12:15:02][C][esphome.ota:073]: Over-The-Air updates:
[12:15:02][C][esphome.ota:074]:   Address: garagentorsteuerung.local:3232
[12:15:02][C][esphome.ota:075]:   Version: 2
[12:15:02][C][esphome.ota:078]:   Password configured
[12:15:02][C][safe_mode:018]: Safe Mode:
[12:15:02][C][safe_mode:020]:   Boot considered successful after 60 seconds
[12:15:02][C][safe_mode:021]:   Invoke after 10 boot attempts
[12:15:02][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[12:15:02][C][api:140]: API Server:
[12:15:02][C][api:141]:   Address: garagentorsteuerung.local:6053
[12:15:02][C][api:143]:   Using noise encryption: YES
[12:15:34][D][bh1750.sensor:159]: 'BH1750 Illuminance': Got illuminance=152.7lx
[12:15:34][D][sensor:094]: 'BH1750 Illuminance': Sending state 152.69193 lx with 1 decimals of accuracy
[12:15:54][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[12:15:54][D][esp32.preferences:114]: Saving 1 preferences to flash...
[12:15:54][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[12:15:56][D][pn532:364]: Mifare classic
[12:15:56][E][pn532.mifare_classic:101]: Authentication failed - Block 0x04
[12:15:56][D][text_sensor:064]: 'RFID Tag': Sending state 'FE-4C-FD-EC'
[12:15:56][D][pn532:200]: Found new tag 'FE-4C-FD-EC'
[12:15:56][D][pn532:379]: Waiting to read next tag
[12:15:56][W][component:237]: Component pn532 took a long time for an operation (109 ms).
[12:15:56][W][component:238]: Components should block for at most 30 ms.
[12:16:21][D][pn532:364]: Mifare classic
[12:16:21][E][pn532.mifare_classic:101]: Authentication failed - Block 0x04
[12:16:21][D][text_sensor:064]: 'RFID Tag': Sending state 'FE-4C-FD-EC'
[12:16:21][D][pn532:200]: Found new tag 'FE-4C-FD-EC'
[12:16:21][D][pn532:379]: Waiting to read next tag
[12:16:21][W][component:237]: Component pn532 took a long time for an operation (110 ms).
[12:16:21][W][component:238]: Components should block for at most 30 ms.
[12:16:25][D][pn532:364]: Mifare classic
[12:16:25][E][pn532.mifare_classic:101]: Authentication failed - Block 0x04
[12:16:25][D][text_sensor:064]: 'RFID Tag': Sending state 'FE-4C-FD-EC'
[12:16:25][D][pn532:200]: Found new tag 'FE-4C-FD-EC'
[12:16:25][D][pn532:379]: Waiting to read next tag
[12:16:25][W][component:237]: Component pn532 took a long time for an operation (115 ms).
[12:16:25][W][component:238]: Components should block for at most 30 ms.
[12:16:34][D][bh1750.sensor:159]: 'BH1750 Illuminance': Got illuminance=121.8lx
[12:16:34][D][sensor:094]: 'BH1750 Illuminance': Sending state 121.79133 lx with 1 decimals of accuracy
[12:16:42][D][pn532:364]: Mifare classic
[12:16:42][E][pn532.mifare_classic:101]: Authentication failed - Block 0x04
[12:16:42][D][text_sensor:064]: 'RFID Tag': Sending state 'FE-4C-FD-EC'
[12:16:42][D][pn532:200]: Found new tag 'FE-4C-FD-EC'
[12:16:42][D][pn532:379]: Waiting to read next tag
[12:16:42][W][component:237]: Component pn532 took a long time for an operation (110 ms).
[12:16:42][W][component:238]: Components should block for at most 30 ms.

It working as expected.
You can try to add to text_sensor:

  • force_update (Optional, boolean): If true, this option will force the frontend (usually Home Assistant) to create a state changed event when the sensor updates even if the value stayed the same. Some applications like Grafana require this when working with Home Assistant, but beware it can significantly increase the database size. Defaults to false.

After adding homeassistant.tag_scanned scanned tags will appear in HA in Settings->Tags, where You can name them, make automations.

Here is an example of my automation to open gates :

    - id: gate_walker_by_rfid
      alias: Gate - Walker by RFID
      description: ""
      trigger:
        platform: event
        event_type: tag_scanned
      condition:
        - "{{ trigger.event.data.name is search('Gate') }}"
        - condition: state
          entity_id: sensor.sns_gate_state
          state: 'Closed'
      action:
        - service: button.press
          metadata: {}
          data: {}
          target:
            entity_id: button.sns_gate_walker_timed
      mode: single

Have several tags. As soon tag scanned and HA tag name contains Gate - HA pressing the button to open the gate.

Can create automation for specific tag by using as a trigger:

triggers:
  - trigger: tag
    tag_id: "1034156139"

But then You need to change automation if change a tag.

@Masterzz
Many thanks. I really appreciate your help! The homeassistant.tag_scanned hint is really valuable for my next steps.

1.) I’ve tried to add the force_update to the text_sensor, but it showed an error


text_sensor:
  force_update: true
  - platform: template
    id: fingerprint_state
    name: "Garage Fingerprint State"
  - platform: template
    name: "RFID Tag"
    id: rfid_tag

But I received an syntax error - don’t really know where to place it correcty.
→ Can you tell me what is wrong?

I then have added the on_tag_removed

pn532_i2c:
  update_interval: 1s
  on_tag:
    then:
    - text_sensor.template.publish:
        id: rfid_tag
        state: !lambda 'return x;'
    - homeassistant.tag_scanned: !lambda |-
        return x;
  on_tag_removed:
    then:
    - text_sensor.template.publish:
        id: rfid_tag
        state: 'removed' # !lambda 'return x;'

This updates the text sensor with removed and the next tag approached is visualized.

2.) Separate question
If I scan my mobile phone (pixel 9) I receive changing NFC IDs - is this normal?

Many thanks,
Rainer