PN532 (NFC) Meets ASI Biont: Automate Your Door Access, Inventory, and More with an AI Agent

Introduction

NFC (Near Field Communication) is everywhere — from contactless payments and keyless entry to asset tracking and smart posters. The PN532 is the most popular NFC module for makers and industrial integrators, supporting both reader/writer and card emulation modes. But manually polling a tag, parsing its UID, and triggering an action (like opening a door or logging an asset) is tedious. What if you could just tell an AI agent: “When employee badge #1234 is scanned, unlock the door and log the entry in Google Sheets”?

That’s exactly what ASI Biont does. It’s an AI agent that connects to your PN532 via Hardware Bridge (COM port) or MQTT (if your PN532 is attached to an ESP32). You simply describe what you want in plain English, and ASI Biont writes the Python code, runs it, and controls the NFC reader — no manual programming required.

Why Connect PN532 to an AI Agent?

A standalone PN532 is a dumb peripheral — it can only read or write NFC tags when you send it commands. An AI agent adds:
- Context-aware actions: Scan a tag → AI checks a database → decides to grant or deny access.
- Multi-protocol orchestration: NFC scan triggers MQTT publish to a smart lock, or HTTP API call to a cloud attendance system.
- Error handling & logging: AI catches malformed reads, retries, and logs every event.
- Dynamic rule changes: Tell the AI “now let only managers in after 6 PM” — no firmware update needed.

Connection Methods Supported by ASI Biont

Method When to Use How ASI Biont Connects
Hardware Bridge (COM port) PN532 connected directly to your PC (USB-UART) or to an Arduino/ESP32 that exposes a serial port User runs bridge.py with --ports=COM3 --default-baud=115200. AI sends industrial_command(protocol='serial://COM3', command='write', data='...') or reads responses.
MQTT PN532 connected to an ESP32 that publishes tag UIDs to a broker (e.g., Mosquitto) AI writes a Python script with paho-mqtt, subscribes to topic nfc/tag, parses JSON, and triggers actions.
SSH PN532 connected to a Raspberry Pi (via I²C or SPI) AI uses paramiko to SSH into Pi, runs a local Python script that reads PN532, and returns results.

For this article, we’ll focus on the most common scenario: PN532 connected to a PC via USB-UART (e.g., using a USB-to-serial adapter) and controlled via Hardware Bridge. This works out of the box with ASI Biont’s industrial_command tool.

Real-World Scenario: NFC-Based Door Access with Auto-Logging

Hardware Setup

  • PN532 module (breakout board) connected to a USB-UART adapter (e.g., FTDI) via UART (TX → RX, RX → TX, VCC 3.3V, GND).
  • USB-UART adapter plugged into a Windows/Linux/macOS PC.
  • Bridge.py (from ASI Biont) running on that PC.

Wiring Diagram (simplified)

PN532 Pin USB-UART Adapter
VCC (3.3V) 3.3V
GND GND
TX RX
RX TX

Set the PN532’s DIP switches to UART mode (SEL0=0, SEL1=1).

Step 1: Discover the COM Port

On the PC, open Device Manager (Windows) or ls /dev/ttyUSB* (Linux). Note the port, e.g., COM3 or /dev/ttyUSB0. The PN532 communicates at 115200 baud by default.

Step 2: Run the Bridge

python bridge.py --token=YOUR_ASI_BIONT_TOKEN --ports=COM3 --default-baud=115200

The bridge connects to ASI Biont’s cloud via long polling. Now the AI can send serial commands to COM3.

Step 3: Tell the AI What to Do

In the ASI Biont chat, you type:

“Connect to PN532 on COM3. When a NFC tag is scanned, read its UID and send it to my webhook at https://myapi.com/access. If the UID is in the allowed list [‘04:12:34:56:78:9A’, ‘04:AB:CD:EF:00:11’], also publish a command to unlock the door via MQTT topic ‘door/unlock’.”

Step 4: AI Writes and Executes the Integration Code

ASI Biont generates a Python script that runs in its sandbox (execute_python). The script does the following:

# This code is written by ASI Biont AI agent
import asyncio
import json
import aiohttp
import paho.mqtt.client as mqtt

# Configuration
PORT = 'COM3'  # will be replaced by bridge
BAUD = 115200
ALLOWED_UIDS = ['04:12:34:56:78:9A', '04:AB:CD:EF:00:11']
WEBHOOK_URL = 'https://myapi.com/access'
MQTT_BROKER = '192.168.1.100'

# Note: This is a simplified representation.
# The actual bridge communication uses industrial_command tool.
# The AI will call industrial_command(protocol='serial://COM3', command='write', data=b'\x00\x00\xFF...') to send PN532 commands.
# For brevity, we show the logic.

async def scan_and_act():
    # 1. Send PN532 command to read a tag (InListPassiveTarget)
    # This is sent via industrial_command() in chat, not directly in sandbox
    # The bridge returns raw response

    # 2. Parse UID from response (PN532 returns 7-byte UID for MIFARE Classic)
    uid_raw = '04:12:34:56:78:9A'  # example

    # 3. Send to webhook
    async with aiohttp.ClientSession() as session:
        await session.post(WEBHOOK_URL, json={'uid': uid_raw, 'timestamp': '2026-07-13T10:00:00Z'})

    # 4. Check access
    if uid_raw in ALLOWED_UIDS:
        client = mqtt.Client()
        client.connect(MQTT_BROKER, 1883, 60)
        client.publish('door/unlock', '1')
        client.disconnect()
        print(f"Access granted for {uid_raw}")
    else:
        print(f"Access denied for {uid_raw}")

asyncio.run(scan_and_act())

The AI doesn’t just write the code — it actually executes it in the sandbox, sending serial commands via industrial_command in real time. The whole process takes seconds.

Step 5: Verify

Hold an NFC tag (e.g., a MIFARE card) near the PN532. The AI reads the UID, checks the allowed list, and if authorized, unlocks the door via MQTT. You see the log in the chat.

No-Code Integration: Just Describe

You don’t need to write a single line of Python. ASI Biont’s AI agent handles everything:
- It knows the PN532 protocol (InListPassiveTarget, SAMConfig, etc.) from its training data.
- It selects the correct industrial_command parameters.
- It constructs the MQTT or HTTP logic.
- It handles errors (e.g., timeout, no tag).

If you want to change the rule later, just say: “Now also log the UID to a PostgreSQL database” — the AI updates the script instantly.

Other Use Cases

Scenario AI Agent Action
Inventory management Scan NFC tags on boxes → AI writes to a spreadsheet (openpyxl) and updates a dashboard.
Attendance system Scan employee badge → AI checks time, logs to Google Sheets, sends Slack notification if late.
Smart poster User taps phone on PN532 → AI sends a welcome email and adds contact to CRM.
Medical equipment tracking Scan asset tag → AI queries database, returns last calibration date and maintenance history.

Why This Matters

Traditional NFC integrations require:
1. Writing a Python script with pyserial.
2. Manually parsing PN532 frames (SAMConfig, InListPassiveTarget, etc.).
3. Handling edge cases (timeouts, multiple tags).
4. Deploying and maintaining the script.

With ASI Biont, you skip all that. The AI does it in real time, for free, and you can change the logic with a sentence. It’s like having a senior firmware engineer on call 24/7.

Getting Started

  1. Connect your PN532 to your PC via USB-UART.
  2. Download bridge.py from ASI Biont (in the Integrations section).
  3. Run it with your token and COM port.
  4. Open the chat and describe your integration.

No dashboards, no “add device” buttons — just conversation.

Conclusion

PN532 is a powerful NFC module, but its true potential is unlocked when connected to an intelligent agent that can interpret tag data, make decisions, and orchestrate multi-system workflows. ASI Biont provides that intelligence with zero coding effort. Whether you’re building a smart office, a warehouse tracking system, or a home automation project, you can integrate PN532 in minutes.

Try it today at asibiont.com. Just describe what you want, and the AI will connect, control, and automate your NFC reader.

← All posts

Comments