I am experimenting with a project that uses NFC tags to trigger specific scripts on a Raspberry Pi like turning on lights, sending a webhook / launching a Python function. I have got the NFC reader working but I am looking for the most reliable way to map tag IDs to custom actions. Has anyone here tried something like this?
I am considering using a lightweight backend interface to configure tag actions more easily. If you’ve done any NFC-triggered automation / have a script setup you like; I would really appreciate hearing about your approach. Checked How to use a NFC Reader with Raspberry Pi - Tutorial Australia guide related to this .
Also; while discussing possible optimizations, someone asked me what is java, and I started wondering whether using Java might offer better performance for handling tag logic /background services.
Great to hear you’re working on NFC-triggered automation with the Raspberry Pi. Since your NFC reader is already working, the next step is organising how tag IDs map to actions. Here are some ideas that might point you in the right direction with your research or bouncing ideas off AI:
Simple Mapping
Use a Python script that reads the tag’s unique ID, then looks it up in a dictionary or a simple database (like SQLite). Each ID corresponds to a function or command you want to run. This is reliable and easy to update.
Configurable Setup
If you want to change mappings without editing code, store the tag-to-action mappings in a JSON or YAML file. Your script reads this file on startup or when triggered. This way, you or others can update actions by editing a simple text file.
Lightweight Web Interface
For more convenience, you can build a small web interface (for example, using Flask) to manage tag mappings. This makes it easier to add or change tags remotely.
Performance and Language Choice
Python is usually enough and simpler for Raspberry Pi automation tasks. Java can run in the background too, but it adds complexity and usually isn’t necessary unless you have a Java-based system already.
As for using Java, it can work well for background services, but it’s generally more complex to deploy and manage on a Raspberry Pi. Unless you have a specific need for Java, Python is usually easier for this kind of project.
Hopefully, someone else here might also have some examples or tips to share
I have plenty of ideas, and can go on for days… But after 3 drafts here, I feel Im just going to make it more complicated…
So, 2 questions.
What is the reader you think you will be using?
Do you need to support concurrent tags on the reader?
Do you have an security concerns?
At a very simply level and just using UID to actions, I would tend to store in an SQL data base such that you can then just “select scriptname from tags where uid = ‘12345678’;”