I am working on adding a NFC reader and used a NodeMCU coupled with a RC-522 reader. I followed the RC-522 and NodeMCU documentation, as well as a detailed description of the RC-522 pinout. The inspiration was the answer in a French community.
This is coupled with the following ESPHome configuration:
esphome:
name: badge
esp8266:
board: nodemcuv2
logger:
api:
password: ""
ota:
password: ""
wifi:
ssid: "XXX"
password: "XXX"
ssid: "Badge Fallback Hotspot"
password: "XXX"
domain: .XXX
captive_portal:
mqtt:
broker: 192.168.10.2
spi:
clk_pin: D5
mosi_pin: D2
miso_pin: D1
rc522_spi:
cs_pin: D6
update_interval: 1s
on_tag:
then:
- homeassistant.tag_scanned: !lambda "return x;"
- mqtt.publish:
topic: rc522/tag
payload: !lambda "return x;"
switch:
- platform: gpio
name: "LedBleu2RFIDPF"
pin: 2
This solution works great (connects to HA, sends the scanned tag to MQTT, the blue LED is driven), except for one point: how should I use and configure the following pins of the RC-522:
- pin 2 (RST), I guess that the NodeMCU will send a reset signal on its own, where should pin2 of the badge reader connected to the NodeMCU?
- pin 4 (IRQ), apparently the badge reader (?) can go in deep sleep and the NodeMCU wakes it up (or maybe this is the other way round). What si the expected connection?
As a side/minor problem, with the configuration above, the blue LED starts on and is seen as off by HA. Switching it “on” in HA switches it off on the NodeMCU. The reality is flipped with how HA sees that LED.