Of course. Getting a USB-based PN544 NFC reader working in Ubuntu involves a few key steps: installing the necessary software, identifying your specific device, configuring the library to recognize it, and setting the correct permissions.
The PN544 is a popular NFC controller from NXP, but when connected via USB, it often isn't automatically handled by the kernel. Instead, we rely on the user-space library libnfc to communicate with it directly.
Here is a complete step-by-step guide.
Step 1: Install libnfc and Utilities
First, you need to install the core NFC library (libnfc) and the command-line tools (nfc-utils) that allow you to interact with the reader.
Open a terminal and run the following commands:
sudo apt update
sudo apt install libnfc-bin libnfc-dev
libnfc-bin: Provides the command-line utilities like nfc-list, nfc-poll, etc.
libnfc-dev: Provides the development headers. While not strictly necessary for just using the reader, it's good practice to install it.
Step 2: Identify Your USB NFC Reader
Plug your PN544 reader into a USB port. We need to find its Vendor ID and Product ID. The lsusb command is perfect for this.
lsusb
Look for a line that mentions NXP or a similar name. The PN544 is often sold under different brands, but it will likely have the NXP Vendor ID, which is 0471.
Your output might look something like this:
Bus 001 Device 005: ID 0471:021d NXP Semiconductors PN544 NFC Controller
In this example:
- Vendor ID is
0471
- Product ID is
021d
Write these two values down. You will need them in the next steps. Your IDs might be different, so be sure to use the ones from your lsusb output.
Step 3: Configure libnfc
Now, you need to tell libnfc how to find and communicate with your specific device. This is done by editing the main configuration file.
-
Backup the original configuration file (optional but recommended):
sudo cp /etc/nfc/libnfc.conf /etc/nfc/libnfc.conf.bak
-
Edit the configuration file:
sudo nano /etc/nfc/libnfc.conf
-
Modify the file content. The file contains many device definitions, most of which will be commented out with a #. You need to do two things:
- Comment out any active, non-matching device entries.
- Add a new entry for your USB PN544 device.
Scroll through the file. You might see an line like device.name = "_PN53x_USB". Make sure it is commented out by placing a # at the beginning of the line.
Now, add the following lines to the file. You can add them at the top for clarity. Remember to replace 0471 and 021d with your actual Vendor and Product IDs from Step 2.
# Allow intrusive auto-scan
allow_intrusive_scan = true
# Custom device entry for our USB PN544 reader
device.name = "NXP_PN544_USB_Reader"
device.connstring = "pn544_usb:0471:021d"
device.name: A descriptive name for your reader.
device.connstring: This is the most important part.
pn544_usb: Tells libnfc to use the specific driver for a USB-connected PN544.
:0471:021d: Specifies the Vendor and Product ID of your device.
-
Save the file and exit the editor (in nano, press Ctrl+X, then Y, then Enter).
Step 4: Set USB Device Permissions with udev
By default, only the root user has permission to directly access USB devices. To allow your regular user to access the NFC reader, you need to create a udev rule.
-
Create a new udev rules file:
sudo nano /etc/udev/rules.d/99-nfc.rules
-
Add the following line to the file. Again, replace 0471 and 021d with your device's IDs.
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="0471", ATTRS{idProduct}=="021d", MODE="0666"
- This rule tells the system: when a USB device is added (
ACTION=="add") that matches this Vendor ID (ATTRS{idVendor}) and Product ID (ATTRS{idProduct}), set its file permissions (MODE) to 0666 (read and write access for everyone).
-
Save the file and exit (Ctrl+X, Y, Enter).
-
Apply the new rule. You can either reboot your computer or run the following commands to make the system aware of the new rule without rebooting.
sudo udevadm control --reload-rules
sudo udevadm trigger
It's also a good idea to unplug and replug your NFC reader at this point to ensure the rule is applied to it.
Step 5: Test the NFC Reader
Now everything should be configured correctly. Let's test it.
-
List available NFC devices:
Run the nfc-list command. You should not need sudo if your udev rule is correct.
nfc-list
If successful, the output will look similar to this, showing the device name and connection string you defined in libnfc.conf:
nfc-list uses libnfc 1.7.1
Available NFC device:
1:
name: NXP_PN544_USB_Reader
connstring: pn544_usb:0471:021d
-
Poll for an NFC tag:
Now, let's try reading a tag. Run the nfc-poll command. It will wait for you to present a tag.
nfc-poll
The terminal will show:
nfc-poll uses libnfc 1.7.1
NFC reader: NXP_PN544_USB_Reader opened
NFC device will poll during 30000 ms (20s)
Now, place an NFC card or tag on your reader. If it works, you will see detailed information about the tag:
NFC device will poll during 30000 ms (20s)
ISO/IEC 14443A (106 kbps) target:
ATQA (SENS_RES): 00 44
UID (NFCID1): 01 23 45 67
SAK (SEL_RES): 00
Success! Your USB PN544 NFC reader is now working in Ubuntu.
Troubleshooting
If you encounter problems, here are the most common issues and solutions:
-
nfc-list shows "No NFC device found."
- Check IDs: Double-check that the Vendor and Product IDs in
/etc/nfc/libnfc.conf are exactly what lsusb reported.
- Check
libnfc.conf syntax: Ensure there are no typos. Make sure you haven't forgotten to comment out other conflicting device entries.
- Permissions Issue: Try running
sudo nfc-list. If this works, but the command without sudo doesn't, your udev rule is the problem. Re-check the file /etc/udev/rules.d/99-nfc.rules for correct IDs and syntax, and make sure you reloaded the rules.
-
nfc-list gives a "Permission denied" or similar error.
- This is almost certainly a
udev permissions problem. Go back to Step 4 and verify everything. Unplug and replug the device after fixing the rule.
-
Conflicting Kernel Module
- In some rare cases, a generic kernel module might try to claim the device, interfering with
libnfc. Check the kernel message log right after plugging in the device:
dmesg | tail
- If you see a module like
pn533_usb or similar claiming the device, you may need to blacklist it. This is uncommon for the PN544 but possible.