I am trying to connect NFC module PN 532 to home assistant.
On Raspberry Pi Zero
Using Python it is working, I can read any cards.
But I do not understand how to integrate it with HomeAssistant.
Any assistants would be appreciated.
My configuration:
Home Assistant: 2021.1.5
Python: 3.7.3
OS: Linux raspberrypi 5.10.17+
CPU: armv6l
Working code on Python:
import board
import busio
from digitalio import DigitalInOut
from adafruit_pn532.i2c import PN532_I2C
reset_pin = DigitalInOut(board.D6)
req_pin = DigitalInOut(board.D12)
i2c = busio.I2C(board.SCL, board.SDA)
pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
ic, ver, rev, support = pn532.firmware_version
print(‘Found PN532 with firmware version: {0}.{1}’.format(ver, rev))
pn532.SAM_configuration()
while True:
uid = pn532.read_passive_target(timeout=0.5)
print(’.’, end="", flush=True)
if uid is None:
continue
print(‘Found card with UID:’, [hex(i) for i in uid])
Result:
login as: pi
[email protected]’s password:
Linux raspberrypi 5.10.17+ #1403 Mon Feb 22 11:26:13 GMT 2021 armv6l
pi@raspberrypi:~ $ python3 pn532.py
Found PN532 with firmware version: 1.6
.Found card with UID: [‘0x1’, ‘0x2’, ‘0x3’, ‘0x4’]