Build

Acting On Tessel RFID Events with Tessel RFID Module

3 min read Michael Carroll on May 21, 2015
Try PubNub Today

Free up to 1MM monthly messages. No credit card required.

Subscribe to our newsletter

By submitting this form, you are agreeing to our Terms and Conditions and Privacy Policy.

How to receive a Tessel RFID event and act on it, triggering an action in real time. We'll receive and interpret RFID events, and match it against code.

We left off in the first part of our series by successfully detecting a Tessel RFID scan and sending RFID events in real time. Now, let’s do something with that RFID event. Let’s act on the event and trigger an action.

This entry goes into the detail required for receiving and interpreting those Tessel RFID events. Every time a message is sent with an RFID you would need to interpret the message, extract the data, and match it against known RFID codes.

read_UID-1

In the case shown in the example we need to have a list of valid RFIDs, which includes the 026e9a03. Your RFID code will be something completely different, so please take note of that code and use it instead. The first step will be getting the Tessel set up.

Follow the instructions from our previous blog post and run the code!

ready_read-1

This puts the Tessel in a state where it is ready to read the RFID card. Now everytime we touch the RFID card to the module, it will read the UID and publish the UID to the tesseldemo channel. The question is how we use this information with a purpose.

The Code

You will use the source code from projects/streaming-camera/camera-ui.html. If you don’t already have the repository, clone the repository.

Navigate to the projects/streaming-camera folder. Next you need to open camera-ui.html with your preferred text editor. You need to keep much of the streaming-camera project code. First we will make some simple modifications to the HTML itself. Remove the img line as well as the lines regarding the timestamp. You also need to modify uuid and change every occurence to uid instead.

This leaves you with html, which will display all detected card uid’s. Now you need to change the AngularJS code. Once again just change uuid to uid for every occurrence.

After refreshing the web page, the html should show you every unique uid number that has been sent to the channel.

ui-detect

This is cool. You can see everyone who has tried to access your secret Tessel vault. Now you need to add some code to allow or deny access based on the uid. You also want to add a string based on authorization. This is where you will edit the message event in the angular code. First you need to create a string, which contains the valid authorization code.

Next you need to check based on the string.

This code looks through each of the devices objects and matches them against the string. If the code matches, the device gets a green color and is authorized. If it is not authorized, it gets a red color and is not authorized.

Now switch back to the html to add the visuals.

Acting On Tessel RFID Events with Tessel RFID Module

The code could be further modified to contain an array of objects. Those objects could contain the owner’s name or other information pertinent to the service being provided.

That’s it! We hoped you enjoyed our two-parter on building a real-time RFID app with Tessel and PubNub.

More from PubNub

NPP and HIPAA: Notice of Privacy Practices Definition
Healthcare CategoryJan 6, 20235 min read

NPP and HIPAA: Notice of Privacy Practices Definition

A Notice of Privacy Practices (NPP) is one of the requirements of HIPAA and helps patients understand their personal data rights.

Michael Carroll

Michael Carroll

HIPAA Violation Examples
Healthcare CategoryJan 5, 20236 min read

HIPAA Violation Examples

HIPAA violations can be financially expensive and devastating to a brand. Examine some examples of HIPAA violations, and learn...

Michael Carroll

Michael Carroll

HIPAA Technical Safeguards: How To Protect Sensitive Data
Healthcare CategoryJan 5, 20236 min read

HIPAA Technical Safeguards: How To Protect Sensitive Data

HIPAA covered entities must follow the five technical safeguards to achieve HIPAA compliance and prevent data corruption.

Michael Carroll

Michael Carroll