Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A Python wrapper for MATRIX HAL NFC

Project description


MATRIX Lite NFC Py is a package that allows users of varying skill levels to easily program NFC with their MATRIX Creator.

Smartphone Apps For Debugging


  • [x] Reading Info (All tags)
  • [x] Reading Pages (MIFARE Ultralight & NTAG)
  • [x] Writing Page (MIFARE Ultralight & NTAG)
  • [x] Reading NDEF (MIFARE Ultralight & NTAG)
  • [x] Writing NDEF (MIFARE Ultralight & NTAG)
  • [ ] Docker deployment to PyPi


  1. Install matrix-hal-nfc to use this library.


Import Statement

import matrix_lite_nfc as nfc


When a read or write function completes, it will contain a status code to indicate the result. nfc.Status returns a string of what that number means.


There can only be one instance of NFC reading. This is a hardware limitation that will not change.

Synchronous Read

A simple read that returns an object with tag data.{
    # At least 1 read options is required. Less options -> faster reading!
    "info": True,  # Generic information for any NFC tag
    "pages": True, # All page data
    "ndef": True,  # A single page(faster than pages)
    "page": 0,     # All NDEF data

Starting Read Loop

A non-blocking loop that passes tag data to a callback.

def read_callback(tag):
    if(tag.status == 256):
        print("NFC Tag Scanned!")
    elif(tag.status == 1024):
        print("Nothing Scanned!")

# Configure what you want to read{
    "rate": 0.5, # Read loop speed (Seconds)
    "info": True,
    "pages": True,
    "ndef": True,
    "page": 0,
}, read_callback)

Stopping Read Loop


1. Creating a new NDEF Message

# Create an empty NDEF message
msg = nfc.Message()

# Add NDEF Records to message
msg.addTextRecord("Hello World")
msg.addTextRecord("Hola Mundo", "es")
msg.addMimeMediaRecord("text/json", '{"answer": 42}')

# You then pass msg into nfc.write.message(msg)

2. Reading a new NDEF Message

# Get NDEF data from scanned tag
tag ={"ndef": True})

# Create & print NDEF message
msg = nfc.Message(tag.ndef.content)


Writing to an NFC tag should normally be done inside the read loop.

Writing an NDEF message

# Create new message
msg = nfc.Message()

# Write and then Print status codes for activation & writing

Erasing an NDEF message


Writing to a tag's page (WARNING)

Be careful when writing to a page. You can accidentally lock your NFC tag!

# arg1: page you want to overwrite
# arg2: Array of numbers that represents a byte
print(, [48,45,59,21]))

Building Locally For Development

Download the repository.

git clone

Install pybind11.

sudo python3 -m pip install pybind11

Compile and install library.

sudo python3 -m pip install ./matrix-lite-nfc-py

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for matrix-lite-nfc, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size matrix_lite_nfc-0.0.1-cp35-cp35m-linux_armv6l.whl (3.7 MB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size matrix_lite_nfc-0.0.1-cp35-cp35m-linux_armv7l.whl (3.7 MB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size matrix_lite_nfc-0.0.1-cp37-cp37m-linux_armv6l.whl (3.7 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size matrix_lite_nfc-0.0.1-cp37-cp37m-linux_armv7l.whl (3.7 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size matrix_lite_nfc-0.0.1.tar.gz (10.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page