#Esp32 NFC reader

1 messages · Page 1 of 1 (latest)

keen laurel
#

Hi, im trying to create this NFC "vhs player" from thestockpot https://www.thestockpot.net/videos/cartrdgeplayer, Im using an esp32 c6 with an RC522 reader, im unable to view any entities or read the tags in home assistant but they seem to show up on the web . esphome logs properly
any idea what i could be doing wrong here?

#

heres the code (ps:im very new to this and used chat gpt to modify the original code)

#
esphome:
  name: cartridge-player
  friendly_name: Cartridge Player
  name_add_mac_suffix: true
  comment: "NFC based cartridge player from The Stock Pot [C3 Zero version]"
  project:
    name: "The Stock Pot.Cartridge Player"
    version: "1.0.3"

esp32:
  board: esp32-c6-devkitc-1
  framework:
    type: esp-idf

logger:

api:

ota:
  platform: esphome

wifi:
  ssid: ""
  password: ""
  power_save_mode: NONE


  ap:
    
captive_portal:

# SPI connection for RC522
spi:
  clk_pin: GPIO23
  mosi_pin: GPIO22
  miso_pin: GPIO20


# Enable the Web Server component 
web_server:
  port: 80
  version: 3




# Global to track last tag detection time (for debounce)
globals:
  - id: last_tag_time
    type: unsigned long
    restore_value: no
    initial_value: '0'

# Buzzer on GPIO1
output:
  - platform: gpio
    pin: GPIO1
    id: buzzer_output

# Button to manually trigger a beep
button:
  - platform: template
    name: "Cartridge Player Beep"
    id: buzzer_button
    on_press:
      then:
        - output.turn_on: buzzer_output
        - delay: 100ms
        - output.turn_off: buzzer_output

# RC522 SPI Reader
rc522_spi:
  id: rc522_reader
  cs_pin: GPIO21
  reset_pin: GPIO7
  update_interval: 250ms
#
on_tag:
    then:
      - lambda: |-
          id(last_tag_time) = millis();
      - logger.log:
          format: "Cartridge detected: %s"
          args: ['x.c_str()']
      - text_sensor.template.publish:
          id: last_uid
          state: !lambda 'return x;'
      - binary_sensor.template.publish:
          id: tag_present
          state: true
      - homeassistant.event:
          event: esphome.nfc_card_inserted
          data:
            uid: !lambda 'return x;'

  on_tag_removed:
    then:
      - delay: 500ms
      - lambda: |-
          if (millis() - id(last_tag_time) > 500) {
            ESP_LOGI("rfid", "Cartridge removed (debounced)");
            id(last_uid).publish_state("");
            id(tag_present).publish_state(false);
          }
      - if:
          condition:
            lambda: 'return millis() - id(last_tag_time) > 500;'
          then:
            - homeassistant.event:
                event: esphome.nfc_card_removed
                data:
                  message: "Cartridge removed"

# Current Tag UID
text_sensor:
  - platform: template
    name: "Cartridge ID"
    id: last_uid
    update_interval: never
    internal: false

# Whether a cartridge is inserted
binary_sensor:
  - platform: template
    name: "Cartridge Present"
    id: tag_present
#

this is what i see in home assistant

#

logs from web. esphome

tepid thistle
# keen laurel Hi, im trying to create this NFC "vhs player" from thestockpot https://www.thest...

this might be better asked on the ESPHome discord server.
but some thoughts after giving things a look over.
you should update your home assistant install
then your esphome builder tool which i assume may also be out of date.

the example code for the project uses the arduino framework instead of esp-idf which you have here. although I don't know if there's any difference with these components.

using an LLM to modify stuff might not always work out well. its worth looking through the esphome documentation and seeing if the stuff is correct or not where it made changes.

keen laurel
#

omggg thank you, updating home assistant fixed the issue!!!!!!!!!! cant believe it was soo simple

#

thanks alot man

tepid thistle
tepid thistle