NFC Tags – An Inexpensive Smart Home Automation Application

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:

  • Use your smart phone as a key to unlock the door to your home by simply tapping your phone against the door
  • Use your smart phone to open your garage overhead door by simply tapping the phone against the wood that frames the garage door
  • Use your smart phone to control outdoor lighting by simply tapping the phone against the arm of your favorite outdoor chair

What are NFC Tags?

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.

How to Use NFC Tags in a Smart Home

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:

  1. Open the Shortcut app
  2. Select “Automation” from the menu bar on the bottom of the screen
  3. Press the “+” button in the upper righthand corner of the screen
  4. Press the button labeled “Create Personal Automation”
  5. Scroll down and select “NFC Ex. “When I tap an NFC Tag”
  6. Select “NFC Tag Scan”
  7. Scan your NFC tag by holding the phone next to it
  8. Enter a name for your NFC tag
  9. Press the “Next” button in the upper righthand corner of the screen

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.

Crestron

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:

  1. Press the “Add Action” button in the Shortcut app
  2. From the categories of actions choose “Web”
  3. Scroll down and from the list of items under the category “Web Requests” choose “Get Contents of URL”
  4. Enter an URL in the following format:

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.

  1. When you’ve entered the URL press “Next” in the upper righthand corner of the screen
  2. Turn off the setting “Ask Before Running” and press “Done” in the upper righthand corner of the screen

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.

IFTTT

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.

Hubitat

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

Where to Use NFC Tags

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:

  1. Unlock doors that are outfitted with smart locks that don’t include their own support for using your smart phone as a key.
  2. Opening, or closing, a garage overhead door that is integrated with your smart home platform. An NFC tag is much more inconspicuous than the outdoor keypads that are sold with garage doors
  3. Disarm your alarm system using your smart phone before entering your home. For example, place an NFC tag in your car. Place your phone next to the tag after you have pulled into your garage to disarm the alarm system. Now you can enter your house carrying bags of groceries without worrying about having to type a code into a keypad to disarm the alarm system.
  4. You can toggle outside lighting on/off by placing an NFC tag in a convenient location on your porch or patio.
  5. Given the power of the iPhone Shortcut app and the Android Tasker app, there are actions outside the smart home that can be automated using an NFC tag. For example, a tag could be placed on the dashboard mount you use for your smart phone in your car. When the phone is placed in the mount it could trigger the phone to automatically open your mapping app so you can immediately enter the address you are traveling to.
  6. Using the free iPhone app NFC21 Tools, Wi-Fi credentials for your home’s guest network can be written to an NFC tag. This tag can be placed in a guest bedroom, and guests can use it to connect to your Wi-Fi network without going through the hassle of asking you for the SSID and password. This can also be done using an Android phone.

Summary

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

(Visited 1 times, 1 visits today)

Leave a Comment