Skip to main content

pepper_c1

Python driver for the Eccel Pepper C1 RFID reader made by Eccel Technology Ltd.

Supports communication over UART and TCP, and covers MIFARE Classic, MIFARE Ultralight, MIFARE DESFire, and ICODE tag families.

Compatibility

Module UART TCP MIFARE Classic MIFARE Ultralight MIFARE DESFire ICODE
Pepper C1 ✓ ✓ ✓ ✓ ✓ ✓
Pepper C2 ✓ — ✓ ✓ — ✓

Pepper C2 modules communicate over UART only and do not support the MIFARE DESFire command set (mfdf_* methods). All other commands work identically to the C1. From C2 firmware 1.21 MIFARE DESFire and NTAG 424 DNA tags can be used with ISO 7816-4 APDUs (iso_apdu_exchange()) - see tools/c2_ntag424_ndef_apdu.py. From the same firmware iso14443a_raw_exchange() works too, with full bytes only (tx_last_bits 0, no 7-bit frames such as WUPA).

Installation

pip install pepper_c1

Quick start

from pepper_c1 import PepperC1, UARTTransport

with PepperC1(UARTTransport('/dev/ttyUSB0', baudrate=115200)) as reader:
    print(reader.get_version())
    count = reader.get_tag_count()
    if count:
        uid_info = reader.get_uid()  # returns [type, param, uid_bytes...]
        print(f"Tag UID: {uid_info[2:].hex()}")

MIFARE Classic example

from pepper_c1 import PepperC1, UARTTransport
from pepper_c1.commands import KEY_TYPE_MIFARE

with PepperC1(UARTTransport('/dev/ttyUSB0')) as reader:
    reader.get_tag_count()
    reader.activate_tag()
    reader.set_key(0, KEY_TYPE_MIFARE, bytes([0xFF] * 12))  # key A + key B

    original = reader.mf_read_block(5)
    print(f"Block 5: {original.hex()}")

    reader.mf_write_block(5, b'\x01' * 16)
    print(f"Readback: {reader.mf_read_block(5).hex()}")

    reader.mf_write_block(5, original)  # restore

MIFARE Ultralight example

from pepper_c1 import PepperC1, UARTTransport

with PepperC1(UARTTransport('/dev/ttyUSB0')) as reader:
    reader.get_tag_count()
    reader.activate_tag()

    original = reader.mfu_read_page(4)
    print(f"Page 4: {original.hex()}")

    reader.mfu_write_page(4, b'\x01\x02\x03\x04')
    print(f"Readback: {reader.mfu_read_page(4).hex()}")

    reader.mfu_write_page(4, original)  # restore

MIFARE DESFire example

from pepper_c1 import PepperC1, UARTTransport
from pepper_c1.commands import KEY_TYPE_AES128

with PepperC1(UARTTransport('/dev/ttyUSB0')) as reader:
    # DESFire does not need activate_tag
    reader.get_tag_count()
    reader.mfdf_select_app(bytes([0x00, 0x00, 0x00]))  # select PICC master app
    reader.set_key(0, KEY_TYPE_AES128, bytes(16))       # all-zero = factory default
    reader.mfdf_auth_aes(key_no=0, key_slot=0)

    app_ids = reader.mfdf_get_app_ids()
    for aid in app_ids:
        print(f"AID: {aid.hex()}")

ISO 7816-4 APDU example (NDEF from NTAG 424 DNA)

iso_apdu_exchange() sends any APDU to an ISO14443-4 tag (SAK bit 0x20: NTAG 424 DNA, MIFARE DESFire, smart cards, phones in card emulation) and returns the response with the status word (SW1 SW2). Requires Pepper C1 firmware 3.0 or newer.

from pepper_c1 import PepperC1, UARTTransport

def trace(direction, payload):          # optional: log commands without the binary framing
    print(direction, payload.hex(' ').upper())

with PepperC1(UARTTransport('/dev/ttyUSB0'), trace=trace) as reader:
    reader.get_tag_count()              # a single ISO14443-4 tag is activated here
    reader.iso_apdu_exchange(bytes.fromhex('00A4040007D276000085010100'))  # NDEF application
    reader.iso_apdu_exchange(bytes.fromhex('00A4000C02E104'))              # NDEF file
    nlen = int.from_bytes(reader.iso_apdu_exchange(bytes.fromhex('00B0000002'))[:2], 'big')
    resp = reader.iso_apdu_exchange(bytes([0x00, 0xB0, 0x00, 0x02, nlen]))
    print(f"NDEF message: {resp[:-2].hex()}, SW {resp[-2:].hex()}")

Full examples with logs: tools/desfire_apdu.py (DESFire commands as APDUs) and tools/ntag424_ndef_apdu.py (DESFire prepared like an NTAG 424 DNA, then NDEF read with ISO SELECT / READ BINARY). Both format the card at the end. For the Pepper C2, which has no mfdf_* commands, use tools/c2_ntag424_ndef_apdu.py: the same test with APDUs only, the DESFire authentication for the final format is calculated in the script (requires pip install cryptography).

Raw ISO14443-3A example (NTAG21x)

iso14443a_raw_exchange() sends a raw ISO14443-3A frame, for tag commands without a dedicated method (e.g. NTAG21x FAST_READ, READ_CNT) and low-level frames (WUPA, HLTA). CRC, timeout and the number of bits of the last byte are selectable. Requires Pepper C1 firmware 3.0 or newer.

from pepper_c1 import PepperC1, UARTTransport

with PepperC1(UARTTransport('/dev/ttyUSB0')) as reader:
    reader.get_tag_count()
    data, bits = reader.iso14443a_raw_exchange(bytes([0x3A, 0x00, 0x0F]))   # FAST_READ pages 0-15
    print(f"pages 0-15: {data.hex()}")
    ack, bits = reader.iso14443a_raw_exchange(b'\xA2\x04' + data[16:20])    # WRITE page 4 (same data)
    print(f"ACK {ack.hex()} ({bits} bits)")                                  # 0a (4 bits)

Full example with logs: tools/ntag21x_raw.py (GET_VERSION, READ_SIG, FAST_READ, ACK/NAK, WUPA).

ICODE example

from pepper_c1 import PepperC1, UARTTransport

with PepperC1(UARTTransport('/dev/ttyUSB0')) as reader:
    # ICODE (ISO 15693) does not need activate_tag
    reader.get_tag_count()
    reader.get_uid()

    original = reader.icode_read_block(5)
    print(f"Block 5: {original.hex()}")

    reader.icode_write_block(5, b'\x01\x02\x03\x04')
    print(f"Readback: {reader.icode_read_block(5).hex()}")

    reader.icode_write_block(5, original)  # restore

Antenna multiplexer example

For readers with multiple antennas, use set_active_antenna() to switch between them (1–8):

import time
from pepper_c1 import PepperC1, UARTTransport

with PepperC1(UARTTransport('/dev/ttyUSB0')) as reader:
    while True:
        for antenna in range(1, 9):
            reader.set_active_antenna(antenna)
            count = reader.get_tag_count()
            if count:
                uid_info = reader.get_uid()
                tag_type = uid_info[0]
                uid = uid_info[2:].hex().upper()
                print(f"Antenna {antenna}: type=0x{tag_type:02X}  UID={uid}")
            else:
                print(f"Antenna {antenna}: --")

See tools/mux_example.py for the full CLI script with transport selection and configurable dwell time.

Firmware update (OTA)

import math
from pepper_c1 import PepperC1, TCPTransport
from pepper_c1.commands import Command

fw_data    = open("Pepper_C1_2.56.2249.bin", "rb").read()
chunk_size = 1024
num_frames = math.ceil(len(fw_data) / chunk_size)

with PepperC1(TCPTransport('192.168.100.1', 1234), response_timeout=2.0) as reader:
    reader._timeout = 5.0
    reader.send_command(Command.OTA_BEGIN)

    reader._timeout = 2.0
    for i in range(num_frames):
        chunk = fw_data[i * chunk_size : (i + 1) * chunk_size]
        reader.send_command(Command.OTA_FRAME, chunk)
        print(f"\r  {(i + 1) * 100 // num_frames}%  frame {i + 1}/{num_frames}", end="")

    print()
    reader._timeout = 5.0
    reader.send_command(Command.OTA_FINISH)
    reader.reboot()

See tools/firmware_update.py for the full script with progress bar and CLI options.

Configuration backup and restore

The reader keeps its configuration in a config.json file, which you can save to a file and restore later.

Download a backup:

from pepper_c1 import PepperC1, UARTTransport

with PepperC1(UARTTransport('COM3'), response_timeout=3.0) as reader:
    data = reader.read_config()

with open("backup.json", "wb") as f:
    f.write(data)

Restore it:

from pepper_c1 import PepperC1, UARTTransport

with open("backup.json", "rb") as f:
    data = f.read()

with PepperC1(UARTTransport('COM3'), response_timeout=3.0) as reader:
    reader.write_config(data)   # checks the JSON, writes the file and reads it back to verify
    reader.reboot()             # the new configuration takes effect after a reboot

Use TCPTransport('192.168.100.1', 1234) to do the same over TCP. If write_config() raises an error, the configuration on the reader may be incomplete, so do not power it off; run the restore again.

For a ready-made command-line version, see tools/config_backup.py:

python config_backup.py uart COM3 download backup.json
python config_backup.py uart COM3 restore backup.json
python config_backup.py tcp 192.168.100.1 restore backup.json

The saved file may contain sensitive data such as MIFARE keys or Wi-Fi passwords, so store it securely. Restoring a file on a different reader also copies its name and network settings.

TCP transport

from pepper_c1 import PepperC1, TCPTransport

# Connect via TCP before opening UART — closing UART may reset the device
with PepperC1(TCPTransport('192.168.100.1', 1234)) as reader:
    print(reader.get_version())
    count = reader.get_tag_count()
    if count:
        uid_info = reader.get_uid()
        print(f"Tag UID: {uid_info[2:].hex()}")

Error handling

from pepper_c1 import PepperC1, UARTTransport, CommandError, TransportError

try:
    with PepperC1(UARTTransport('/dev/ttyUSB0')) as reader:
        reader.get_tag_count()
        reader.get_uid()
except TransportError as e:
    print(f"Connection failed: {e}")
except CommandError as e:
    print(f"Device error: {e}")

Protocol

The Pepper C1 uses a binary framing protocol over serial or TCP:

[0xF5] [LEN_L] [LEN_H] [LEN_L^0xFF] [LEN_H^0xFF] [PAYLOAD...] [CRC_L] [CRC_H]

CRC is CCITT-16 computed over the payload only. Low-level access is available via PepperC1.send_command(cmd, data).

Changelog

Also on the documentation page.

0.5.1 (2026-11-23)

Added

  • tools/firmware_update.py reconnects on its own when the reader restarts into the bootloader and into the new firmware (Pepper C2, C1 Lite), so the update runs in one go, and prints the new firmware version at the end.
  • tools/ntag21x_raw.py runs on the Pepper C2 as well (C2 firmware 1.21: full bytes only, the 7-bit WUPA step is skipped).
  • Example tools/c2_ntag424_ndef_apdu.py for the Pepper C2: NDEF test with ISO 7816-4 APDUs only, including the DESFire authentication and format (needs pip install cryptography). Requires C2 firmware with ISO_APDU_EXCHANGE (0xC0).

0.5.0 (2026-11-23)

Added

  • iso14443a_raw_exchange(): sends raw ISO14443-3A frames with selectable CRC, timeout and number of bits of the last byte (new ISO14443A_RAW_EXCHANGE (0xC1) command), e.g. NTAG21x commands without a dedicated method. Requires Pepper C1 firmware 3.0 or newer.
  • Example tools/ntag21x_raw.py: NTAG21x GET_VERSION, READ_SIG, FAST_READ, 4-bit ACK/NAK, WUPA and anticollision, with full command logs.

0.4.1 (2026-11-23)

Added

  • Changelog in the README (shown on PyPI) and on the documentation page.

0.4.0 (2026-11-23)

Added

  • iso_apdu_exchange(): sends ISO 7816-4 APDUs to ISO14443-4 tags (NTAG 424 DNA, MIFARE DESFire, smart cards, phones in card emulation) with the new ISO_APDU_EXCHANGE (0xC0) command. Requires Pepper C1 firmware 3.0 or newer.
  • trace option of PepperC1: logs every command and response without the binary protocol framing.
  • Example tools/desfire_apdu.py: MIFARE DESFire commands sent as APDUs, with full command logs.
  • Example tools/ntag424_ndef_apdu.py: prepares a DESFire card as an NTAG 424 DNA style NDEF tag and reads the NDEF message with ISO SELECT / READ BINARY, as from a real NTAG 424 DNA.

Fixed

  • Error codes in CommandError were shown with swapped bytes (e.g. 0x0102 instead of 0x0201).
  • mfdf_auth() and mfdf_auth_aes() sent key_no and key_slot in the wrong order. Breaking: code that swapped the arguments to work around it must be changed back.
  • DESFire examples and c1-desfire authenticate the application with the correct AES key slot.

Metadata

Release files for pepper-c1 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pepper-c1 0.5.1
File Size Uploaded Provenance Actions
pepper_c1-0.5.1.tar.gz 31.8 kB Without provenance Details for pepper_c1-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pepper-c1 0.5.1
File Interpreter ABI Platform Actions
pepper_c1-0.5.1-py3-none-any.whl Python 3 none any Details for pepper_c1-0.5.1-py3-none-any.whl

Total release size: 54.6 kB

Release files / pepper_c1-0.5.1.tar.gz

Download URL pepper_c1-0.5.1.tar.gz
Size 31.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c6e316fcc0d16287fa6127e9e8538ca482f49f2c71c188c4096d5e6931df4c74
BLAKE2b-256 checksum
How to use checksums
a6de3b7ba3f9fa2bb9a0a0a8dd722e740e82111d81222b95d2ce2a45d13ee502
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / pepper_c1-0.5.1-py3-none-any.whl

Download URL pepper_c1-0.5.1-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
385ba0c8cbc39255b6555d0977bbec988adc223beb341d671b532880eeb4dca6
BLAKE2b-256 checksum
How to use checksums
7c9b5009ba713a6f32e2f49e37e82d554683f17133736522b220ef49483fe6f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for pepper-c1 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page