RFID and key management

RFID and key management

In the past, we've been asked several times whether it was possible to build a key management system based on Yoctopuce modules. Of course, we're talking about keys for opening locks, not cryptographic keys. We did propose a modest project a few years ago, but with the arrival of Yocto-RFID-15693, we can think bigger.

So we're trying to build a kind of board capable of managing a set of keys, i.e. listing the keys hanging on the board and indicating at all times which keys are missing and when they were borrowed.

We'd like to improve the concept a little
We'd like to improve the concept a little

The basic idea, of course, is to equip each key with an RFID tag and take advantage of the ability of the Yocto-RFID-15693 to identify several RFID tags at the same time. On the face of it, the topic is trivial, and not necessarily worthy of a post, but there are a few subtleties that need to be taken into account when implementing it.

Where to put the tags?

You can't stick tags directly onto keys: the metal of the latter prevents them from working. We've looked for ISO 15693 tag-based key-holders, but haven't found much. On the other hand, there's nothing to stop us sticking RFID tags onto conventional key rings.

Which tag size?

The size of the tags is very important. Remember that the tags are powered by the energy radiated by the antenna, so a compromise has to be found between the size of the antenna and the size of the tags. As the transmitting power of the Yocto-RFID-15693 is set, the larger the antenna, the less "dense" the radiating energy. The larger the tag, the easier it is to capture the energy required for its operation. On the other hand, the larger the tag, the fewer tags can be physically present in front of the antenna at the same time.

For example, we tried using small 30x15mm ICODE SLIX 2 tags, which had the advantage of fitting into those cheap little key rings you find everywhere. Unfortunately, they weren't detected by the Yocto-RFID-15693 equipped with the large antenna we'd planned to use. They probably can't harvest enough energy to work properly.

These tags are too small for a large antenna system, too bad.
These tags are too small for a large antenna system, too bad.

We've settled on 38x25mm ICODE SLIX self-adhesive tags, which can easily be stuck into transparent key-holders purchased from a local online store.

these tags work and we found key rings just the right size
these tags work and we found key rings just the right size


In terms of hardware, we used nothing out of the ordinary:

The electronic part, note that the panel is powered by PoE
The electronic part, note that the panel is powered by PoE

We've managed to fit 14 key rings on our board, which more or less corresponds to the maximum number of tags that the Yocto-RFID-15693 can "see" at the same time.

With some squeezing, we can manage 14 key rings
With some squeezing, we can manage 14 key rings

Out of curiosity, we checked if our system could also work with the panel set horizontally and the keys loose on top of it. And it works... less well. If several tags are superimposed, those furthest from the antenna have trouble being detected.

How does it work?

The Python script that drives the panel runs on a remote computer and tracks tag arrivals and departures. It automatically builds up a key inventory as each new key arrives, and reads the description of each key. Each time a change is made, the system configuration is saved in a file, enabling the application to be stopped and restarted without losing the complete key list. If you're interested in the complete code, you can find it here.

About key descriptions

The description of each key is stored in each tag in the form of a character string. Depending on the programming language used, storing and reading back a string of characters is a little complicated, because the rfidreader→tagWriteStr() and rfidreader.tagReadStr() functions only store and read back a sequence of characters without implicitly managing the length of the string.

One solution is to end the stored string with a special character, typically zero, as illustrated in the Python example below.

def writeStringToRfidTag(reader, rfidUID, block, str, maxlen,status ):
  if len(str)>=maxlen :
    str = str[:maxlen]
  options = YRfidOptions() # default option
  return reader.tagWriteStr(rfidUID,block,str,options,status) == YAPI.SUCCESS

def readStringFromRfidTag(reader, rfidUID, block, maxlen,status):
  options = YRfidOptions() # default option
  str = reader.tagReadStr(rfidUID, block, maxlen, options, status)
  if (status.get_errorCode() != YAPI.SUCCESS): return ""
  n = str.find('\x00')
  if n >= 0: str = str[0:n]
  return str

Does it work?

It's not too bad, key rings are detected without difficulty, and the presence of metal keys doesn't seem to be a big issue, even when they end up between the antenna and the tag. However, from time to time, the system sees a key disappear, only to reappear immediately. We've made a short video to show you.



Obviously, even if this system is a clear improvement over a dumb passive key rack, there are still quite a few limitations.

  • It's not possible to know the position of a specific key on the panel, so you always have to stick human-readable tags on the key holders.
  • When there are a lot of tags on the board, every now and then a key may briefly disappear from the inventory, probably due to radio interference between tags. This little glitch can easily be masked by programming.
  • While you know when a key has been borrowed, you can't tell who borrowed it.


This DIY project is a simple proof-of-concept, but it shows that it's possible to use the Yocto-RFID-15693 to manage a limited inventory of small objects in real time. The small size of the management code, less than 200 lines in all, proves just how simple and easy to use the Yoctopuce API for the Yocto-RFID-15693 reader is.

Add a comment No comment yet Back to blog

Yoctopuce, get your stuff connected.