Hi there, @A308011, and welcome to the forum. Glad to have you here.
May I ask what kind of computer and programming language that you’re using?
The simplest way is with python. If you the file path of the object into the tag, then in your code you can use the os library to write a command to open a file:
import os
def openingFile():
rfidTag = myRFIDProgram()
# Uncomment out for your system.
#os.system(f'xdg-open {rfidTag}') #For Linux
#os.system(f'start {rfidTag}') #For Windows
Some things to consider:
The method above is fast but unsafe as it will open any tag that it reads. You can make it more safer by using a function to check that the tag is formatted correctly for a file path so that you’re not opening random URLs someone hands you.
File Paths can be a nightmare. The program will crash if things are not where they should be and you could theoretically reveal the file structure of your PC if a hacker started testing this (although if this is a home system, the bigger concern would be that a stranger is in your house :P). The best way to get around this is by having your files in a known folder, with the filepath being a known variable. That way your tags can have less on them, it’s more secure, and your program can just combine the rfid path with the directory path on the fly like so:
However, I don’t think the Pico can simply send os.system commands to the host PC?
I apologise if I was unclear, I assumed the Piicodev RFID module is something exclusive to being used with a Raspberry Pi Pico (or similar compatible controller), which I understand can be used to communicate with a PC over USB.
I’m finding a handful of posts elsewhere on the topic, but as a novice a lot of it seems to either be not quite what I’m after or impenetrable!
If you want to send commands to a PC then there are a few options each with pros/cons.
Option 1.
Use HID OmniKey reader. this can be setup to read from many types of RFID tags (need to check if ntag is one) and output what it read as it it was a keyboard. So if left at a cmd/terminal prompt would out put command.
Pro - Works well with many card types. No coding needed just setup.
Con - Expensive compared to other options.
Build an I2C to UART, then write code for the OS e.g. windows, to send the I2C commands to get the tag ID and run the system command.
Pro can work at a system level on the PC, no controller need.
Con need to know the target machine in advance.
Use a controller that can be setup as an HID Keyboard. Read the RFID tag with the controller and inject the read data into the PC like a keyboard.
Like the first option, but cheaper and limited to what the reader can do.
Also, like Jane said. you need some sort of security layer around this to protect things.
You can custom encrypted the data on the tag, so only you know the keys. This if you cant decrypt it correctly then dont try to run. Note: Add some fixed data so you know if it decrpeted OK. e.g. Len, Command data (len long),MYID
Where MYID is at the end to better hide it.
You can use the security on the tag, to set the keys that allow you to read the data.
Or a very simple way would be to just use the tag UID and pair that to a list of commands in code.
Oops, sorry, I assumed you were doing this on a Pi. PiicoDevs are usually done with the Pico, but there are adaptors for working with the Pi range.
If using a Pico, Michael as some great suggestions.
Otherwise, to keep it in Python, you could use the Belay Library, which allows Python on a PC to treat a USB-Connected device as an I2C slave. It would allow you to interface with the RFID Tag Reader..
Thanks again for the replies, however I’ve found a post which was simple to adapt the code for to fit my needs in conjunction with a simple continuously reading PySerial server as found here.
Re: security, I can just retrieve the tag ID to the host PC and do what needs to be done based purely on that, don’t even need anything written to the tags. This will be for home use so duplication is not an issue.