Let’s Make Any Space ‘Smart’

Zach Griffin
6 min readMay 11, 2019

Smart Homes are all the rage today. With companies such as Nest, Ring, Phillips, TP-Link, Samsung, and others competing heavily to take control of your devices, it is important to have a system that can manage all different brands, across multiple wireless protocols, with full functionality and ease of use.

And why is everything about smart homes? With the right mix of administration, infrastructure, and planning, these solutions can be implemented into businesses such as retail stores or office parks.

This IoT Gateway Guide serves as a free tool to assist companies in utilizing the power of IoT Devices. Primarily, this will be used by small to medium sized businesses where three focus points are observed: Scalability, Ease of Management, and Integration with current devices. This guide can also be used to create a more advanced IoT management system in the home. This document will walk you through the necessary steps to configure this network of IoT smart devices.

Please note, the software here is open source through Mozilla, don’t proceed unless you are comfortable using an open source platform.

Pre-Requisites

· IoT Smart Devices

· Laptop with WiFi capability

· SSID or private network reserved for IoT devices

· Raspberry Pi

· 32GB MicroSD Card

· MicroSD to USB/SD Adapter

Software Installation

For this project, we will be using the open-source project from Mozilla known as Things Gateway. This software will provide an intuitive user interface as well as back end management for the devices and integration with smart assistants.

Raspberry Pi

For this guide, we will be using a Raspberry Pi as the central hub. The software used can be installed on any Linux distribution, but setup is easiest using a pi. For more information, visit Mozilla’s github page here.

Take the MicroSD card and flash the pre-built Mozilla Things OS image onto it. The OS can be found at iot.mozilla.org/gateway. For flashing, you can use software such as Etcher to write the bootable OS to the disk. When the flash is complete, insert the microSD card into the Raspberry Pi and plug in the power to boot it up.

Gateway Setup

Use the following steps to setup your gateway after first boot

· The pi will act as a WiFi hotspot temporarily. Connect your device to the ‘Mozilla IoT Gateway’ SSID from your computer.

· Navigate your web browser to gateway.local or if your environment doesn’t support it, you can enter the IP address of the pi.

· You will be prompted to connect the device to a WiFi network. Select the private IoT network you built before starting this guide.

· Connect to that private network from your PC and navigate to gateway.local again.

· Now you will be asked to specify a web address subdomain. This should be thought about for a moment as it cannot be changed later. Make sure the subdomain is memorable, related to your business or home, and has an incrementor such as ‘001’ to future proof the scheme going forward.

· Fill in the remaining fields and continue.

· Create your user account with Name, Email, and Password.

Add-Ons

The software has been installed and the basics have been configured. We now need to inform the gateway of what protocols to search for when adding devices. This is achieved using Add-Ons.

· From the home page, go to the main menu (hamburger icon in the top left)

· Select Settings, then Add-Ons

· On the bottom right of the screen, click the plus button to add new Add-Ons

All available Add-Ons are shown here. Depending on your current inventory of IoT smart devices, you will need to add different ones. For example, if you have a TPLink bulb and a Phillips Hue Bulb, you will need to add an add-on for each. To use the system with Apple’s HomeKit, you will need to add the HomeKit Add-On. Most importantly, for any device, add the ZWave and ZigBee Add-Ons. These are the standard IoT Protocols that most devices connect using.

When the Add-Ons have been completed, check the system for updates to make sure you have the latest version of all add-ons, adapters, and software.

Users

The main account should be used for administration purposes only. The main account is the one created in the setup process. To allow others access to the software, you will need to manually add each user in the “Add User” settings area. LDAP and other IdP integrations are not yet supported.

Optionally, create one additional user named kiosk with its own email address. The reasoning for this is explained in the next section.

Kiosk

A kiosk is an optional space with a touchscreen interface that will always be connected to the hub . This could be a touchscreen in the CEO office for quick access to devices or a replacement for a thermostat.

The touch device needs internet access over Ethernet or Wi-Fi and electricity. That’s it! Navigate the device to the domain we created in Gateway Setup and log in using the kiosk account we explained earlier.

Rules

Rules can be found under the main menu. These are user-friendly If else statements. We can create simple or complex rules with inputs such as time, device status, or from voice assistants. Outputs of these rules can vary in quantity but can set status of any of your connected devices. For example, we can create a rule that when the hallway light is turned on, the basement lights are turned on as well, creating a virtual electrical circuit between the two zones. This allows us to link groups of devices together and have corresponding rules that turn the lights off.

To create rules, follow these steps:

1. Go to Settings

2. Select Rules

3. Click “+”

4. Drag and Drop the input action (can be time of day)

5. Drag and Drop output(s) and set the device statuses

Protocol Adapters

The raspberry pi only has access to WiFi and can only connect to devices communicating using WiFi. This can be altered by utilizing the USB ports on the pi, we can install dongles to allow support of IoT protocols such as ZigBee and Z-Wave. Many smart devices such as lights, thermostats, dimmers, and more communicate over the Z-Wave protocol.

To accommodate these devices, we need to purchase a USB dongle adapter that communicates on the specific protocol. Aeotec, Sigma, and Digi XStick are a few options. Follow the below steps to install and configure IoT protocol adapters.

1. Power off the hub/gateway

2. Insert the USB Protocol Adapter

3. Power on the hub

4. Under adapters on the hub settings, add the protocol for the adapter you just installed

To install devices using this protocol, simply enter them into pairing mode (varies on device or manufacturer) and search for new devices on your hub

DNS

A great feature of the Mozilla setup is that we are given a DNS entry for our specific device from Mozilla. We can route to this address from a custom domain if we own one. For this example, we will use example.com as our domain. You can replace that domain name with the one you own. Follow these steps to create a custom DNS entry when your DNS provider is organized by subdomains. If your DNS provider is not organized by subdomains, create the entire entry instead of the zone first, such as office.iot.example.com. Only follow the second step when setting up the first device:

CNAME

1. Launch your DNS management platform

2. Create a subdomain (zone) that is something along the lines of iot.example.com

3. Within the subdomain, create a CNAME record of <device-location>, example: front-office.iot.example.com

4. For the record value, enter the Remote Access domain created on the gateway in the setup such as smartspaceHQ-001.mozilla-iot.org.

5. Save

Now, the address of front-office.iot.example.com will bring you to the device.

A-Record

The same steps can be taken if you do not want to rely on Mozilla and want to route directly to the IP. Our options here are to either assign an external IP to the device, utilize port 443, or make the device only accessible internally with no remote management.

· If the device is externally facing, simply add the external IP to a DNS A record

· If you use NAT, forward port 443 from your router to the IP of the gateway and create the DNS entry using the external IP of your router.

· If we make the device internally facing only, we will utilize internal DNS on your DNS server or router and point the entry from there.

--

--