Posted on 1 Comment

Why IoT Central?

My first experience with IoT Central

Microsoft has multiple tools and services designed for IoT.

After Ignite this year it’s clear that Microsoft has dedicated a sizable investment of time and people to expanding its IoT reach. I’ve worked quite a bit with IoT Hub, Event Hub, and Azure Functions to capture telemetry data, so when I first heard about IoT Central I thought, why would I want to play with a toy version of all the bigger tools when there’s already so much on offer in Azure?

Well, I was wrong. IoT Central is far from a toy. It’s an amazing platform perfectly designed as an entry into IoT application development. I had an opportunity to work with IoT Central for our Catapult Modern Data Culture Summit and I came away with insights that I hope will show you the potential of this powerful platform.

It’s clear that no-code and low-code solutions are rising in popularity. The Microsoft Power Platform has risen to the status of the fourth cloud platform for Microsoft along with Azure, 365, and Dynamics. IoT Central is to IoT development as Power Platform is to application development. IoT Central features the same type of ease to entry and offers many of the same UI goodies developers come to expect from the Power Platform.

I’ll dive into the various pieces of IoT Central and discuss my experiences. My goal was to develop an adequate demonstration aimed at the small to midsize business interested in applying IoT to their operations. I wanted to focus on smaller organizations because I believe there’s a misconception that IoT is really only for large companies with huge budgets and a small army of IoT and data specialists. That’s not to say that IoT Central doesn’t require some technical knowledge, but the barrier to entry and the operational overhead is much smaller. If I could prove to small and midsize organization leaders that IoT Central could give them the same type of insights and observability that larger organizations achieve, but on a much smaller budget, I saw that as a great way to bring more IoT work to Catapult. It’s my opinion that almost any organization can use IoT and AI to strengthen operations, gain insights, and continuously implement total quality improvement. Could IoT Central help me prove this?

What is IoT Central?

Microsoft describes IoT Central as, “IoT Central is an IoT application platform that reduces the burden and cost of developing, managing, and maintaining enterprise-grade IoT solutions.” Unlike Microsoft’s other IoT tools, IoT Central is a web application. You log in through your IoT Central portal and create apps. These apps represent IoT solutions. By solutions, I mean a single app provides everything you need to achieve a robust IoT implementation. From the devices to the backend data, you can use a single IoT Central app to provide enterprise level products to market.

Users & Roles

IoT Central’s user management is built around a few specific roles. The documentation refers to these as personas. When planning out your implementation it’s helpful to keep in mind the type of people you’ll need to help you perform the various tasks required by IoT Central to be truly operational. You won’t need an army of specialists, but you will need a team of individuals willing to fulfill certain responsibilities.

The solution builder is primarily responsible for creating the app, configuring the rules and actions, setting up integrations with other services, and customizing the application for the rest of the various users.

The operator is your device manager. This person manages the devices attached to the application.

The administrator is responsible for adding users and assigning roles and permissions.

The device developer is responsible for writing the code that runs on the device or IoT Edge module connected to your app.

As a solution builder I found I could do everything I needed to build, deploy, and manage my IoT Central app. I could see this as a lone wolf development position at a very small company. In fact, if you’re considering an IoT solo-entrepreneur effort, IoT Central is probably a great platform to start with.

Creating the App

To get started, you need to log into the IoT Central portal. In the latest version I’m working in you are greeted with a landing page describing the service. There’s also a menu with three basic items:

  • Home
  • Build
  • My apps

Use build if you want to start an app. One thing I found most interesting were the number of templates. You can select certain solution templates based on the industries of Retail, Energy, Government, and Healthcare. Each of these presents patterns fitting for common IoT solutions. You also have the option of creating a custom app, which is where I started.

I had an idea to use a bakery vending machine as my example. My fictional company has four bakery vending machines scattered around Texas. One in Houston, Dallas, Austin, and Fort Worth. The idea was to use IoT Central is a management platform for my various vending machines. I wanted to see the following basic data:

  • Number of sales during the telemetry time period (every 15 minutes)
  • High and low temperature of the machine
  • If the machine had been serviced that day
  • Where the machine was located

One thing this demo taught me is that it’s a lot of work to prepare for a fascinating IoT demonstration. I not only needed to create simulation data and IoT device simulators for this demo, but I also needed to plan out business operations. They were actually much more complex than what I went with. I had intended to add trucks, schedule stops by fictional employees to refill the vending machines, oh lots of different things were in the works. However, time got the best of me and I had to settle for generating data for the machines and pretending some additional elements were in place.

One day in the near future I’ll spend more time creating a fictional IoT business, but what I created served my needs well enough for the demo.

Creating Devices

Unlike IoT Hub where you add a device and then assign that device ID to an actual physical device, IoT Central gives you a number of options that start at the device template creation stage. From here you can:

  • Design the device template in IoT Central and then implement its device model in the device code.
  • Create a device model using VS Code and publish the model to a repository. Implement your device code from the model and connect your device to your IoT Central app. IoT central will find the device model from the repository and create a single device template for you.
  • Create a device model using VS Code. Implement the device code from the model. Manually import the device model into your IoT Central app and then add any cloud properties, customizations, and dashboard your IoT Central app needs.

I went with the first option and created a template manually in the portal. The second choice looks like the better way to do it, and I might try that in the future. I did create a number of customizations. For instance, I ended up adding the latitude and longitude values as cloud parameters so that I could see those on a device dashboard.

Simulating the devices

I had initially wanted to use my MXChip as a device, but setting that up became non-trivial. I was just learning about the system and didn’t really have a firm understanding of how to do it. And once I started, I thought it would be a better demonstration if I had more than one device. Here’s what my code looked like:

from dotenv import load_dotenv
import sys, asyncio, os, json, time
from iotc import (
    IOTCConnectType,
    IOTCLogLevel,
    IOTCEvents,
    Command,
    CredentialsCache,
    Storage,
)
from iotc.aio import IoTCClient
from random import randint, uniform

load_dotenv()

def getPurchaseAmount():
    return randint(1,5)

def getTemperature():
    return round(uniform(8.88, 16.66))

# Load the device connection values
DEVICE_ID_AUSTIN = os.environ.get("DEVICE_ID_AUSTIN")
ID_SCOPE_AUSTIN = os.environ.get("ID_SCOPE_AUSTIN")
PRIMARY_KEY_AUSTIN = os.environ.get("PRIMARY_KEY_AUSTIN")


austin_client = IoTCClient(
    DEVICE_ID_AUSTIN,
    ID_SCOPE_AUSTIN,
    IOTCConnectType.IOTC_CONNECT_DEVICE_KEY,
    PRIMARY_KEY_AUSTIN,
    None,
    None
)
        
async def sendAustinTelemetry():
    await austin_client.connect()
    while austin_client.is_connected():
        print("client connected {}".format(austin_client._device_client.connected))
        await austin_client.send_telemetry(
            {
                "CakeInventoryFilled": 0,
                "CakeInventoryPurchased": getPurchaseAmount(),
                "FridgeTemperature": getTemperature(),
                "LocationLatitude": 30.26715,
                "LocationLongitude": -95.36327
            }
        )
        await asyncio.sleep(900)

async def main():
    await sendAustinTelemetry()

asyncio.run(main())

I used the IoTC library to make this easy. And it was. Creating the code for an IoT Central app for basic telemetry is trivial. However, I didn’t dive into cloud-to-device messaging. It would have been nice to have the ability to send a message to the machine to tell it to reset its internal inventory counter. I have more learning to do around integrating the operations side of IoT Central with a more sophisticated IoT Device. But I can definitely see the potential here.

Customization, Dashboards, Rules, and Telemetry Data

IoT Central includes a lot of tools you would need to develop yourself if you went with the traditional Azure IoT suite. You might still want to build these tools, but there was enough in IoT Central that I think you could cover the majority of your operations needs from the portal.

I explored a number of different dashboard options from device specific dashboards to sales and inventory dashboards. I was able to drag and drop tiles to represent specific telemetry or cloud parameters. If you are familiar with Power BI tiles or Azure portal tiles, you’ll recognize these UI elements. Understanding how they work is fairly intuitive. There’s not a lot of flexibility here, but if you need more than the standard set of time, you can always route data to Power BI.

You can track telemetry and add rules around the inbound data. I practiced by setting alerts based on high or low temperatures. This worked ok, but it’s by no means the sort of thing I would need to predictive analytics or something more sophisticated. If you want something more than visuals built around incoming data or custom parameters, you’ll want to integrate IoT Central with other services.

And that’s probably some of the best news. Integrating with other services is relatively easy. I connected my app to Event Hubs and captured data to send to a Stream Analytics Job. This allowed me to build a Power BI dashboard. But with a Stream Analytics Job I would perform much more elaborate rules and queries on the incoming data. You could also use the IoT Central API to build mobile apps, custom integration with lines of business like an inventory system or a telematics solution, or perform more sophisticated device management. However, I want to be clear that you don’t necessarily need to do these things. For my fictional scenario, there was really no need to create any sort of integration. I could have managed my vending machines and the surrounding services from IoT Central alone.

What about IoT Edge and AI?

I chose to stick with simple devices for my demonstration, but IoT Central definitely supports IoT Edge deployment. IoT Central treats these devices as Edge Gateways and as IoT Edge devices. IoT Central models an IoT Edge device as follows:

  • Every IoT Edge device template has a capability model
  • For each custom module in the deployment manifest, a module capability model is generated
  • A relationship is established between each module capability model and device model
  • A module capability model implements one or more module interfaces
  • Each module interface contains telemetry, properties, and commands

I like this approach to creating a device shadow that represents the IoT Edge device. It’s a good reason to implement IoT Edge devices on IoT Central.

Closing thoughts

When I first learned of IoT Central I didn’t get it. Why create a suite of Azure IoT services, and then turn around and create a little version of all these things crammed into a web app? Well, I get it now. IoT Central is far from a toy and doesn’t diminish any of the other IoT tools and services that Microsoft has to offer. If anything, It adds to that collection. I plan to explore more applications in IoT Central in the future. I’m considering it for my backyard garden’s automated irrigation system, because with so few devices and so little data, it basically cots me nothing.