March 29th, 2022
Integrating near field communication (NFC) tags into a smart home is a fun project that can add real convenience to homeowners and their families. To make my case, consider these potential applications:
NFC tags are small devices that consist of a microchip and an antenna enclosed in a substrate. A typical NFC tag, which could be used in a smart home, is just a thin, plastic disk, about the diameter of a quarter. Only about 1/32-inch thick it has adhesive on one side so it can be attached to almost any surface.
An NFC tag doesn’t require batteries or a connection to a power supply. When an NFC reader is placed next to the NFC tag, an alternating magnetic field generated by the reader induces a current in the NFC tag’s antenna. That current provides enough electricity to power the device. The reader and the NFC tag can then communicate with each other.
Each NFC tag contains a unique identifier that will be transmitted to the reader. A reader, such as a smart phone, can then take actions based on the identifier it receives.
NFC tags are inexpensive and are readily available on Amazon, eBay, and other shopping sites. For this article I purchased a package of 30 NFC tags for $11.99 + tax with Prime shipping on Amazon.
Most newer iPhones (iPhone 7 and newer running at least iOS 11) are NFC enabled and can be used to read NFC tags. The same is true for newer Android phones. I am an iPhone user and don’t have an Android phone to test with, so this article will focus on how to use the Shortcuts app on the iPhone to integrate NFC tags into a smart home. It is my understanding, however, that the Android Tasker app can be also used to accomplish the same thing. There is an article on the Android Authority web site that describes the process.
The process on an iPhone is as follows:
At this point you are ready to create the linkage between the act of scanning your NFC tag and your smart home. I’m going to provide information on integrating NFC tags with a Crestron smart home processor, IFTTT, and a Hubitat Elevation hub.
I’ve written a module for a 3-Series or 4-Series Crestron processor that allows http messages sent from a smart phone when an NFC tag is scanned to trigger logic running on the Crestron processor. To create the linkage to the Crestron driver I wrote:
http://[ProcessorIPAddress]:[ProcessorPort]/?tag=[NameForTagAction]&secret=[SecretKey]
Where:
Processor IP – The IP address of your Crestron processor on your home’s network
Processor Port – The port you are using for communications. This must match the entry you make as a parameter in the Crestron module
Name for Tag Action – As written, the Crestron module supports up to ten NFC tags (it is easily expandable to support more by editing the Simpl+ portion of the module). This field must exactly match (case sensitive) one of the Tag_ID parameter fields in the Crestron module. When an http message is sent by the smart phone to the Crestron processor, the Tag_Scanned digital output associated with the matching Tag_ID field will be pulsed and can be used to trigger smart home actions on the Crestron system.
Secret Key – This field is added for security purposes to help assure that someone sending random http messages cannot trigger actions on the Crestron system. It can contain any standard alpha-numeric characters and must exactly match (case sensitive) the Secret parameter field on the Crestron processor. Any http messages, where this field doesn’t match the Secret parameter field, are ignored by the Crestron system.
For example, the URL to open a garage door controlled by a Crestron processor might look like this:
http://192.168.1.10:9000/?tag=open_garage&secret=12345
This all assumes that your smart phone will automatically connect to your home’s Wi-Fi network when you are inside, or around, your home. I didn’t intend for the system to be used away from home where a port forward on the home’s router would be required for the message to reach the smart home processor/hub.
Port forwards on a residential router have become a major security issue. Hackers doing port scans on random IP addresses can easily stumble upon your home and attempt to break into your home network through an open port.
Once the module has been added to your Crestron program you can test it by simply scanning the NFC tag with your smart phone.
The Crestron module can be downloaded from my GitHub here.
The process for using IFTTT is very similar to the steps I’ve outlined above except the URL you enter needs to correspond with an URL that will initiate an IFTTT applet that is triggered by a Webhook. And, since IFTTT is a cloud-based service, NFC tags can be used to trigger actions in your smart home without the necessity of your phone being connected to your home’s network. The URL to trigger IFTTT will look something like this:
https://maker.ifttt.com/trigger/open_garage/with/key/xLDzNMtSYfBnQmVqVLxqK
More information on IFTTT Webhooks can be found here.
Again, the process for integrating NFC tags with a Hubitat Elevation hub matches the process described above, but simply requires a different URL. The URL to communicate with a Hubitat hub needs to work with the Hubitat’s Maker API app. The documentation for the Maker API app can be found here. It will provide information on how to communicate with the Hubitat hub using the Maker API including the fields in URL that is described below.
Like a Crestron processor, a Hubitat Elevation Hub sits on your home network, and all smart home processing takes place on the hub. So, even if there is an internet outage, your smart home continues to function. Unlike a Crestron processor, however, Hubitat’s Maker API app can receive messages either locally or, optionally, through the cloud.
The URL to communicate directly with the Maker API app on the Hubitat hub is formatted as follows:
http://[HubIPAddress]/apps/api/[MakerAppID]/devices/[DeviceID]/[Command]?access_token=[OAUTHAccessToken]
Alternatively, the URL to communicate with the Maker API app through the cloud is formatted as follows:
https://cloud.hubitat.com/api/[MakerAppID]/devices/[DeviceID]/[Command]?access_token=[OAUTHAccessToken]
Where:
HubIPAddress – The IP address of the Hubitat Elevation hub on your home’s network
MakerAppID – The application ID of the Maker API app.
DeviceID – The device ID of the device you want to control.
Command – The command sent to operate the specific device you want to control. For example, an “on” command to turn on a smart switch connected to the Hubitat
OAUTHAccessToken – The OAUTH access token for your Hubitat hub. This token uniquely identifies your hub from all the other Hubitat hubs in use around the world.
For example, the URL to turn on a switch controlled by a Hubitat hub might look like this:
http://192.168.1.10/apps/api/38/devices/112/on?access_token=xLDzNMtSYfBnQmVq
Or
https://cloud.hubitat.com/api/38/devices/112/on?access_token=xLDzNMtSYfBnQmVq
Because even basic NFC tags are waterproof, they can be used outside. Keep in mind, though, that the glue used on tags may not stand up well to the heat produced by direct summer sunlight. With that in mind you can use NFC tags to:
NFC tags are one of the least expensive additions you can make to a smart home. Using the iPhone Shortcut app, or the Android Tasker app, they can easily be integrated with a wide range of smart home platforms. And, the functions they can perform are only limited by your imagination.
More from Jay Basen: Smart Living with the Withings Body Cardio Smart Scale
Jay Basen
Jay Basen has been a home automation hobbyist for over 30 years and has worked professionally in the industry for almost 20 years. His professional background is electrical engineering and software development. He has a master’s degree in engineering and has been writing software professionally for over 40 years. To read more of Jay’s articles, visit his blog http://topicsinhomeautomation.blogspot.com/
1750 Wewatta Street, #1821
Denver, CO 80202 | 720.476.4920