Imagine tapping a card on your desk and your AI agent logs your work hours, triggers a smart-home scene, or opens a VPN tunnel. That's exactly what you get when you connect an NXP PN532 NFC module to ASI Biont.
ASI Biont is an AI agent that connects hardware to arbitrary APIs. Instead of manual configuration screens, you describe your device in natural language and the agent writes the integration code on the fly. In this case study, I'll walk through connecting a PN532 NFC module to ASI Biont using two approaches: an ESP32 with MicroPython over MQTT, and a direct PC-serial connection via the ASI Biont Hardware Bridge. Both follow the same principle—you bring a physical object to your digital workflow, and the AI agent does the rest.
Why Pair PN532 with an AI Agent?
NFC tags are cheap, passive, and reliable. A single tag can represent a user, a device, or a context. In traditional setups, each reader needs custom code to map tag UIDs to actions. With ASI Biont, that mapping becomes a natural-language request: "When the tag with UID 04:12:34:56:78:AB:CD:EF is read, send a Telegram notification and add a calendar event."
Hardware Overview
The PN532 from NXP is a near-field communication controller that supports three interfaces: I2C, SPI, and UART (HSU). It operates at 13.56 MHz and can read NFC tags (ISO/IEC 14443 A/B, Mifare, FeliCa). For our example, we'll use UART because it's simple and works with both the ESP32 and a PC's USB-to-serial adapter.
| Pin (PN532) | Connects to ESP32 | Connects to USB-UART |
|---|---|---|
| VCC (3.3V) | 3V3 | VCC (3.3V) |
| GND | GND | GND |
| TXD | RX (GPIO16) | RX |
| RXD | TX (GPIO17) | TX |
| SEL0, SEL1 | high, low (UART) | high, low (UART) |
Make sure to set SEL0 high and SEL1 low to select UART mode. The module operates at 3.3V logic on most breakout boards, but some boards are 5V-tolerant; check your specific hardware before wiring.
Method 1: ESP32 + MicroPython + MQTT
The most elegant setup for a room-level NFC reader is to run a low-power ESP32 that publishes tag events to an MQTT broker. ASI Biont subscribes to that broker using the paho-mqtt library.
Here's a minimal MicroPython script for the ESP32 that reads the tag UID and publishes it to the topic nfc/read:
from machine import Pin, UART
import ubinascii
from umqtt.simple import MQTTClient
# PN532 over UART (pins 16 RX, 17 TX)
uart = UART(1, baudrate=115200, tx=Pin(17), rx=Pin(16))
# Send PN532 command: InListPassiveTarget (one target)
def read_uid():
uart.write(b'\x00\x00\xff\x04\xfc\xd4\x4a\x01\x00\xe1')
raw = uart.read(16)
if raw and raw[0] == 0x00:
uid = raw[-8:-2]
return ubinascii.hexlify(uid).decode()
return None
client = MQTTClient('nfc_reader', '192.168.1.100', 1883)
client.connect()
while True:
uid = read_uid()
if uid and uid != '00000000':
client.publish('nfc/read', uid)
print('Published:', uid)
time.sleep(1)
The command frame may look cryptic, but that's the point—ASI Biont's AI agent can generate protocol-specific code like this for you. You don't need to memorize frame formats.
Connecting ASI Biont to MQTT
In the ASI Biont chat, simply type:
Connect to MQTT broker at 192.168.1.100:1883, subscribe to
nfc/read, and when a UID arrives, look it up in the room map (room1: AA:BB:...; room2: ...), then call the smart-home API to turn on the corresponding light.
The agent will respond with an MQTT subscription using the paho-mqtt library. Here's a skeleton of what it generates:
import paho.mqtt.client as mqtt
import requests
ROOM_MAP = {
"aabbccdd": "room1",
"11223344": "room2"
}
def on_message(client, userdata, msg):
uid = msg.payload.decode()
room = ROOM_MAP.get(uid)
if room:
requests.post(f"http://home.local/lights/{room}/on")
client = mqtt.Client()
client.on_message = on_message
client.connect('192.168.1.100', 1883)
client.subscribe('nfc/read')
client.loop_forever()
This is a real MQTT integration. ASI Biont doesn't rely on cloud polling; it subscribes to the broker and reacts instantly.
Method 2: Direct Serial via Hardware Bridge
If you prefer to connect the PN532 directly to your PC, you can use the ASI Biont Hardware Bridge. Download bridge.py from the dashboard (it is never distributed via GitHub) and launch it with your token and port:
python bridge.py --token=YOUR_TOKEN --ports=COM3 --baud 115200 --rate=10
After that, ask ASI Biont: "Read the NFC tag on COM3 and log the UID to a CSV file." The agent can use industrial_command() for protocol-specific commands, but for PN532 it will likely switch to execute_python because the NFC protocol is so specific.
Here's a compact Python snippet that works inside the ASI Biont sandbox. Notice there is no while True (the sandbox enforces a 30-second timeout) and it directly uses pyserial:
import serial
ser = serial.Serial('COM3', 115200, timeout=0.2)
send = bytes.fromhex('0000ff04fcd44a0100e1') # InListPassiveTarget
ser.write(send)
resp = ser.read(16)
if resp and resp[0] == 0x00:
uid = resp[-8:-2].hex()
print(f"Tag UID: {uid}")
else:
print("No tag detected")
ser.close()
The AI agent adds retries, checksums, and error handling to this skeleton automatically.
How the AI Agent Builds the Integration
The real power of ASI Biont is execute_python. You don't need to wait for a vendor to release a "PN532 integration plugin." You describe the device in the chat—COM port, baud rate, protocol (UART/I2C/SPI), API keys, target broker—and the AI writes a Python script that uses pyserial, paho-mqtt, pymodbus, aiohttp, or any other approved library. The script runs in a sandbox with strict timeouts, but it's enough to talk to any device.
For example, if you have a Raspberry Pi with a PN532 on I2C, you would just say: "Use bus 1, address 0x24, with the pn532pi library." The agent will generate the corresponding code, or if the library isn't available, it'll write the protocol frames from scratch. This universal approach means your hardware is never a dead end.
Real-World Automation Scenarios
- Time tracking — Tap a tag to log billable hours in a spreadsheet or API.
- Room presets — Tap a tag at a desk to set lighting and temperature.
- Access events — Send a security alert if an unknown tag is presented.
- Device provisioning — Unlock a test bench when an authorized tag is scanned.
- Personal shortcuts — Tap a tag to call an LLM prompt or post a message to Teams.
These are all just chat instructions away. The UID from the tag is the key, and ASI Biont is the door.
Why This Matters for Everyone
The days of waiting for official device integrations are over. With ASI Biont, any engineer, maker, or IT pro can connect a PN532—or any other serial, MQTT, Modbus, or HTTP device—by simply describing the problem. The AI agent produces working code, you review it in the chat, and it runs. If the protocol changes, you change one line in the chat. That's how we gain true hardware ownership.
Sources and Further Reading
- NXP PN532/C1 user manual: nxp.com/docs/en/user-guide/141520.pdf
- MicroPython MQTT documentation: docs.micropython.org
- Eclipse Paho-MQTT client: eclipse.dev/paho
Try It Yourself
Grab any PN532 breakout, an ESP32 or a USB-UART adapter, and join ASI Biont at asibiont.com. In the chat, ask the agent to connect your NFC reader. Within minutes, you'll have a physical tag that triggers your digital world—no complex code, no waiting for plugins. Your next automation is already on your keychain.
Comments