Skip to content

Examples

Nine runnable scripts live in the examples/ folder. Each one takes the serial port as an optional argument (default /dev/ttyUSB0) and uses the factory-default key FFFFFFFFFFFF:

python examples/01_basic_uid.py /dev/ttyUSB0     # Windows: COM3

Use a spare card

Examples 04–07 and 09 write to the card. They never touch sector trailers, but they will overwrite data blocks.

  • 01 — Basic card UID


    Reads the UID three ways and prints the reader's firmware version.

    ping() · get_version() · get_uid() · get_uid_int() · scan_tag()

    01_basic_uid.py

  • 02 — Event mode


    Turns on auto mode and waits for the reader to announce a card.

    wait_for_card()

    02_event_mode.py

  • 03 — Async wait


    Waits for a card without blocking an asyncio event loop. This is the pattern for FastAPI and other async services.

    wait_for_card_async()

    03_async_wait.py

  • 04 — Read & write a block


    Runs the full authenticate → read → write → verify cycle on one 16-byte block.

    authenticate_sector() · read_block() · write_block()

    04_read_write_block.py

  • 05 — Sector operations


    Reads and writes all three data blocks of a sector in one call.

    read_sector() · write_sector()

    05_sector_operations.py

  • 06 — Multi-sector bulk I/O


    Reads and writes blocks across several sectors, each with its own key.

    read_blocks() · write_blocks() · SectorAuth

    06_multi_sector_bulk.py

  • 07 — Value blocks


    Creates a stored-value counter, then increments, decrements, transfers and restores it.

    create_value_block() · increment_value() · decrement_value() · transfer() · restore()

    07_value_blocks.py

  • 08 — Multi-card enumeration


    Lists every card on the reader using HALT and REQUEST ALL.

    get_uid() · halt() · request_all()

    08_multi_card.py

  • 09 — RF power cycling


    Recovers a stuck card by switching the RF field off and on, inside a retry loop.

    rf_power() · authenticate_sector() · read_block()

    09_rf_power_reset.py

01 — Basic card UID

python examples/01_basic_uid.py

02 — Event mode

python examples/02_event_mode.py

03 — Async wait

python examples/03_async_wait.py

04 — Read and write a block

python examples/04_read_write_block.py

05 — Sector operations

python examples/05_sector_operations.py

06 — Multi-sector bulk I/O

python examples/06_multi_sector_bulk.py

07 — Value blocks

python examples/07_value_blocks.py

08 — Multi-card enumeration

python examples/08_multi_card.py

09 — RF power cycling

python examples/09_rf_power_reset.py