NFC and RicaricaMi
From time to time, I’ve read of some clever setups that use NFC cards or QR code readers for automating something.
I can see the appeal of such a system, but any solution requires buying some cards and a dedicated reader. Since I do not feel the need for such a system, I never looked at how to implement one. Except that recently I had some NFC cards for which I had no better use.
RicaricaMI
Apparently since 2020, in Milan, disposable paper tickets have been replaced by NFC Tickets 🗄️.
What’s interesting is that those cards are not made of plastic but of paper, with a chip inside.
I’m not sure how they should be disposed of; I could not find any information. Contrary to "classic" paper tickets, they can be recharged and reused indefinitely, thus ideally one would never throw the ticket away; although I’m sure that in practice, a lot of tickets are still thrown away.
For example, for a tourist, it makes little sense to keep the Ticket forever, especially if one does not plan to return to Milan.
I got a little curious about those tickets, and since my phone has an NFC reader, I tried to read some data out of it.
Can I recharge those tickets for free?
I have no idea how the ticketing system works, but I can make some assumptions.
The simplest solution would be to use the card just as an identifier.
The machine reads the ID of the card and verifies remotely how many tickets are associated with the card.
This approach has the obvious disadvantage that it requires a connection, but it should not be an issue in practice.
Writing some data on the card has security implications. An attacker could overwrite, for example, the number of fares.
With the card being used as ID, in order to change the number of fares, one would need to change something on the remote machines of atm.it, which would be much more difficult than inspecting and trying to change a card.
One can try to "copy" other cards; depending on which security mechanisms are in place, it might be possible.
What is missing, for the end-user, is the possibility to verify how many fares are on the card. The information is not written on the card, and there is no section on the website where to insert the ID to ask for this information.
Practical uses (when not using it as a ticket)
Unfortunately, most computers do not have an NFC reader, and it is not possible to use an Android phone connected over USB as one.
While for my use cases using one or more cards makes little sense, some nice projects want to take advantage of physical media.
An example would be making a digital media library and using NFC cards to select and start a movie, a game, or play audio files.
This can be achieved quite easily on any GNU/Linux system, an NFC reader, and a shell script.
Here is a minimal example that, with the card I have, will start a specific homebrew NES 🗄️ with RetroArch 🗄️:
#!/bin/sh
set -x
set -u
echo "Waiting for NFC cards..."
while true; do
# Read one NFC tag and extract UID
# get result when card is removed
CARDID=$(nfc-poll | grep "UID" | awk '{ $1=$2=""; sub(/^ */, ""); print toupper($0) }')
echo "Card detected: $CARDID"
# Custom actions
case "$CARDID" in
"")
echo "empty cardid; try again";;
"04 95 4B 02 50 21 94")
# RicaricaMI
retroarch --libretro "$HOME/.config/retroarch/cores/mesen_libretro.so" "$HOME/games/my-game.nes";;
# add other cards here
*)
echo "Card not registered";;
esac
done The biggest downside of the presented script is that nfc-poll does not poll when the card reader is disconnected, but returns immediately.
If you want to use NFC cards for managing movies and are using Kodi, then replace the retroarch command with kodi-send
kodi-send --action="PlayMedia(/abolsute/path/to/video.mkv)"; If the command is not available, on a Debian-based system, it is part of the package kodi-eventclients-kodi-send. If installing another program is problematic, or if one wants to start the video on a different system, it is possible to enable remote control under HTTP. The option is located under , choose a port, username, and password.
To start a video, use the following command.
# replace
# * /absolute/path/to/video.mkv with the actual path to the video file
# * USERNAME with chosen username in the settings (kodi is the default one)
# * PASSWORD with chosen password in the settings (kodi is the default one)
# * PORT with chosen port in the settings (8080 is the default one)
# * localhost with the IP address of the remote computer, if the video is to be played on another computer
curl --proxy-user USERNAME:PASSWORD --silent --header "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"file":"/abolsute/path/to/video.mkv"}},"id":1}' http://localhost:PORT/jsonrpc Needless to say, I would prefer to use kodi-send over enabling remote control.
| Note 📝 | With kodi-send it is also possible to control remote Kodi instances. |
If one has an NFC card reader to attach to a PC, it can be an interesting way to reuse an old computer or phone.
In the case of smartphones, it will not be as easy as on a Linux system to kitbash something together.
Where to find cards
I did not realize it immediately, but I am surrounded by NFC cards.
For example, my library card is a "MIFARE DESFire EV1 4K" card, hotels might use cards for opening rooms (the last one I visited used a "MIFARE Ultralight 11" card), there are ski passes, login systems, and obviously contactless payment cards.
There are also toys for children; for example the Toniebox uses a SLIX-L chip 🗄️, based on ISO 15693, and the Amiibo figures 🗄️ (based again on ISO-14443 🗄️).
Other figures with NFC tags are Skylanders 🗄️, Lego Dimension 🗄️, and Disney Infinity 🗄️. There might be other games I am not aware of.
Note that the NFC reader might not support some cards.
For example, the NFC reader I’m using does not seem to support the Toniebox figures.
The command nfc-list -v should print the supported card types; in my case, the output looks like the following:
0 ISO14443A passive target(s) found.
0 Felica (212 kbps) passive target(s) found.
0 Felica (424 kbps) passive target(s) found.
0 ISO14443B passive target(s) found.
0 ISO14443B' passive target(s) found.
0 ISO14443B-2 ST SRx passive target(s) found.
0 ISO14443B-2 ASK CTx passive target(s) found.
0 ISO14443B iClass passive target(s) found.
0 ISO14443A-3 Jewel passive target(s) found.
0 ISO14443A-2 NFC Barcode passive target(s) found. In this case, since ISO15693 is missing, the reader cannot read SLIX-L cards.



If you have questions, comments, or found typos, the notes are not clear, or there are some errors; then just contact me.