Implementing NFC scanner

Currently NFC scanning is not possible using the Perspective app, there has been a ticket since 2020 and no timetable for this feature.
I have succesfully created a work around for android devices

Requirement:

NFC Tools: App is used for actively scanning NFC/RFID tags
NFC Tasks: App is used for executing tasks stored on the NFC/RFID tag
NFC Tools - Pro Edition: App needs to be purchased for creating HTTP REST tasks, only required on a single device and not all readers

The Tag required for my case is limited to 106 writeable bytes so i have to use some variables:

Define a HTTP Post task:

  • {VAR_INP} hold the API endpoint
  • {TAGID} holds the ID of the tag as "98:38:4e:94:50:01:04:e0"
  • {VAR_U} Hold the username of the device, the IMEI/SIM returns "UNKNONW" and since only 106 bytes are available i have to use a variable.
  • Optionally the result can be stored in a variable for debugging

Variables are stored in the app NFC Tasks and could be altered by the user,

def doPost(request, session):
	# NFC Tools HTTP POST
	# ContentType "application/x-www-form-urlencoded"
	# First key in the 'request["params"]" is the actual json value	
	# Looks like a bug but it works
	json = system.util.jsonDecode(str(request["params"].keys()[0]))
	
	if 'tag' in json:
		system.tag.writeBlocking(["[default]NfcTag"], [json['tag']])
	if 'user' in json:
		system.tag.writeBlocking(["[default]NfcUser"], [json['user']])
	
	return {
		'json': 'ok'
	}

After a succesfull scan the values are written in two Tags and can be used within Perspective.

2024-10-07_08-59-48

Note: some tags IDS are limited by their byte size and duplicates are already on the market.

3 Likes

What am I missing here? It's been possible for a quite a while, with a video on IU showing how to do it.

Take a look at this old post, the current problem i guess is that not many protocols are implemented in the app and ISO 14443 which is commonly used is not implemented.

I have tested with a few NFC tags and the perspective app could not detect them while other apps could.

It could be I couldn't read the tag because there was no data on it (only needed the ID), will test tomorrow and will let you know.

I have a lot of experience in Ignition Vision, but I have not done a "real" project in Perspective yet so take my advice with a grain of salt. Also I got my first batch of NFC tags off of Amazon today, so this is the first time I've tried to work with one.

To start, I got "the "NFC Tools" app out of the Google Play store and I used that to start writing, and then reading data from the NFC tags I bought. If you can get that far on your phone or tablet, you will at least be able to eliminate the question of whether your issue is caused by no data on the tag.

My thinking is, that no matter what else, if I can any data off the tag, I can use scripting to accomplish whatever else I need.

After wrting some data to the NFC tag "ABCDEF" i was actually able to read the tag using the session events.
edit: Empty tag now works now and dont know why. Gateway is 8.1.47.

tag value
[{
	u'string': u'\x02enABCDEF', 
	u'type': u'VA==', 
	u'typeNameFormat': 1L, 
	u'payload': u'AmVuQUJDREVG', 
	u'bytes': array('b', [2, 101, 110, 65, 66, 67, 68, 69, 70]),
	u'id': u''
}]

Log
Type:VA==, Type Name Format:1, Payload:AmVuQUJDREVG, String:enABCDEF, Bytes:array('b', [2, 101, 110, 65, 66, 67, 68, 69, 70])

used session event: Perspective Session Event Scripts | Ignition User Manual

The actual value needs to skip the first 3 bytes, dont know why.
The id (which i need) is missing since i dont want to manually write unique value to each individual tag (450)

Hopefully this helps you out.

Yes! I ran into that same 3-bytes issue when I just wrote a text value to a tag. But I noticed that when I made the tag perform a more complex action (on Android remember) of "Copy To Clipboard" and the value I want, I get exactly the value I wrote.

I get where you're coming from not wanting to write to 450 different tags. I'm going to solve that problem by getting someone else to do it :laughing:.

1 Like