Introduction

In this article, I will discuss the challenges in setting up an IoT device for the very first time and suitable methods to address these challenges.

Many IoT devices are now being shipped to end consumers and these consumers are expected to setup the devices. For example, the product AirCare IoT is a Raspberry PI based air quality sensor that needs to be setup by a consumer for the first time.

Although AirCare IoT has a built-in ethernet port, we expect the unit to be installed in a garage or a balcony where an ethernet cable is not expected to be available. The only other option is to use the Wi-Fi network.  Also, no display monitor with keyboard can be  connected to the IoT to allow easy configuration. Consumers expect a device such as this be easily setup using an phone app.

Expected Procedure for Configuration

A consumer would expect the following logical steps to configure the device:

  1. If not done already, download the app from the app store.
  2. Turn on the power for the device.
  3. Launch the app in the phone, the device should auto recognized, perform an easy setup.

Challenges

Factory shipped IoT can’t connect to Wi-Fi network at home

In order for the above procedure to work, the IoT device should be connected to a Wi-Fi network is generally accessible from the app.  This is not possible, as the IoT shipped from the factory does not know your home Wi-Fi network name and the password! The first step in the setup should logically involve providing the home Wi-Fi network and the password.

The IoT can be shipped to host an hot-spot with a known name (SSID), for example, AirCare Config, and a known password. The user can be instructed to connect  their phone to this Wi-Fi network temporarily to complete the setup. The user after a successful setup can connect the phone to their regular home Wi-Fi network.

Once the network settings are available, the IoT can join the home Wi-Fi network.  The IoT can fall back to be an hot-spot if the credentials are invalid or has other connectivity issues.

Can’t find the IP address of the just setup IoT

Now we face a new challenge! Once the IoT connects to the home Wi-Fi network we need to know its IP address to connect to it from the app. This process would involve accessing the Wi-Fi router admin page and inferring the IP address. We can’t expect a consumer to perform this action!

Conversely, the IoT can’t connect to the app because it does not know the IP address of the phone or the phone IP address could have changed. Also, the incoming network connections to apps are also discouraged in practice. The app would have learnt the MAC address of the IoT and can do use RARP (Reverse Address Resolution Protocol)  to map MAC address to the IP address. This level of deep networking stack access is not available to the apps.

Furthermore, there is no central server like system at home that can share such information.

Solution: Use an publicly hosted custom registry that can map MAC address to the IP Address

In this solution, the IoT upon joining the home Wi-Fi network registers itself to a registry server using a well defined REST API as following:

POST http://aircare-registry.mapshalli.org/register

Parameters:

  • MAC address
  • IP address

Now, the android app can query to get the IP address as follows:

GET http://aircare-registry.mapshalli.org/register/<mac_address>

Returns:

Access credentials and other parameters have been omitted for brevity. The IP address of the IoT itself is not a publicly visible IP address but private address that is only valid in the local Wi-Fi network. The session mapping of public IP address to the private address is done automatically by the local router(s) using the NAT protocol.

The app needs to manage its own MAC address to IP address table and use TTL values to intelligently query to get the IP address.

Further Study

The challenges and solutions points to the glaring gap of lack of centralized IoT management at home.

Published by Shiv

Shiv is the founder of MapsHalli. He started MapsHalli committed to helping entrepreneurs, students, and citizens with technology, hands-on help, and advice. Connect with him: https://www.linkedin.com/in/shivshankar2020/

Leave a comment