Developing an IoT Hub to Facilitate the Support of Your IoT Architecture
Tags: fordevelopers, iot, eventdriven, mqtt
Published: 2021-04-14 17:45:17

---
title: Developing an IoT Hub to Facilitate the Support of Your IoT Architecture
published: true
date: 2021-04-01 13:44:26 UTC
tags: ForDevelopers, IoT, eventdriven, mqtt
canonical_url: https://solace.com/blog/iot-hub-mqtt-hackathon/
---

 ![](https://solace.com/wp-content/uploads/2017/07/DARK_Solace-Says-Enabling-Event-Driven-Microservices.png) 

Every quarter, Solace’s PubSub+ Cloud team participates in a two-day hackathon. It’s an opportunity to experiment with the [Solace PubSub+ Platform](https://docs.solace.com/Solace-PubSub-Platform.htm), either by utilizing it in a novel way or extending the platform itself. It’s also a great way to work side by side with others on the team that we haven’t had a chance to work with and possibly dabble in other areas.

Our team’s goal for the hackathon was to provide an IoT hub where users only had to worry about writing code and could leave the other details to us. [PubSub+ Event Broker](https://solace.com/products/event-broker/) is an extremely powerful and versatile broker with a staggering number of features across many protocols. Within two days we went from an idea to actually creating the IoT hub. This article shares how we used PubSub+ Event Broker: Cloud to develop the hub.

## **How the IoT Hub Works**

The IoT Hub uses PubSub+ Cloud to provision event brokers. When a new device is registered on the hub, a new client username is created on the event broker.

[![](https://solace.com/wp-content/uploads/2021/03/iot-hub-1.png)](https://solace.com/wp-content/uploads/2021/03/iot-hub-1.png)

This is as simple as adding a device from the IoT hub’s UI.

[![](https://solace.com/wp-content/uploads/2021/03/iot-hub-2.gif)](https://solace.com/wp-content/uploads/2021/03/iot-hub-2.gif)

## **How We Developed the IoT Hub**

We used  the [ACL substitution variables](https://solace.com/blog/iot-security-acl-substitution-variables/) of PubSub+ to ensure that each device only has access to their own topic space. This was all done with a straightforward integration with the [PubSub+ Cloud REST API](https://docs.solace.com/Solace-Cloud/solace_cloud_rest_api.htm) and [SEMP](https://docs.solace.com/SEMP/Using-SEMP.htm).

We then offered some useful shortcuts for developers who want to dive straight into coding. There are Java and Python snippets ready to download and run, pre-populated with your connection details.

[![](https://solace.com/wp-content/uploads/2021/03/iot-hub-3.png)](https://solace.com/wp-content/uploads/2021/03/iot-hub-3.png)

For easier debugging, we also display recent events within your topic space and provide a way to publish events right from the hub.

[![](https://solace.com/wp-content/uploads/2021/03/iot-hub-4.gif)](https://solace.com/wp-content/uploads/2021/03/iot-hub-4.gif)

./run.sh and you’re publishing and subscribing!

Now we needed devices to use the IoT hub. Our choice? Nerf guns.

[![](https://solace.com/wp-content/uploads/2021/03/NerfDuns-small.gif)](https://solace.com/wp-content/uploads/2021/03/NerfDuns-small.gif)

We created an internet-connected target and score display. Using code samples and connection details from the hub, we were able to start iterating immediately.

When the target powers on, it sends a registration event to the hub. A micro switch push button is depressed when the target is hit. The button triggers “hit” events to be published to the hub. The score display receives the “hit” events and updates the score.

[![](https://solace.com/wp-content/uploads/2021/03/iot-hub-5.png)](https://solace.com/wp-content/uploads/2021/03/iot-hub-5.png)

The hub gave us a fast and simple way to start publishing, subscribing, and seeing events. We were able to add the score display as a second device with the press of a button, giving it its own set of credentials. This quick validation allowed us to concentrate on the actual events instead of debugging connection parameters.

## **The Hackathon – Working with Students**

Solace has participated in many university hackathons, exposing students to event-driven architecture and getting them to think beyond REST. However, many students don’t have much experience with event brokers.

Historically, we helped students sign up for [PubSub+ Cloud](https://solace.cloud/) and guided them through connecting their applications. One of the broker’s greatest assets of being language agnostic and multi-protocol ended up being overwhelming with so many different ways to connect.

We thought the IoT hub could resolve all of these. Choosing MQTT as the protocol, picking which libraries to use for the different languages, and setting up the connection parameters gave students a baseline functionality they could start with. As they explored more advanced use-cases, we could point them to PubSub+ Cloud, but they were armed with a working prototype.

In two days, we had a few tweaks to help us out during an upcoming university hackathon. First, we secured the dashboard with our company’s SSO. This allowed all the Solace volunteers to create new devices (i.e. credentials) and help students debug issues by viewing their connection details. Then, we added a way to generate unauthenticated, hard-to-guess links to the different devices so we could easily onboard the students. Finally, we polished up the interface, added more samples, and hosted the application online.

During the hackathon, we started seeing the benefits immediately. We were able to help students debug simple issues by checking out their connection details and using the hub to publish events to their applications. Instead of the usual questions about how to connect, we heard “How can we tell when a client disconnects?” ([will messages](https://docs.solace.com/Open-APIs-Protocols/MQTT/Using-MQTT.htm#Will)) and “Can I publish with one protocol and subscribe with another?” ([absolutely!](https://solace.com/resources/developer/a-demo-of-solaces-multi-protocol-capabilities)). Without being bogged down by connection issues, students were starting to think beyond the basics and concentrating on the events!

## **Looking Beyond the Hackathon**

The IoT Hub wasn’t the most elaborate use of what Solace has to offer, it was a few opinionated integrations with Solace products that are readily available to anyone. The only difference is that we have the valuable experience of advising countless customers on their event-driven architecture and guiding users to proven patterns.

We hope to bring these lessons to our products. Who knows, maybe sometime in the future you’ll see an “IoT Hub” icon appear in PubSub+ Cloud and you’ll be assured that you have the expertise of Solace powering your products.

The post [Developing an IoT Hub to Facilitate the Support of Your IoT Architecture](https://solace.com/blog/iot-hub-mqtt-hackathon/) appeared first on [Solace](https://solace.com).