ESP8266 can't read TAG

Dear,
I just build a RFID card reader following this topic : GitHub - adonno/tagreader: Simple to build/use NFC tag reader, specially created for Home Assistant

After installing and chage some line in the code received because… the PIN6 and 7 was not able…
So I placed the buzzer on PIN3 and remove all code regarding the LED as the PIN 4 was already used in the code it seems…

I reached to read two RFID TAG and even made an automation to turn light on with one of them.
But after 10 minutes… not possible de read any TAG RFID.

I restart the ESP8266 but nothing…
You’ll find the LOG for a restart of the ESP8266 as follow :

[21:53:34][D][api.connection:199]: Home Assistant 2025.3.3 (192.168.68.64) requested disconnected
[21:53:34][W][component:157]: Component api set Warning flag: unspecified
[21:53:34][D][binary_sensor:036]: '${friendly_name} Status': Sending state OFF
[21:53:34][D][api:103]: Accepted 192.168.68.64
[21:53:34][W][component:170]: Component api cleared Warning flag
[21:53:34][W][component:237]: Component api took a long time for an operation (293 ms).
[21:53:34][W][component:238]: Components should block for at most 30 ms.
[21:53:34][D][binary_sensor:036]: '${friendly_name} Status': Sending state ON
[21:53:34][D][api.connection:1446]: Home Assistant 2025.3.3 (192.168.68.64): Connected successfully
[21:53:34][D][switch:016]: '${friendly_name} Buzzer Enabled' Turning OFF.
[21:53:34][D][switch:055]: '${friendly_name} Buzzer Enabled': Sending state OFF
[21:53:34][D][switch:016]: '${friendly_name} LED enabled' Turning OFF.
[21:53:34][D][switch:055]: '${friendly_name} LED enabled': Sending state OFF
[21:54:01][D][switch:012]: '${friendly_name} Buzzer Enabled' Turning ON.
[21:54:01][D][switch:055]: '${friendly_name} Buzzer Enabled': Sending state ON
[21:56:39][D][button:010]: 'Cancel writing' Pressed.
[21:56:39][D][pn532:379]: Waiting to read next tag
[21:56:39][D][rtttl:061]: Playing song write
[21:56:39][D][rtttl:390]: State changed from STATE_STOPPED to STATE_RUNNING
[21:56:40][D][rtttl:390]: State changed from STATE_RUNNING to STATE_STOPPED
[21:56:40][D][rtttl:367]: Playback finished
[21:56:48][D][button:010]: '${friendly_name} Restart' Pressed.
[21:56:48][I][restart.button:012]: Restarting device...
[21:56:48][I][app:132]: Rebooting safely...
[21:56:48][I][pn532:087]: Powering down PN532
[21:56:48][W][wifi_esp8266:513]: Event: Disconnected ssid='WiFi-2.4-F9E8' bssid=E4:FA:C4:B8:2A:12[redacted] reason='Association Leave'
[21:56:48]
[21:56:48] ets Jan  8 2013,rst cause:2, boot mode:(3,6)
[21:56:48]
[21:56:48]load 0x4010f000, len 3424, room 16 
[21:56:48]tail 0
[21:56:48]chksum 0x2e
[21:56:48]load 0x3fff20b8, len 40, room 8 
[21:56:48]tail 0
[21:56:48]chksum 0x2b
[21:56:48]csum 0x2b
[21:56:48]v0008b890
[21:56:48]~ld
[21:56:48]    o {  '|  d {dc  |{ l o  o  d`  s l d  [I][logger:034]: Log initialized
[21:56:48][C][safe_mode:079]: There have been 0 suspected unsuccessful boot attempts
[21:56:48][I][app:029]: Running through setup()...
[21:56:48][I][i2c.arduino:218]: Performing I2C bus recovery
[21:56:48][C][esp8266_pwm:017]: Setting up ESP8266 PWM Output...
[21:56:48][D][template.switch:046]:   Restored state ON
[21:56:48][D][switch:012]: '${friendly_name} Buzzer Enabled' Turning ON.
[21:56:48][D][switch:055]: '${friendly_name} Buzzer Enabled': Sending state ON
[21:56:48][D][template.switch:046]:   Restored state OFF
[21:56:48][D][switch:016]: '${friendly_name} LED enabled' Turning OFF.
[21:56:48][D][switch:055]: '${friendly_name} LED enabled': Sending state OFF
[21:56:48][C][pn532:018]: Setting up PN532...
[21:56:48][D][pn532:036]: Found chip PN532
[21:56:48][D][pn532:037]: Firmware ver. 1.6
[21:56:48][D][binary_sensor:034]: '${friendly_name} Status': Sending initial state OFF
[21:56:48][D][text_sensor:064]: '${friendly_name} ESPHome Version': Sending state '2025.2.2'
[21:56:48][C][wifi:048]: Setting up WiFi...
[21:56:48][C][wifi:061]: Starting WiFi...
[21:56:48][C][wifi:062]:   Local MAC: 40:F5:20:3F:8E:3C
[21:56:48][D][wifi:482]: Starting scan...
[21:56:48][W][component:157]: Component wifi set Warning flag: scanning for networks
[21:56:54][D][wifi:497]: Found networks:
[21:56:54][I][wifi:540]: - 'WiFi-2.4-F9E8' (E4:FA:C4:B8:57:C2) [redacted]▂▄▆█
[21:56:54][D][wifi:542]:     Channel: 3
[21:56:54][D][wifi:543]:     RSSI: -51 dB
[21:56:54][I][wifi:540]: - 'WiFi-2.4-F9E8' (E4:FA:C4:B8:2A:12) [redacted]▂▄▆█
[21:56:54][D][wifi:542]:     Channel: 3
[21:56:54][D][wifi:543]:     RSSI: -53 dB
[21:56:54][I][wifi:540]: - 'WiFi-2.4-F9E8' (E4:FA:C4:B8:57:BE) [redacted]▂▄▆█
[21:56:54][D][wifi:542]:     Channel: 3
[21:56:54][D][wifi:543]:     RSSI: -56 dB
[21:56:54][I][wifi:540]: - 'WiFi-2.4-F9E8' (DC:62:79:78:9C:36) [redacted]▂▄▆█
[21:56:54][D][wifi:542]:     Channel: 3
[21:56:54][D][wifi:543]:     RSSI: -76 dB
[21:56:54][D][wifi:545]: - ''[redacted] (EA:FA:C4:B8:57:C2) [redacted]▂▄▆█
[21:56:54][D][wifi:545]: - ''[redacted] (EA:FA:C4:B8:2A:12) [redacted]▂▄▆█
[21:56:54][D][wifi:545]: - ''[redacted] (EA:FA:C4:B8:57:BE) [redacted]▂▄▆█
[21:56:54][D][wifi:545]: - ''[redacted] (62:15:A2:44:EE:A9) [redacted]▂▄▆█
[21:56:54][D][wifi:545]: - ''[redacted] (E2:62:79:78:9C:36) [redacted]▂▄▆█
[21:56:54][D][wifi:545]: - 'SUN2000-HV2250364839'[redacted] (14:AB:02:CD:08:F1) [redacted]▂▄▆█
[21:56:54][I][wifi:313]: WiFi Connecting to 'WiFi-2.4-F9E8'...
[21:56:58][I][wifi:617]: WiFi Connected!
[21:56:58][C][wifi:428]:   Local MAC: 40:F5:20:3F:8E:3C
[21:56:58][C][wifi:433]:   SSID: 'WiFi-2.4-F9E8'[redacted]
[21:56:58][C][wifi:436]:   IP Address: 192.168.68.67
[21:56:58][C][wifi:439]:   BSSID: E4:FA:C4:B8:57:C2[redacted]
[21:56:58][C][wifi:441]:   Hostname: 'lecteur-badge-3f8e3c'
[21:56:58][C][wifi:443]:   Signal strength: -54 dB ▂▄▆█
[21:56:58][C][wifi:447]:   Channel: 3
[21:56:58][C][wifi:448]:   Subnet: 255.255.252.0
[21:56:58][C][wifi:449]:   Gateway: 192.168.68.1
[21:56:58][C][wifi:450]:   DNS1: 192.168.1.1
[21:56:58][C][wifi:451]:   DNS2: 192.168.1.1
[21:56:58][D][wifi:626]: Disabling AP...
[21:56:58][C][api:026]: Setting up Home Assistant API server...
[21:56:58][I][app:062]: setup() finished successfully!
[21:56:58][D][text_sensor:064]: '${friendly_name} IP Address': Sending state '192.168.68.67'
[21:56:58][D][text_sensor:064]: '${friendly_name} Connected SSID': Sending state 'WiFi-2.4-F9E8'
[21:56:58][W][component:170]: Component wifi cleared Warning flag
[21:56:58][W][component:157]: Component api set Warning flag: unspecified
[21:56:58][I][app:100]: ESPHome version 2025.2.2 compiled on Mar 19 2025, 21:02:01
[21:56:58][I][app:102]: Project adonno.tag_reader version dev
[21:56:58][C][wifi:600]: WiFi:
[21:56:58][C][wifi:428]:   Local MAC: 40:F5:20:3F:8E:3C
[21:56:58][C][wifi:433]:   SSID: 'WiFi-2.4-F9E8'[redacted]
[21:56:58][C][wifi:436]:   IP Address: 192.168.68.67
[21:56:58][C][wifi:439]:   BSSID: E4:FA:C4:B8:57:C2[redacted]
[21:56:58][C][wifi:441]:   Hostname: 'lecteur-badge-3f8e3c'
[21:56:58][C][wifi:443]:   Signal strength: -55 dB ▂▄▆█
[21:56:58][C][wifi:447]:   Channel: 3
[21:56:58][C][wifi:448]:   Subnet: 255.255.252.0
[21:56:58][C][wifi:449]:   Gateway: 192.168.68.1
[21:56:58][C][wifi:450]:   DNS1: 192.168.1.1
[21:56:58][C][wifi:451]:   DNS2: 192.168.1.1
[21:56:58][C][logger:177]: Logger:
[21:56:58][C][logger:178]:   Max Level: DEBUG
[21:56:58][C][logger:179]:   Initial Level: DEBUG
[21:56:58][C][logger:181]:   Log Baud Rate: 115200
[21:56:58][C][logger:182]:   Hardware UART: UART0
[21:56:58][C][i2c.arduino:071]: I2C Bus:
[21:56:58][C][i2c.arduino:072]:   SDA Pin: GPIO4
[21:56:58][C][i2c.arduino:073]:   SCL Pin: GPIO5
[21:56:58][C][i2c.arduino:074]:   Frequency: 400000 Hz
[21:56:58][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[21:56:58][C][esp8266_pwm:022]: ESP8266 PWM:
[21:56:58][C][esp8266_pwm:023]:   Pin: GPIO3
[21:56:58][C][esp8266_pwm:024]:   Frequency: 1000.0 Hz
[21:56:58][C][template.switch:068]: Template Switch '${friendly_name} Buzzer Enabled'
[21:56:58][C][template.switch:070]:   Icon: 'mdi:volume-high'
[21:56:58][C][template.switch:090]:   Restore Mode: restore defaults to ON
[21:56:58][C][template.switch:057]:   Optimistic: YES
[21:56:58][C][template.switch:068]: Template Switch '${friendly_name} LED enabled'
[21:56:58][C][template.switch:070]:   Icon: 'mdi:alarm-light-outline'
[21:56:58][C][template.switch:090]:   Restore Mode: restore defaults to ON
[21:56:58][C][template.switch:057]:   Optimistic: YES
[21:56:58][C][restart.button:017]: Restart Button '${friendly_name} Restart'
[21:56:58][C][restart.button:017]:   Icon: 'mdi:restart'
[21:56:58][C][pn532:431]: PN532:
[21:56:58][C][pn532:443]:   Update Interval: 1.0s
[21:56:58][C][pn532_i2c:125]:   Address: 0x24
[21:56:58][C][status:034]: Status Binary Sensor '${friendly_name} Status'
[21:56:58][C][status:034]:   Device Class: 'connectivity'
[21:56:58][C][version.text_sensor:021]: Version Text Sensor '${friendly_name} ESPHome Version'
[21:56:58][C][version.text_sensor:021]:   Icon: 'mdi:new-box'
[21:56:58][C][rtttl:030]: Rtttl:
[21:56:58][C][rtttl:031]:   Gain: 0.600000
[21:56:58][C][captive_portal:089]: Captive Portal:
[21:56:58][D][api:103]: Accepted 192.168.68.64
[21:56:58][W][component:170]: Component api cleared Warning flag
[21:56:58][C][mdns:116]: mDNS:
[21:56:58][C][mdns:117]:   Hostname: lecteur-badge-3f8e3c
[21:56:58][D][main:391]: API is connected!
[21:56:58][D][rtttl:061]: Playing song success
[21:56:58][D][rtttl:390]: State changed from STATE_STOPPED to STATE_RUNNING
[21:56:58][D][switch:012]: '${friendly_name} Buzzer Enabled' Turning ON.
[21:56:58][D][binary_sensor:036]: '${friendly_name} Status': Sending state ON
[21:56:58][W][component:237]: Component api took a long time for an operation (289 ms).
[21:56:58][W][component:238]: Components should block for at most 30 ms.
[21:56:58][C][esphome.ota:073]: Over-The-Air updates:
[21:56:58][C][esphome.ota:074]:   Address: lecteur-badge.local:8266
[21:56:58][C][esphome.ota:075]:   Version: 2
[21:56:58][C][esphome.ota:078]:   Password configured
[21:56:58][C][safe_mode:018]: Safe Mode:
[21:56:58][C][safe_mode:019]:   Boot considered successful after 60 seconds
[21:56:58][C][safe_mode:021]:   Invoke after 10 boot attempts
[21:56:58][C][safe_mode:022]:   Remain in safe mode for 300 seconds
[21:56:58][C][api:140]: API Server:
[21:56:58][C][api:141]:   Address: lecteur-badge.local:6053
[21:56:58][C][api:143]:   Using noise encryption: YES
[21:56:58][C][improv_serial:032]: Improv Serial:
[21:56:58][C][wifi_info:012]: WifiInfo SSID '${friendly_name} Connected SSID'
[21:56:58][C][wifi_info:012]:   Icon: 'mdi:wifi-strength-2'
[21:56:58][C][wifi_info:010]: WifiInfo IPAddress '${friendly_name} IP Address'
[21:56:58][C][wifi_info:010]:   Icon: 'mdi:wifi'
[21:56:59][D][rtttl:390]: State changed from STATE_RUNNING to STATE_STOPPED
[21:56:59][D][rtttl:367]: Playback finished
[21:57:01][D][api.connection:1446]: Home Assistant 2025.3.3 (192.168.68.64): Connected successfully
[21:57:48][I][safe_mode:041]: Boot seems successful; resetting boot loop counter

THis LOG file is when I’m connected with my computer through the USB port.

If I try to connect in wireless with HA… It seems not findable…
disconnect in HA

THis is the LOG from HA :

INFO ESPHome 2025.2.2
INFO Reading configuration /config/esphome/lecteur-badge.yaml...
INFO Starting log output from lecteur-badge.local using esphome API
WARNING Can't connect to ESPHome API for lecteur-badge.local: Timeout while resolving IP address for ['lecteur-badge.local'] (ResolveTimeoutAPIError)
INFO Trying to connect to lecteur-badge.local in the background

I don’t know what happened… as I really new in HA and programming… can you help me?

for information, this is the code yaml on my ESP8266

#esphome:
#  name: lecteur-badge
#  friendly_name: Lecteur_badge

esp8266:
  board: esp01_1m



# Enable Home Assistant API
#api:
#  encryption:
#    key: 

#ota:
#  - platform: esphome
#    password:

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Lecteur-Badge Fallback Hotspot"
    password: "

captive_portal:
dashboard_import:
  package_import_url: github://adonno/tagreader/tagreader.yaml

improv_serial:



esphome:
  name: lecteur-badge
  friendly_name: Lecteur_badge

  # Automatically add the mac address to the name
  # so you can use a single firmware for all devices
  name_add_mac_suffix: true

  # This will allow for (future) project identification,
  # configuration and updates.
  project:
    name: adonno.tag_reader
    version: dev
# If buzzer is enabled, notify on api connection success
  on_boot:
    priority: -10
    then:
    - wait_until:
        api.connected:
    - logger.log: API is connected!
    - rtttl.play: "success:d=24,o=5,b=100:c,g,b"
#    - light.turn_on:
#        id: activity_led
#        brightness: 100%
#        red: 0%
#        green: 0%
#        blue: 100%
#        flash_length: 500ms
    - switch.turn_on: buzzer_enabled
#    - switch.turn_on: led_enabled

# Define switches to control LED and buzzer from HA
switch:
- platform: template
  name: "${friendly_name} Buzzer Enabled"
  id: buzzer_enabled
  icon: mdi:volume-high
  optimistic: true
  restore_mode: RESTORE_DEFAULT_ON
  entity_category: config
- platform: template
  name: "${friendly_name} LED enabled"
  id: led_enabled
  icon: mdi:alarm-light-outline
  optimistic: true
  restore_mode: RESTORE_DEFAULT_ON
  entity_category: config

# Define buttons for writing tags via HA
button:
  - platform: template
    name: Write Tag Random
    id: write_tag_random
    # Optional variables:
    icon: "mdi:pencil-box"
    on_press:
      then:
#      - light.turn_on:
#          id: activity_led
#          brightness: 100%
#          red: 100%
#          green: 0%
#          blue: 100%
      - lambda: |-
          static const char alphanum[] = "0123456789abcdef";
          std::string uri = "https://www.home-assistant.io/tag/";
          for (int i = 0; i < 8; i++)
            uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
          uri += "-";
          for (int j = 0; j < 3; j++) {
            for (int i = 0; i < 4; i++)
              uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
            uri += "-";
          }
          for (int i = 0; i < 12; i++)
            uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
          auto message = new nfc::NdefMessage();
          message->add_uri_record(uri);
          ESP_LOGD("tagreader", "Writing payload: %s", uri.c_str());
          id(pn532_board).write_mode(message);
      - rtttl.play: "write:d=24,o=5,b=100:b"
      - wait_until:
          not:
            pn532.is_writing:
 #     - light.turn_off:
 #         id: activity_led
  #    - rtttl.play: "write:d=24,o=5,b=100:b,b"
  - platform: template
    name: Clean Tag
    id: clean_tag
    icon: "mdi:nfc-variant-off"
    on_press:
      then:
#      - light.turn_on:
#          id: activity_led
#          brightness: 100%
#          red: 100%
#          green: 64.7%
#          blue: 0%
      - lambda: 'id(pn532_board).clean_mode();'
      - rtttl.play: "write:d=24,o=5,b=100:b"
      - wait_until:
          not:
            pn532.is_writing:
#      - light.turn_off:
#          id: activity_led
#      - rtttl.play: "write:d=24,o=5,b=100:b,b"
  - platform: template
    name: Cancel writing
    id: cancel_writing
    icon: "mdi:pencil-off"
    on_press:
      then:
      - lambda: 'id(pn532_board).read_mode();'
 #     - light.turn_off:
 #         id: activity_led
      - rtttl.play: "write:d=24,o=5,b=100:b,b"

  - platform: restart
    name: "${friendly_name} Restart"
    entity_category: config
# Enable logging
logger:
  # level: VERY_VERBOSE
  # level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "
  services:
  - service: rfidreader_tag_ok
    then:
    - rtttl.play: "beep:d=16,o=5,b=100:b"

  - service: rfidreader_tag_ko
    then:
    - rtttl.play: "beep:d=8,o=5,b=100:b"

  - service: play_rtttl
    variables:
      song_str: string
    then:
    - rtttl.play: !lambda 'return song_str;'

  - service: write_tag_id
    variables:
      tag_id: string
    then:
#    - light.turn_on:
#        id: activity_led
#        brightness: 100%
#        red: 100%
#        green: 0%
#        blue: 0%
    - lambda: |-
        auto message = new nfc::NdefMessage();
        std::string uri = "https://www.home-assistant.io/tag/";
        uri += tag_id;
        message->add_uri_record(uri);
        id(pn532_board).write_mode(message);
    - rtttl.play: "write:d=24,o=5,b=100:b"
    - wait_until:
        not:
          pn532.is_writing:
#    - light.turn_off:
#        id: activity_led
    - rtttl.play: "write:d=24,o=5,b=100:b,b"

  - service: write_music_tag
    variables:
      music_url: string
      music_info: string
    then:
#    - light.turn_on:
#        id: activity_led
#        brightness: 100%
#        red: 100%
#        green: 0%
#        blue: 0%
    - lambda: |-
        auto message = new nfc::NdefMessage();
        std::string uri = "";
        std::string text = "";
        uri += music_url;
        text += music_info;
        if ( music_url != "" ) {
          message->add_uri_record(uri);
        }
        if ( music_info != "" ) {
          message->add_text_record(text);
        }
        id(pn532_board).write_mode(message);
    - rtttl.play: "write:d=24,o=5,b=100:b"
    - wait_until:
        not:
          pn532.is_writing:
 #   - light.turn_off:
 #       id: activity_led
  #  - rtttl.play: "write:d=24,o=5,b=100:b,b"

# Enable OTA upgrade
ota:
  - platform: esphome
    password: "

i2c:
  scan: False
  frequency: 400kHz

globals:
  - id: source
    type: std::string
  - id: url
    type: std::string
  - id: info
    type: std::string

pn532_i2c:
  id: pn532_board
  on_tag:
    then:
    - if:
        condition:
          switch.is_on: led_enabled
        then:
 #       - light.turn_on:
 #           id: activity_led
 #           brightness: 100%
 #           red: 0%
 #           green: 100%
 #           blue: 0%
 #           flash_length: 500ms

    - delay: 0.15s #to fix slow component

    - lambda: |-
        id(source)="";
        id(url)="";
        id(info)="";
        if (tag.has_ndef_message()) {
          auto message = tag.get_ndef_message();
          auto records = message->get_records();
          for (auto &record : records) {
            std::string payload = record->get_payload();
            std::string type = record->get_type();
            size_t hass = payload.find("https://www.home-assistant.io/tag/");
            size_t applemusic = payload.find("https://music.apple.com");
            size_t spotify = payload.find("https://open.spotify.com");
            size_t sonos = payload.find("sonos-2://");

            size_t mass_deezer = payload.find("deezer://");
            size_t mass_filesystem_local = payload.find("filesystem_local://");
            size_t mass_filesystem_smb = payload.find("filesystem_smb://");
            size_t mass_plex = payload.find("plex://");
            size_t mass_qobuz = payload.find("qobuz://");
            size_t mass_radiobrowser = payload.find("radiobrowser://");
            size_t mass_soundcloud = payload.find("soundcloud://");
            size_t mass_spotify = payload.find("spotify://");
            size_t mass_tidal = payload.find("tidal://");
            size_t mass_tunein = payload.find("tunein://");
            size_t mass_ytmusic = payload.find("ytmusic://");

            if (type == "U" and hass != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Home Assistant tag NDEF");
              id(source)="hass";
              id(url)=payload;
              id(info)=payload.substr(hass + 34);
            }
            else if (type == "U" and applemusic != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Apple Music tag NDEF");
              id(source)="amusic";
              id(url)=payload;
            }
            else if (type == "U" and spotify != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Spotify tag NDEF");
              id(source)="spotify";
              id(url)=payload;
            }
            else if (type == "U" and sonos != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Sonos app tag NDEF");
              id(source)="sonos";
              id(url)=payload;
            }
            else if (type == "U" && (mass_deezer != std::string::npos ||
                    mass_filesystem_local != std::string::npos ||
                    mass_filesystem_smb != std::string::npos ||
                    mass_plex != std::string::npos ||
                    mass_qobuz != std::string::npos ||
                    mass_radiobrowser != std::string::npos ||
                    mass_soundcloud != std::string::npos ||
                    mass_spotify != std::string::npos ||
                    mass_tidal != std::string::npos ||
                    mass_tunein != std::string::npos ||
                    mass_ytmusic != std::string::npos)) {
              ESP_LOGD("tagreader", "Found Music Assistant tag NDEF");
              id(source) = "mass";
              id(url) = payload;
            }
            else if (type == "T" ) {
              ESP_LOGD("tagreader", "Found music info tag NDEF");
              id(info)=payload;
            }
            else if ( id(source)=="" ) {
              id(source)="uid";
            }
          }
        }
        else {
          id(source)="uid";
        }

    - if:
        condition:
          lambda: 'return ( id(source)=="uid" );'
        then:
          - homeassistant.tag_scanned: !lambda |-
              ESP_LOGD("tagreader", "No HA NDEF, using UID");
              return x;
        else:
        - if:
            condition:
              lambda: 'return ( id(source)=="hass" );'
            then:
            - homeassistant.tag_scanned: !lambda 'return id(info);'
            else:
            - homeassistant.event:
                event: esphome.music_tag
                data:
                  reader: !lambda |-
                    return App.get_name().c_str();
                  source: !lambda |-
                    return id(source);
                  url: !lambda |-
                    return id(url);
                  info: !lambda |-
                    return id(info);

    - if:
        condition:
          switch.is_on: buzzer_enabled
        then:
        - rtttl.play: "success:d=24,o=5,b=100:c,g,b"
  on_tag_removed:
    then:
    - homeassistant.event:
        event: esphome.tag_removed
# Define the buzzer output
output:
- platform: esp8266_pwm
  pin: 3
  id: buzzer

binary_sensor:
  - platform: status
    name: "${friendly_name} Status"
    entity_category: diagnostic


text_sensor:
  - platform: version
    hide_timestamp: true
    name: "${friendly_name} ESPHome Version"
    entity_category: diagnostic
  - platform: wifi_info
    ip_address:
      name: "${friendly_name} IP Address"
      icon: mdi:wifi
      entity_category: diagnostic
    ssid:
      name: "${friendly_name} Connected SSID"
      icon: mdi:wifi-strength-2
      entity_category: diagnostic

# Define buzzer as output for RTTTL
rtttl:
  output: buzzer

# Configure LED
#light:
#- platform: neopixelbus
#  variant: WS2812
#  pin: 7
#  num_leds: 1
#  flash_transition_length: 500ms
#  type: GRB
#  id: activity_led
#  name: "${friendly_name} LED"
#  restore_mode: ALWAYS_OFF


And Buzzer seems not working, but it’s not my priority

So, I don’t know why… but a new device was created with another Name…
So I deleted the old one and compete the new device.
It was ONLINE, I edit the yaml file with same code as the old…
once uploaded… device OFFLINE and same as before… :frowning:

the code Yaml

#substitutions:
#  name: lecteur-badge-3f8e3c
#  friendly_name: Lecteur_badge
#packages:
 # adonno.tag_reader: github://adonno/tagreader/tagreader.yaml
#esphome:
#  name: ${name}
#  name_add_mac_suffix: false
#  friendly_name: ${friendly_name}
#api:
#  encryption:
#    
esp8266:
  board: esp01_1m

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

captive_portal:
dashboard_import:
  package_import_url: github://adonno/tagreader/tagreader.yaml

improv_serial:



esphome:
  name: lecteur-badge-3f8e3c
  friendly_name: Lecteur_badge


  # Automatically add the mac address to the name
  # so you can use a single firmware for all devices
  name_add_mac_suffix: true

  # This will allow for (future) project identification,
  # configuration and updates.
  project:
    name: adonno.tag_reader
    version: dev
# If buzzer is enabled, notify on api connection success
  on_boot:
    priority: -10
    then:
    - wait_until:
        api.connected:
    - logger.log: API is connected!
    - rtttl.play: "success:d=24,o=5,b=100:c,g,b"
#    - light.turn_on:
#        id: activity_led
#        brightness: 100%
#        red: 0%
#        green: 0%
#        blue: 100%
#        flash_length: 500ms
    - switch.turn_on: buzzer_enabled
#    - switch.turn_on: led_enabled

# Define switches to control LED and buzzer from HA
switch:
- platform: template
  name: "${friendly_name} Buzzer Enabled"
  id: buzzer_enabled
  icon: mdi:volume-high
  optimistic: true
  restore_mode: RESTORE_DEFAULT_ON
  entity_category: config
- platform: template
  name: "${friendly_name} LED enabled"
  id: led_enabled
  icon: mdi:alarm-light-outline
  optimistic: true
  restore_mode: RESTORE_DEFAULT_ON
  entity_category: config

# Define buttons for writing tags via HA
button:
  - platform: template
    name: Write Tag Random
    id: write_tag_random
    # Optional variables:
    icon: "mdi:pencil-box"
    on_press:
      then:
#      - light.turn_on:
#          id: activity_led
#          brightness: 100%
#          red: 100%
#          green: 0%
#          blue: 100%
      - lambda: |-
          static const char alphanum[] = "0123456789abcdef";
          std::string uri = "https://www.home-assistant.io/tag/";
          for (int i = 0; i < 8; i++)
            uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
          uri += "-";
          for (int j = 0; j < 3; j++) {
            for (int i = 0; i < 4; i++)
              uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
            uri += "-";
          }
          for (int i = 0; i < 12; i++)
            uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
          auto message = new nfc::NdefMessage();
          message->add_uri_record(uri);
          ESP_LOGD("tagreader", "Writing payload: %s", uri.c_str());
          id(pn532_board).write_mode(message);
      - rtttl.play: "write:d=24,o=5,b=100:b"
      - wait_until:
          not:
            pn532.is_writing:
 #     - light.turn_off:
 #         id: activity_led
  #    - rtttl.play: "write:d=24,o=5,b=100:b,b"
  - platform: template
    name: Clean Tag
    id: clean_tag
    icon: "mdi:nfc-variant-off"
    on_press:
      then:
#      - light.turn_on:
#          id: activity_led
#          brightness: 100%
#          red: 100%
#          green: 64.7%
#          blue: 0%
      - lambda: 'id(pn532_board).clean_mode();'
      - rtttl.play: "write:d=24,o=5,b=100:b"
      - wait_until:
          not:
            pn532.is_writing:
#      - light.turn_off:
#          id: activity_led
#      - rtttl.play: "write:d=24,o=5,b=100:b,b"
  - platform: template
    name: Cancel writing
    id: cancel_writing
    icon: "mdi:pencil-off"
    on_press:
      then:
      - lambda: 'id(pn532_board).read_mode();'
 #     - light.turn_off:
 #         id: activity_led
      - rtttl.play: "write:d=24,o=5,b=100:b,b"

  - platform: restart
    name: "${friendly_name} Restart"
    entity_category: config
# Enable logging
logger:
  # level: VERY_VERBOSE
  # level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "
  services:
  - service: rfidreader_tag_ok
    then:
    - rtttl.play: "beep:d=16,o=5,b=100:b"

  - service: rfidreader_tag_ko
    then:
    - rtttl.play: "beep:d=8,o=5,b=100:b"

  - service: play_rtttl
    variables:
      song_str: string
    then:
    - rtttl.play: !lambda 'return song_str;'

  - service: write_tag_id
    variables:
      tag_id: string
    then:
#    - light.turn_on:
#        id: activity_led
#        brightness: 100%
#        red: 100%
#        green: 0%
#        blue: 0%
    - lambda: |-
        auto message = new nfc::NdefMessage();
        std::string uri = "https://www.home-assistant.io/tag/";
        uri += tag_id;
        message->add_uri_record(uri);
        id(pn532_board).write_mode(message);
    - rtttl.play: "write:d=24,o=5,b=100:b"
    - wait_until:
        not:
          pn532.is_writing:
#    - light.turn_off:
#        id: activity_led
    - rtttl.play: "write:d=24,o=5,b=100:b,b"

  - service: write_music_tag
    variables:
      music_url: string
      music_info: string
    then:
#    - light.turn_on:
#        id: activity_led
#        brightness: 100%
#        red: 100%
#        green: 0%
#        blue: 0%
    - lambda: |-
        auto message = new nfc::NdefMessage();
        std::string uri = "";
        std::string text = "";
        uri += music_url;
        text += music_info;
        if ( music_url != "" ) {
          message->add_uri_record(uri);
        }
        if ( music_info != "" ) {
          message->add_text_record(text);
        }
        id(pn532_board).write_mode(message);
    - rtttl.play: "write:d=24,o=5,b=100:b"
    - wait_until:
        not:
          pn532.is_writing:
 #   - light.turn_off:
 #       id: activity_led
  #  - rtttl.play: "write:d=24,o=5,b=100:b,b"

# Enable OTA upgrade
ota:
  - platform: esphome
    password: 

i2c:
  scan: False
  frequency: 400kHz

globals:
  - id: source
    type: std::string
  - id: url
    type: std::string
  - id: info
    type: std::string

pn532_i2c:
  id: pn532_board
  on_tag:
    then:
    - if:
        condition:
          switch.is_on: led_enabled
        then:
 #       - light.turn_on:
 #           id: activity_led
 #           brightness: 100%
 #           red: 0%
 #           green: 100%
 #           blue: 0%
 #           flash_length: 500ms

    - delay: 0.15s #to fix slow component

    - lambda: |-
        id(source)="";
        id(url)="";
        id(info)="";
        if (tag.has_ndef_message()) {
          auto message = tag.get_ndef_message();
          auto records = message->get_records();
          for (auto &record : records) {
            std::string payload = record->get_payload();
            std::string type = record->get_type();
            size_t hass = payload.find("https://www.home-assistant.io/tag/");
            size_t applemusic = payload.find("https://music.apple.com");
            size_t spotify = payload.find("https://open.spotify.com");
            size_t sonos = payload.find("sonos-2://");

            size_t mass_deezer = payload.find("deezer://");
            size_t mass_filesystem_local = payload.find("filesystem_local://");
            size_t mass_filesystem_smb = payload.find("filesystem_smb://");
            size_t mass_plex = payload.find("plex://");
            size_t mass_qobuz = payload.find("qobuz://");
            size_t mass_radiobrowser = payload.find("radiobrowser://");
            size_t mass_soundcloud = payload.find("soundcloud://");
            size_t mass_spotify = payload.find("spotify://");
            size_t mass_tidal = payload.find("tidal://");
            size_t mass_tunein = payload.find("tunein://");
            size_t mass_ytmusic = payload.find("ytmusic://");

            if (type == "U" and hass != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Home Assistant tag NDEF");
              id(source)="hass";
              id(url)=payload;
              id(info)=payload.substr(hass + 34);
            }
            else if (type == "U" and applemusic != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Apple Music tag NDEF");
              id(source)="amusic";
              id(url)=payload;
            }
            else if (type == "U" and spotify != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Spotify tag NDEF");
              id(source)="spotify";
              id(url)=payload;
            }
            else if (type == "U" and sonos != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Sonos app tag NDEF");
              id(source)="sonos";
              id(url)=payload;
            }
            else if (type == "U" && (mass_deezer != std::string::npos ||
                    mass_filesystem_local != std::string::npos ||
                    mass_filesystem_smb != std::string::npos ||
                    mass_plex != std::string::npos ||
                    mass_qobuz != std::string::npos ||
                    mass_radiobrowser != std::string::npos ||
                    mass_soundcloud != std::string::npos ||
                    mass_spotify != std::string::npos ||
                    mass_tidal != std::string::npos ||
                    mass_tunein != std::string::npos ||
                    mass_ytmusic != std::string::npos)) {
              ESP_LOGD("tagreader", "Found Music Assistant tag NDEF");
              id(source) = "mass";
              id(url) = payload;
            }
            else if (type == "T" ) {
              ESP_LOGD("tagreader", "Found music info tag NDEF");
              id(info)=payload;
            }
            else if ( id(source)=="" ) {
              id(source)="uid";
            }
          }
        }
        else {
          id(source)="uid";
        }

    - if:
        condition:
          lambda: 'return ( id(source)=="uid" );'
        then:
          - homeassistant.tag_scanned: !lambda |-
              ESP_LOGD("tagreader", "No HA NDEF, using UID");
              return x;
        else:
        - if:
            condition:
              lambda: 'return ( id(source)=="hass" );'
            then:
            - homeassistant.tag_scanned: !lambda 'return id(info);'
            else:
            - homeassistant.event:
                event: esphome.music_tag
                data:
                  reader: !lambda |-
                    return App.get_name().c_str();
                  source: !lambda |-
                    return id(source);
                  url: !lambda |-
                    return id(url);
                  info: !lambda |-
                    return id(info);

    - if:
        condition:
          switch.is_on: buzzer_enabled
        then:
        - rtttl.play: "success:d=24,o=5,b=100:c,g,b"
  on_tag_removed:
    then:
    - homeassistant.event:
        event: esphome.tag_removed
# Define the buzzer output
output:
- platform: esp8266_pwm
  pin: 3
  id: buzzer

binary_sensor:
  - platform: status
    name: "${friendly_name} Status"
    entity_category: diagnostic


text_sensor:
  - platform: version
    hide_timestamp: true
    name: "${friendly_name} ESPHome Version"
    entity_category: diagnostic
  - platform: wifi_info
    ip_address:
      name: "${friendly_name} IP Address"
      icon: mdi:wifi
      entity_category: diagnostic
    ssid:
      name: "${friendly_name} Connected SSID"
      icon: mdi:wifi-strength-2
      entity_category: diagnostic

# Define buzzer as output for RTTTL
rtttl:
  output: buzzer

# Configure LED
#light:
#- platform: neopixelbus
#  variant: WS2812
#  pin: 7
#  num_leds: 1
#  flash_transition_length: 500ms
#  type: GRB
#  id: activity_led
#  name: "${friendly_name} LED"
#  restore_mode: ALWAYS_OFF


So, I understand, it was that line cause the new name of device after installation :
name_add_mac_suffix: true

I change by
name_add_mac_suffix: false

So now… as It was too late I was too stupid… TAG RFID was to far of the reader.
Now evrything work with the tag…
But Buzzer doesn’t work…
If you have an idea to make LED working and buzzer.
I connect the buzzer on PIN 3

For the LED it seems that I ve no gpio available… as D5 6 7 8 seems to be used…
and the D4 too, but nothing is connected on.

Thanks a lot

PS: I know… I was stupid

and the last code yaml :

substitutions:
  name: lecteur-badge-3f8e3c-3f8e3c
  friendly_name: Lecteur_badge
#packages:
 # adonno.tag_reader: github://adonno/tagreader/tagreader.yaml

#api:
#  encryption:
#   key: nM3NjGBqom3KavQMi1GEGVlfyWkn+9kudJnDr5Jhvdo=
esp8266:
  board: esp01_1m

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

captive_portal:
dashboard_import:
  package_import_url: github://adonno/tagreader/tagreader.yaml

improv_serial:



esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}


  # Automatically add the mac address to the name
  # so you can use a single firmware for all devices
#  name_add_mac_suffix: true

  # This will allow for (future) project identification,
  # configuration and updates.
  project:
    name: adonno.tag_reader
    version: dev
# If buzzer is enabled, notify on api connection success
  on_boot:
    priority: -10
    then:
    - wait_until:
        api.connected:
    - logger.log: API is connected!
    - rtttl.play: "success:d=24,o=5,b=100:c,g,b"
#    - light.turn_on:
#        id: activity_led
#        brightness: 100%
#        red: 0%
#        green: 0%
#        blue: 100%
#        flash_length: 500ms
    - switch.turn_on: buzzer_enabled
#    - switch.turn_on: led_enabled

# Define switches to control LED and buzzer from HA
switch:
- platform: template
  name: "${friendly_name} Buzzer Enabled"
  id: buzzer_enabled
  icon: mdi:volume-high
  optimistic: true
  restore_mode: RESTORE_DEFAULT_ON
  entity_category: config
- platform: template
  name: "${friendly_name} LED enabled"
  id: led_enabled
  icon: mdi:alarm-light-outline
  optimistic: true
  restore_mode: RESTORE_DEFAULT_ON
  entity_category: config

# Define buttons for writing tags via HA
button:
  - platform: template
    name: Write Tag Random
    id: write_tag_random
    # Optional variables:
    icon: "mdi:pencil-box"
    on_press:
      then:
#      - light.turn_on:
#          id: activity_led
#          brightness: 100%
#          red: 100%
#          green: 0%
#          blue: 100%
      - lambda: |-
          static const char alphanum[] = "0123456789abcdef";
          std::string uri = "https://www.home-assistant.io/tag/";
          for (int i = 0; i < 8; i++)
            uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
          uri += "-";
          for (int j = 0; j < 3; j++) {
            for (int i = 0; i < 4; i++)
              uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
            uri += "-";
          }
          for (int i = 0; i < 12; i++)
            uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
          auto message = new nfc::NdefMessage();
          message->add_uri_record(uri);
          ESP_LOGD("tagreader", "Writing payload: %s", uri.c_str());
          id(pn532_board).write_mode(message);
      - rtttl.play: "write:d=24,o=5,b=100:b"
      - wait_until:
          not:
            pn532.is_writing:
 #     - light.turn_off:
 #         id: activity_led
  #    - rtttl.play: "write:d=24,o=5,b=100:b,b"
  - platform: template
    name: Clean Tag
    id: clean_tag
    icon: "mdi:nfc-variant-off"
    on_press:
      then:
#      - light.turn_on:
#          id: activity_led
#          brightness: 100%
#          red: 100%
#          green: 64.7%
#          blue: 0%
      - lambda: 'id(pn532_board).clean_mode();'
      - rtttl.play: "write:d=24,o=5,b=100:b"
      - wait_until:
          not:
            pn532.is_writing:
#      - light.turn_off:
#          id: activity_led
#      - rtttl.play: "write:d=24,o=5,b=100:b,b"
  - platform: template
    name: Cancel writing
    id: cancel_writing
    icon: "mdi:pencil-off"
    on_press:
      then:
      - lambda: 'id(pn532_board).read_mode();'
 #     - light.turn_off:
 #         id: activity_led
      - rtttl.play: "write:d=24,o=5,b=100:b,b"

  - platform: restart
    name: "${friendly_name} Restart"
    entity_category: config
# Enable logging
logger:
  # level: VERY_VERBOSE
  # level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "nM3NjGBqom3KavQMi1GEGVlfyWkn+9kudJnDr5Jhvdo="
  services:
  - service: rfidreader_tag_ok
    then:
    - rtttl.play: "beep:d=16,o=5,b=100:b"

  - service: rfidreader_tag_ko
    then:
    - rtttl.play: "beep:d=8,o=5,b=100:b"

  - service: play_rtttl
    variables:
      song_str: string
    then:
    - rtttl.play: !lambda 'return song_str;'

  - service: write_tag_id
    variables:
      tag_id: string
    then:
#    - light.turn_on:
#        id: activity_led
#        brightness: 100%
#        red: 100%
#        green: 0%
#        blue: 0%
    - lambda: |-
        auto message = new nfc::NdefMessage();
        std::string uri = "https://www.home-assistant.io/tag/";
        uri += tag_id;
        message->add_uri_record(uri);
        id(pn532_board).write_mode(message);
    - rtttl.play: "write:d=24,o=5,b=100:b"
    - wait_until:
        not:
          pn532.is_writing:
#    - light.turn_off:
#        id: activity_led
    - rtttl.play: "write:d=24,o=5,b=100:b,b"

  - service: write_music_tag
    variables:
      music_url: string
      music_info: string
    then:
#    - light.turn_on:
#        id: activity_led
#        brightness: 100%
#        red: 100%
#        green: 0%
#        blue: 0%
    - lambda: |-
        auto message = new nfc::NdefMessage();
        std::string uri = "";
        std::string text = "";
        uri += music_url;
        text += music_info;
        if ( music_url != "" ) {
          message->add_uri_record(uri);
        }
        if ( music_info != "" ) {
          message->add_text_record(text);
        }
        id(pn532_board).write_mode(message);
    - rtttl.play: "write:d=24,o=5,b=100:b"
    - wait_until:
        not:
          pn532.is_writing:
 #   - light.turn_off:
 #       id: activity_led
  #  - rtttl.play: "write:d=24,o=5,b=100:b,b"

# Enable OTA upgrade
ota:
  - platform: esphome
    password: "b7e9b2b5906b74ad449e339e40ceb28f"

i2c:
  scan: False
  frequency: 400kHz

globals:
  - id: source
    type: std::string
  - id: url
    type: std::string
  - id: info
    type: std::string

pn532_i2c:
  id: pn532_board
  on_tag:
    then:
    - if:
        condition:
          switch.is_on: led_enabled
        then:
 #       - light.turn_on:
 #           id: activity_led
 #           brightness: 100%
 #           red: 0%
 #           green: 100%
 #           blue: 0%
 #           flash_length: 500ms

    - delay: 0.15s #to fix slow component

    - lambda: |-
        id(source)="";
        id(url)="";
        id(info)="";
        if (tag.has_ndef_message()) {
          auto message = tag.get_ndef_message();
          auto records = message->get_records();
          for (auto &record : records) {
            std::string payload = record->get_payload();
            std::string type = record->get_type();
            size_t hass = payload.find("https://www.home-assistant.io/tag/");
            size_t applemusic = payload.find("https://music.apple.com");
            size_t spotify = payload.find("https://open.spotify.com");
            size_t sonos = payload.find("sonos-2://");

            size_t mass_deezer = payload.find("deezer://");
            size_t mass_filesystem_local = payload.find("filesystem_local://");
            size_t mass_filesystem_smb = payload.find("filesystem_smb://");
            size_t mass_plex = payload.find("plex://");
            size_t mass_qobuz = payload.find("qobuz://");
            size_t mass_radiobrowser = payload.find("radiobrowser://");
            size_t mass_soundcloud = payload.find("soundcloud://");
            size_t mass_spotify = payload.find("spotify://");
            size_t mass_tidal = payload.find("tidal://");
            size_t mass_tunein = payload.find("tunein://");
            size_t mass_ytmusic = payload.find("ytmusic://");

            if (type == "U" and hass != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Home Assistant tag NDEF");
              id(source)="hass";
              id(url)=payload;
              id(info)=payload.substr(hass + 34);
            }
            else if (type == "U" and applemusic != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Apple Music tag NDEF");
              id(source)="amusic";
              id(url)=payload;
            }
            else if (type == "U" and spotify != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Spotify tag NDEF");
              id(source)="spotify";
              id(url)=payload;
            }
            else if (type == "U" and sonos != std::string::npos ) {
              ESP_LOGD("tagreader", "Found Sonos app tag NDEF");
              id(source)="sonos";
              id(url)=payload;
            }
            else if (type == "U" && (mass_deezer != std::string::npos ||
                    mass_filesystem_local != std::string::npos ||
                    mass_filesystem_smb != std::string::npos ||
                    mass_plex != std::string::npos ||
                    mass_qobuz != std::string::npos ||
                    mass_radiobrowser != std::string::npos ||
                    mass_soundcloud != std::string::npos ||
                    mass_spotify != std::string::npos ||
                    mass_tidal != std::string::npos ||
                    mass_tunein != std::string::npos ||
                    mass_ytmusic != std::string::npos)) {
              ESP_LOGD("tagreader", "Found Music Assistant tag NDEF");
              id(source) = "mass";
              id(url) = payload;
            }
            else if (type == "T" ) {
              ESP_LOGD("tagreader", "Found music info tag NDEF");
              id(info)=payload;
            }
            else if ( id(source)=="" ) {
              id(source)="uid";
            }
          }
        }
        else {
          id(source)="uid";
        }

    - if:
        condition:
          lambda: 'return ( id(source)=="uid" );'
        then:
          - homeassistant.tag_scanned: !lambda |-
              ESP_LOGD("tagreader", "No HA NDEF, using UID");
              return x;
        else:
        - if:
            condition:
              lambda: 'return ( id(source)=="hass" );'
            then:
            - homeassistant.tag_scanned: !lambda 'return id(info);'
            else:
            - homeassistant.event:
                event: esphome.music_tag
                data:
                  reader: !lambda |-
                    return App.get_name().c_str();
                  source: !lambda |-
                    return id(source);
                  url: !lambda |-
                    return id(url);
                  info: !lambda |-
                    return id(info);

    - if:
        condition:
          switch.is_on: buzzer_enabled
        then:
        - rtttl.play: "success:d=24,o=5,b=100:c,g,b"
  on_tag_removed:
    then:
    - homeassistant.event:
        event: esphome.tag_removed
# Define the buzzer output
output:
- platform: esp8266_pwm
  pin: 3
  id: buzzer

binary_sensor:
  - platform: status
    name: "${friendly_name} Status"
    entity_category: diagnostic


text_sensor:
  - platform: version
    hide_timestamp: true
    name: "${friendly_name} ESPHome Version"
    entity_category: diagnostic
  - platform: wifi_info
    ip_address:
      name: "${friendly_name} IP Address"
      icon: mdi:wifi
      entity_category: diagnostic
    ssid:
      name: "${friendly_name} Connected SSID"
      icon: mdi:wifi-strength-2
      entity_category: diagnostic

# Define buzzer as output for RTTTL
rtttl:
  output: buzzer

# Configure LED
#light:
#- platform: neopixelbus
#  variant: WS2812
#  pin: 7
#  num_leds: 1
#  flash_transition_length: 500ms
#  type: GRB
#  id: activity_led
#  name: "${friendly_name} LED"
#  restore_mode: ALWAYS_OFF


Why do you have api: commented out?

There’s another API line which isn’t commented out towards the middle of the code.

Looks like a copy paste job from multiple sources

After some research and trying to understand…
Buzzer works
Led Works
it was the name of the adress of the PIN that were not correct.
Tag works but in my mind :

  • It’s long to have the RFID Card read (1 to 2s) and 1 or 2 seconds more to have the light turn On through HA
  • I’ve on the log file already the same message as here under, I tryied to chanege the update time to 1000ms but error is the same, do you have an idea?
    this is the line I added truing solve the problem (timeout mine):
i2c:
  scan: False
  frequency: 400kHz
  timeout: 1ms

the log file

INFO ESPHome 2025.3.0
INFO Reading configuration /config/esphome/lecteur-badge-3f8e3c-3f8e3c.yaml...
INFO Starting log output from 192.168.68.67 using esphome API
INFO Successfully connected to lecteur-badge-3f8e3c-3f8e3c @ 192.168.68.67 in 0.014s
INFO Successful handshake with lecteur-badge-3f8e3c-3f8e3c @ 192.168.68.67 in 2.486s
[14:09:00][I][app:100]: ESPHome version 2025.3.0 compiled on Mar 20 2025, 13:20:43
[14:09:00][I][app:102]: Project adonno.tag_reader version dev
[14:09:00][C][wifi:600]: WiFi:
[14:09:00][C][wifi:428]:   Local MAC: 40:F5:20:3F:8E:3C
[14:09:00][C][wifi:433]:   SSID: 'WiFi-2.4-F9E8'[redacted]
[14:09:00][C][wifi:436]:   IP Address: 192.168.68.67
[14:09:00][C][wifi:439]:   BSSID: E4:FA:C4:B8:2A:12[redacted]
[14:09:00][C][wifi:441]:   Hostname: 'lecteur-badge-3f8e3c-3f8e3c'
[14:09:00][C][wifi:443]:   Signal strength: -56 dB ▂▄▆█
[14:09:00][V][wifi:445]:   Priority: 0.0
[14:09:00][C][wifi:447]:   Channel: 3
[14:09:00][C][wifi:448]:   Subnet: 255.255.252.0
[14:09:00][C][wifi:449]:   Gateway: 192.168.68.1
[14:09:00][C][wifi:450]:   DNS1: 192.168.1.1
[14:09:00][C][wifi:451]:   DNS2: 192.168.1.1
[14:09:00][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=715623 (now=716628)
[14:09:00][C][logger:177]: Logger:
[14:09:00][C][logger:178]:   Max Level: VERY_VERBOSE
[14:09:00][C][logger:179]:   Initial Level: VERY_VERBOSE
[14:09:00][C][logger:181]:   Log Baud Rate: 115200
[14:09:00][C][logger:182]:   Hardware UART: UART0
[14:09:00][C][i2c.arduino:071]: I2C Bus:
[14:09:00][C][i2c.arduino:072]:   SDA Pin: GPIO4
[14:09:00][C][i2c.arduino:073]:   SCL Pin: GPIO5
[14:09:01][C][i2c.arduino:074]:   Frequency: 400000 Hz
[14:09:01][C][i2c.arduino:079]:   Timeout: 1000 us
[14:09:01][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[14:09:01][C][esp8266_pwm:022]: ESP8266 PWM:
[14:09:01][C][esp8266_pwm:023]:   Pin: GPIO0
[14:09:01][C][esp8266_pwm:024]:   Frequency: 988.0 Hz
[14:09:01][C][light:092]: Light 'Lecteur_badge LED'
[14:09:01][C][light:094]:   Default Transition Length: 1.0s
[14:09:01][C][light:095]:   Gamma Correct: 2.80
[14:09:01][C][template.switch:068]: Template Switch 'Lecteur_badge Buzzer Enabled'
[14:09:01][C][template.switch:070]:   Icon: 'mdi:volume-high'
[14:09:01][C][template.switch:090]:   Restore Mode: restore defaults to ON
[14:09:01][C][template.switch:057]:   Optimistic: YES
[14:09:01][C][template.switch:068]: Template Switch 'Lecteur_badge LED enabled'
[14:09:01][C][template.switch:070]:   Icon: 'mdi:alarm-light-outline'
[14:09:01][C][template.switch:090]:   Restore Mode: restore defaults to ON
[14:09:01][C][template.switch:057]:   Optimistic: YES
[14:09:01][C][mdns:116]: mDNS:
[14:09:01][C][mdns:117]:   Hostname: lecteur-badge-3f8e3c-3f8e3c
[14:09:01][V][mdns:118]:   Services:
[14:09:01][V][mdns:120]:   - _esphomelib, _tcp, 6053
[14:09:01][V][mdns:122]:     TXT: friendly_name = Lecteur_badge
[14:09:01][V][mdns:122]:     TXT: version = 2025.3.0
[14:09:01][V][mdns:122]:     TXT: mac = 40f5203f8e3c
[14:09:01][V][mdns:122]:     TXT: platform = ESP8266
[14:09:01][V][mdns:122]:     TXT: board = esp01_1m
[14:09:01][V][mdns:122]:     TXT: network = wifi
[14:09:01][V][mdns:122]:     TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[14:09:01][V][mdns:122]:     TXT: project_name = adonno.tag_reader
[14:09:01][V][mdns:122]:     TXT: project_version = dev
[14:09:01][V][mdns:122]:     TXT: package_import_url = github://adonno/tagreader/tagreader.yaml
[14:09:01][C][esphome.ota:073]: Over-The-Air updates:
[14:09:01][C][esphome.ota:074]:   Address: lecteur-badge-3f8e3c-3f8e3c.local:8266
[14:09:01][C][esphome.ota:075]:   Version: 2
[14:09:01][C][esphome.ota:078]:   Password configured
[14:09:01][C][safe_mode:018]: Safe Mode:
[14:09:01][C][safe_mode:019]:   Boot considered successful after 60 seconds
[14:09:01][C][safe_mode:021]:   Invoke after 10 boot attempts
[14:09:01][C][safe_mode:022]:   Remain in safe mode for 300 seconds
[14:09:01][C][api:140]: API Server:
[14:09:01][C][api:141]:   Address: lecteur-badge-3f8e3c-3f8e3c.local:6053
[14:09:01][C][api:143]:   Using noise encryption: YES
[14:09:01][C][improv_serial:032]: Improv Serial:
[14:09:01][C][wifi_info:012]: WifiInfo SSID 'Lecteur_badge Connected SSID'
[14:09:01][C][wifi_info:012]:   Icon: 'mdi:wifi-strength-2'
[14:09:01][V][wifi_info:012]:   Unique ID: '40f5203f8e3c-wifiinfo-ssid'
[14:09:01][C][wifi_info:010]: WifiInfo IPAddress 'Lecteur_badge IP Address'
[14:09:01][C][wifi_info:010]:   Icon: 'mdi:wifi'
[14:09:01][V][wifi_info:010]:   Unique ID: '40f5203f8e3c-wifiinfo-ip'
[14:09:01][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=716212 (now=717218)
[14:09:01][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=716623 (now=717623)
[14:09:02][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=716796 (now=717796)
[14:09:02][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=717212 (now=718215)
[14:09:02][VV][i2c.arduino:176]: 0x24 TX 0000FF04FCD44A0100E100
[14:09:02][V][pn532:284]: Reading ACK...
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 01
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 010000FF00FF00
[14:09:02][V][pn532:295]: ACK valid: YES
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:02][V][pn532:330]: Timed out waiting for readiness from PN532!
[14:09:02][V][pn532:300]: Sending ACK for abort
[14:09:02][VV][i2c.arduino:176]: 0x24 TX 0000FF00FF00
[14:09:02][V][pn532:352]: Turning RF field OFF
[14:09:02][VV][i2c.arduino:176]: 0x24 TX 0000FF04FCD4320100F900
[14:09:02][V][pn532:284]: Reading ACK...
[14:09:02][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=717623 (now=718623)
[14:09:03][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=717796 (now=718796)
[14:09:03][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=718212 (now=719212)
[14:09:03][VV][i2c.arduino:176]: 0x24 TX 0000FF04FCD44A0100E100
[14:09:03][V][pn532:284]: Reading ACK...
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 01
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 010000FF00FF00
[14:09:03][V][pn532:295]: ACK valid: YES
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:03][V][pn532:330]: Timed out waiting for readiness from PN532!
[14:09:03][V][pn532:300]: Sending ACK for abort
[14:09:03][VV][i2c.arduino:176]: 0x24 TX 0000FF00FF00
[14:09:03][V][pn532:352]: Turning RF field OFF
[14:09:03][VV][i2c.arduino:176]: 0x24 TX 0000FF04FCD4320100F900
[14:09:03][V][pn532:284]: Reading ACK...
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 01
[14:09:03][VV][i2c.arduino:148]: 0x24 RX 010000FF00FF00
[14:09:03][V][pn532:295]: ACK valid: YES
[14:09:03][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=718623 (now=719623)
[14:09:03][VV][scheduler:225]: Running interval '' with interval=5000 last_execution=714627 (now=719629)
[14:09:04][VV][light.addressable:015]: Addressable Light 'Lecteur_badge LED' (effect_active=NO)
[14:09:04][VV][light.addressable:018]:   [ 0] Color: R=  0 G=  0 B=  0 W=  0
[14:09:04][VV][light.addressable:021]:  
[14:09:04][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=718796 (now=719796)
[14:09:04][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=719212 (now=720216)
[14:09:04][VV][i2c.arduino:176]: 0x24 TX 0000FF04FCD44A0100E100
[14:09:04][V][pn532:284]: Reading ACK...
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 01
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 010000FF00FF00
[14:09:04][V][pn532:295]: ACK valid: YES
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:04][VV][i2c.arduino:148]: 0x24 RX 00
[14:09:04][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=719623 (now=720623)
[14:09:05][VV][scheduler:225]: Running interval 'update' with interval=1000 last_execution=719796 (now=720796)

Thank in advance for your time and your reply :slight_smile: