UHF-RFID Unit

Support the following products:

UHFRFIDUnit

Micropython Example:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from unit import UHFRFIDUnit
 9
10
11nbiot2_0 = None
12uhfrfid_0 = None
13
14
15epc = None
16
17
18def setup():
19    global nbiot2_0, uhfrfid_0, epc
20
21    M5.begin()
22    Widgets.fillScreen(0x222222)
23
24    uhfrfid_0 = UHFRFIDUnit(2, port=(18, 17))
25    epc = uhfrfid_0.inventory()
26    print(epc)
27    uhfrfid_0.select(UHFRFIDUnit.S0, 0b000, UHFRFIDUnit.RFU, 0x20, False, epc)
28    uhfrfid_0.write_mem_bank(UHFRFIDUnit.RFU, 0x00, "12345678", "00000000")
29    print(uhfrfid_0.read_mem_bank(UHFRFIDUnit.RFU, 0x00, 4, "00000000"))
30
31
32def loop():
33    global nbiot2_0, uhfrfid_0, epc
34    M5.update()
35
36
37if __name__ == "__main__":
38    try:
39        setup()
40        while True:
41            loop()
42    except (Exception, KeyboardInterrupt) as e:
43        try:
44            from utility import print_error_msg
45
46            print_error_msg(e)
47        except ImportError:
48            print("please update to latest firmware")

UIFLOW2 Example:

example.png

cores3_uhf_rfid_example.m5f2

class UHFRFIDUnit

Constructors

class UHFRFIDUnit(id: Literal[0, 1, 2], port: list | tuple, verbose: bool = False)

Create a UHF-RFID unit.

Parameters:
  • id (int) – The ID of the unit.

  • port (list|tuple) – The port that the unit is connected to.

  • verbose (bool) – Print the log information. Default is True.

UIFLOW2:

init.png

Methods

Demodulator

UHFRFIDUnit.get_demodulator_mixer() int

Get demodulator mixer value.

Return int:

demodulator mixer value.

Options:
  • 0x00: 0dB

  • 0x01: 3dB

  • 0x02: 6dB

  • 0x03: 9dB

  • 0x04: 12dB

  • 0x05: 15dB

  • 0x06: 16dB

UIFLOW2:

get_demodulator_mixer.png

UHFRFIDUnit.set_demodulator_mixer(value: int) bool

Set demodulator mixer value.

Parameters:

value (int) – demodulator mixer value.

Options:
  • 0x00: 0dB

  • 0x01: 3dB

  • 0x02: 6dB

  • 0x03: 9dB

  • 0x04: 12dB

  • 0x05: 15dB

  • 0x06: 16dB

Return bool:

True if success, False if failed.

UIFLOW2:

set_demodulator_mixer.png

UHFRFIDUnit.get_demodulator_amplifier() int

Get demodulator amplifier value.

Return int:

demodulator amplifier value.

Options:
  • 0x00: 12dB

  • 0x01: 18dB

  • 0x02: 21dB

  • 0x03: 24dB

  • 0x04: 27dB

  • 0x05: 30dB

  • 0x06: 36dB

  • 0x07: 40dB

UIFLOW2:

get_demodulator_amplifier.png

UHFRFIDUnit.set_demodulator_amplifier(value: int) bool

Set demodulator amplifier value.

Parameters:

value (int) – demodulator amplifier value.

Options:
  • 0x00: 12dB

  • 0x01: 18dB

  • 0x02: 21dB

  • 0x03: 24dB

  • 0x04: 27dB

  • 0x05: 30dB

  • 0x06: 36dB

  • 0x07: 40dB

Return bool:

True if success, False if failed.

UIFLOW2:

set_demodulator_amplifier.png

UHFRFIDUnit.get_demodulator_threshold() int

Get demodulator threshold value.

Return int:

demodulator threshold value. the range is from 0x01B0 to 0xFFFF.

UIFLOW2:

get_demodulator_threshold.png

UHFRFIDUnit.set_demodulator_threshold(value: int) bool

Set demodulator threshold value.

Parameters:

value (int) – demodulator threshold value. the range is from 0x01B0 to 0xFFFF.

Return bool:

True if success, False if failed.

UIFLOW2:

set_demodulator_threshold.png

Working

UHFRFIDUnit.get_working_region() int

Get work region.

Return int:

work region.

Options:
  • UHFRFIDUnit.CN_900MHZ: China 900MHz

  • UHFRFIDUnit.CN_800MHZ: China 800MHz

  • UHFRFIDUnit.USA: USA

  • UHFRFIDUnit.EUR: EUR

  • UHFRFIDUnit.KR: KR

UIFLOW2:

get_working_region.png

UHFRFIDUnit.set_working_region(region: int) bool

Set work region.

Parameters:

region (int) – work region.

Options:
  • UHFRFIDUnit.CN_900MHZ: China 900MHz

  • UHFRFIDUnit.CN_800MHZ: China 800MHz

  • UHFRFIDUnit.USA: USA

  • UHFRFIDUnit.EUR: EUR

  • UHFRFIDUnit.KR: KR

Return int:

True if success, False if failed.

UIFLOW2:

set_working_region.png

UHFRFIDUnit.get_working_channel() int

Get work channel.

Return int:

work channel. the range is from 0 to 19.

UIFLOW2:

get_working_channel.png

UHFRFIDUnit.set_working_channel(channel: int) bool

Set work channel.

Parameters:

channel (int) – work channel. the range is from 0 to 19.

Return bool:

True if success, False if failed.

UIFLOW2:

set_working_channel.png

UHFRFIDUnit.insert_working_channel(channel: int) bool

Insert work channel.

Parameters:

channel (int) – work channel. the range is from 0 to 19.

Return bool:

True if success, False if failed.

UIFLOW2:

insert_working_channel.png

UHFRFIDUnit.clear_working_channel() bool

Clear work channel.

Return bool:

True if success, False if failed.

UIFLOW2:

clear_working_channel.png

UHFRFIDUnit.set_automatic_hopping(enable: bool) bool

Set automatic hopping.

Parameters:

enable (bool) – enable automatic hopping.

Return bool:

True if success, False if failed.

UIFLOW2:

set_automatic_hopping.png

RF Power

UHFRFIDUnit.get_channel_rssi(channel: int) int

Get channel RSSI value.

Parameters:

channel (int) – work channel. the range is from 0 to 19.

Return int:

channel RSSI value. the unit is dBm.

UIFLOW2:

get_channel_rssi.png

UHFRFIDUnit.get_blocking_signal_strength(channel: int) int

Get blocking signal strength.

Parameters:

channel (int) – work channel. the range is from 0 to 19.

Return int:

blocking signal strength. the unit is dBm.

UIFLOW2:

get_blocking_signal_strength.png

UHFRFIDUnit.get_tx_power() int

Get TX power.

Return int:

TX power. the unit is dBm. the range is from -7dBm to 30dBm.

UIFLOW2:

get_tx_power.png

UHFRFIDUnit.set_tx_power(power: int) bool

Set TX power.

Parameters:

power (int) – TX power. the range is from -7dBm to 30dBm.

Return bool:

True if success, False if failed.

UIFLOW2:

set_tx_power.png

UHFRFIDUnit.set_continuous_wave(enable: bool) bool

Set continuous wave.

Parameters:

enable (bool) – enable continuous wave.

Return bool:

True if success, False if failed.

UIFLOW2:

set_continuous_wave.png

Module Information and Settings

UHFRFIDUnit.get_manufacturer_id() str

Get manufacturer ID.

Return str:

manufacturer ID.

UIFLOW2:

get_manufacturer_id.png

UHFRFIDUnit.get_hardware_version() str

Get hardware version.

Return str:

hardware version.

UIFLOW2:

get_hardware_version.png

UHFRFIDUnit.get_firmware_version() str

Get firmware version.

Return str:

firmware version.

UIFLOW2:

get_firmware_version.png

UHFRFIDUnit.sleep() bool

Set sleep.

Return bool:

True if success, False if failed.

UIFLOW2:

sleep.png

UHFRFIDUnit.wake() bool

Set wake up.

Return bool:

True if success, False if failed.

UIFLOW2:

wake.png

UHFRFIDUnit.set_automatic_sleep_time(min: int) bool

Set automatic sleep time.

Parameters:

min (int) – automatic sleep time in minutes. the range is from 1 to 30.

Return bool:

True if success, False if failed.

UIFLOW2:

set_automatic_sleep_time.png

UHFRFIDUnit.disable_automatic_sleep() bool

Disable automatic sleep.

Return bool:

True if success, False if failed.

UIFLOW2:

disable_automatic_sleep.png

Read and Write Tag

UHFRFIDUnit.inventory() str

Get tag epc code. if no tag is found, return empty string.

Returns:

hexadecimal string of tag epc code.

UIFLOW2:

inventory.png

UHFRFIDUnit.set_select_mode(mode: int) bool

Set select mode.

Parameters:

mode (int) – select mode.

Options:
  • 0x00: need select command

  • 0x01: no need select command

  • 0x02: part operation need select command

Return bool:

True if success, False if failed.

UIFLOW2:

set_select_mode.png

UHFRFIDUnit.select(target: int, action: int, membank: int, pointer: int, truncate: bool, mask: str) bool

Set select tag.

Parameters:
  • target (int) – target.

  • action (int) – action.

  • membank (int) – memory bank.

  • pointer (int) – pointer.

  • truncate (bool) – truncate.

  • mask (str) – EPC code. hexadecimal string.

Return bool:

True if success, False if failed.

UIFLOW2:

select.png

UHFRFIDUnit.set_access_password(old_password: str, new_password: str) None

Set access password.

Parameters:
  • old_password (str) – old access password. hexadecimal string.

  • new_password (str) – new access password. hexadecimal string.

UIFLOW2:

set_access_password.png

UHFRFIDUnit.set_kill_password(password) None

Set kill password.

Parameters:

password (str) – kill password. hexadecimal string.

UIFLOW2:

set_kill_password.png

UHFRFIDUnit.kill(password: str) bool

Kill tag.

Parameters:

password (str) – kill password. hexadecimal string.

Return bool:

True if success, False if failed.

UIFLOW2:

kill.png

UHFRFIDUnit.set_query_param(dr=0b0, m=0b00, tr_ext=0b1, sel=0b00, session=0b00, target=0b0, q=0b0100) bool

Set query parameter.

Parameters:
  • dr (int) – dr. fixed to 0.

  • m (int) –

    1. fixed to 0.

  • tr_ext (int) – tr_ext. fixed to 1.

  • sel (int) – sel. the range is from 0 to 3.

  • session (int) – session. the range is from 0 to 3.

  • target (int) – target. the range is from 0 to 1.

  • q (int) –

    1. the range is from 0 to 8.

Return bool:

True if success, False if failed.

UIFLOW2:

set_query_param.png

UHFRFIDUnit.lock_mem_bank(kill_lock: int = 0b00, access_lock: int = 0b00, epc_lock: int = 0b00, tid_lock: int = 0b00, user_lock: int = 0b00, access: str = '00000000') bool

Lock memory bank.

Parameters:
  • kill_lock (int) –

    kill lock.

    Options:
    • UHFRFIDUnit.OPEN: open

    • UHFRFIDUnit.LOCK: lock

    • UHFRFIDUnit.PERMA_OPEN: perma open

    • UHFRFIDUnit.PERMA_LOCK: perma lock

  • access_lock (int) –

    access lock.

    Options:
    • UHFRFIDUnit.OPEN: open

    • UHFRFIDUnit.LOCK: lock

    • UHFRFIDUnit.PERMA_OPEN: perma open

    • UHFRFIDUnit.PERMA_LOCK: perma lock

  • epc_lock (int) –

    epc lock.

    Options:
    • UHFRFIDUnit.OPEN: open

    • UHFRFIDUnit.LOCK: lock

    • UHFRFIDUnit.PERMA_OPEN: perma open

    • UHFRFIDUnit.PERMA_LOCK: perma lock

  • tid_lock (int) –

    tid lock.

    Options:
    • UHFRFIDUnit.OPEN: open

    • UHFRFIDUnit.LOCK: lock

    • UHFRFIDUnit.PERMA_OPEN: perma open

    • UHFRFIDUnit.PERMA_LOCK: perma lock

  • user_lock (int) –

    user lock.

    Options:
    • UHFRFIDUnit.OPEN: open

    • UHFRFIDUnit.LOCK: lock

    • UHFRFIDUnit.PERMA_OPEN: perma open

    • UHFRFIDUnit.PERMA_LOCK: perma lock

  • access (str) – access password. hexadecimal string.

UIFLOW2:

lock_mem_bank.png

UHFRFIDUnit.read_mem_bank(bank: int, offset: int, length: int, access_password: str = '00000000') str

Read memory bank.

Parameters:
  • bank (int) –

    memory bank.

    Options:
    • UHFRFIDUnit.RFU: reserved

    • UHFRFIDUnit.EPC: epc

    • UHFRFIDUnit.TID: tid

    • UHFRFIDUnit.USER: user

  • offset (int) – offset.

  • length (int) – length.

  • access_password (str) – access password. hexadecimal string.

Return str:

data. hexadecimal string.

UIFLOW2:

read_mem_bank.png

UHFRFIDUnit.write_mem_bank(bank: int, offset: int, data: str, access_password: str = '00000000')

Write memory bank.

Parameters:
  • bank (int) –

    memory bank.

    Options:
    • UHFRFIDUnit.RFU: reserved

    • UHFRFIDUnit.EPC: epc

    • UHFRFIDUnit.TID: tid

    • UHFRFIDUnit.USER: user

  • offset (int) – offset.

  • data (str) – data. hexadecimal string.

  • access_password (str) – access password. hexadecimal string.

UIFLOW2:

write_mem_bank.png

Impinj Monza

UHFRFIDUnit.get_impinj_monza_qt_sr(persistence, password: str = '00000000') bool

Get Impinj Monza QT_SR.

Parameters:
  • persistence (int) – persistence. 0x00 is volatile memory, 0x01 is non-volatile memory.

  • password (str) – access password. hexadecimal string.

Return bool:

QT_SR status.

UIFLOW2:

get_impinj_monza_qt_sr.png

UHFRFIDUnit.set_impinj_monza_qt_sr(qt_sr: bool, persistence: int, password: str = '00000000') bool

Set Impinj Monza QT_SR.

Parameters:
  • qt_sr (bool) – QT_SR status.

  • persistence (int) – persistence. 0x00 is volatile memory, 0x01 is non-volatile memory.

  • password (str) – access password. hexadecimal string.

Return bool:

True if success, False if failed.

UIFLOW2:

set_impinj_monza_qt_sr.png

UHFRFIDUnit.get_impinj_monza_qt_mem(persistence, password: str = '00000000') bool

Set Impinj Monza QT_MEM.

Parameters:
  • persistence (int) – persistence. 0x00 is volatile memory, 0x01 is non-volatile memory.

  • password (str) – access password. hexadecimal string.

Return bool:

QT_MEM status.

UIFLOW2:

get_impinj_monza_qt_mem.png

UHFRFIDUnit.set_impinj_monza_qt_mem(qt_mem: bool, persistence: int, password: str = '00000000') bool

Set Impinj Monza QT_MEM.

Parameters:
  • qt_mem (bool) – QT_MEM status.

  • persistence (int) – persistence. 0x00 is volatile memory, 0x01 is non-volatile memory.

  • password (str) – access password. hexadecimal string.

Return bool:

True if success, False if failed.

UIFLOW2:

set_impinj_monza_qt_mem.png

NXP

UHFRFIDUnit.nxp_eas_alarm() str

Get NXP EAS alarm code.

Return str:

NXP EAS alarm code. hexadecimal string.

UIFLOW2:

nxp_eas_alarm.png

UHFRFIDUnit.get_nxp_config_word(password: str = '00000000') int

Get NXP config word.

Parameters:

password (str) – access password. hexadecimal string.

Return int:

NXP config word.

UIFLOW2:

get_nxp_config_word.png

UHFRFIDUnit.set_nxp_config_word(config_word: int, password: str = '00000000') bool

Set NXP config word.

Parameters:
  • config_word (int) – NXP config word.

  • password (str) – access password. hexadecimal string.

Return bool:

True if success, False if failed.

UIFLOW2:

set_nxp_config_word.png

UHFRFIDUnit.nxp_read_protect(set: int, password: str = '00000000') bool

Set NXP read protect.

Parameters:
  • set (int) – set read protect. 0x00 is set read protect, 0x01 is reset read protect.

  • password (str) – access password. hexadecimal string.

Return bool:

True if success, False if failed.

UIFLOW2:

nxp_read_protect.png

nxp_read_protect1.png

UHFRFIDUnit.nxp_change_eas(set: int, password: str = '00000000') bool

Change NXP EAS.

Parameters:
  • set (int) – set EAS. 0x00 is set EAS, 0x01 is reset EAS.

  • password (str) – access password. hexadecimal string.

Return bool:

True if success, False if failed.

UIFLOW2:

nxp_change_eas.png

nxp_change_eas1.png