Getting Started with Scaleway IoT Hub

Scaleway IoT Hub Overview

The Internet of Things, or IoT, is about creating a wide ecosystem of services for connected devices to turn them into smart devices.

Scaleway Elements IoT Hub is a message broker, its job is to receive “published” messages and distribute them to the devices who have subscribed to them. Any “client” connected to the Hub can be a publisher and/or a subscriber. To understand how the messages are distributed, we invite you to read our blog post “IoT Hub: Introduction to MQTT Topics”.

In this tutorial, we are going to show you how to create your first IoT Hub to connect to objects, Scaleway services and applications. This tutorial contains the following steps:

Requirements

Creating an IoT Hub

We start by creating our first Hub from the Scaleway console.

1 . Log into your Scaleway console.

2 . Click on IoT Hub in the IoT Station section of the side menu.

3 . The IoT Hub overview page displays. Click Create an IoT Hub:

4 . Enter the information for your IoT Hub:

  • Name your hub (for example: my-first-hub)
  • Select the region in which your Hub will be created (for example: Paris, France)
  • Select a plan (for this tutorial we use the Shared plan)

5 . Click Create to create your hub.

That’s it, the Hub is created. Now you have to allow devices to connect to it.

Adding Devices

A device is a “client” of the Hub, it can be a connected object or any other application. You have to add a “device” for each “client” to connect. Each device will be associated with a unique identifier to be used as “client ID” and a certificate/key pair for a maximum security level. For more detailed information, refer to our blog post “IoT Hub: A Quick Introduction to the MQTT Protocol”.

We add 2 devices publisher and subscriber. In this tutorial, we accept low security connections for the devices. However, in a production environment, it is recommended to always use high-security settings.

1 . From the services list in the IoT Hub section, click on your IoT Hub to enter the hub’s configuration:

2 . Click on the Devices tab, then click Add Devices:

3 . Enter the details of the first device:

  • Check the name of the hub the new device will be assigned to (in our example: my-first-hub)
  • Enter the name of the first device: publisher
  • Click on Allow insecure connection
  • Click Add a Device to your Hub

The first device has been added and you can download its certificate and private key. As we are using insecure connections in this tutorial, you can skip this step.

4 . Click Add a new Device to add the second device.

5 . Enter the details of the second device:

  • Check the name of the hub the new device will be assigned to (in our example: my-first-hub)
  • Enter the name of the first device: subscriber
  • Click on Allow insecure connection
  • Click Add a Device to your Hub

The second device has been added and you can download its certificate and private key. Again, as we are using insecure connections in this tutorial, you can skip this step.

6 . Click Close to return to the Hub’s configuration page.

You have added 2 devices to your Hub, we will now use them to send a message from one device to the other.

Sending Messages

To exchange messages between our two devices, we are going to open two web-based MQTT clients, each one connected with the identifier of one of the devices we previously added.

1 . Click on the first device to see its status page.

2 . Click on MQTT Webclient to open the client. A pop-up displays:

3 . Go back to the devices overview and repeat the steps above for the second device.

4 . You now have two MQTT webclients open, one for the publisher and one for subscriber. The client connects automatically to its associated device. Now that the 2 clients are connected, let’s set up the subscription:

  • On the publisher:
    • Set the topic my/first/topic
  • On the subscriber:
    • Click Add New Topic Subscription
    • Set the topic to my/first/topic
    • Click OK

5 . Now that we have subscribed to the topic my/first/topic, we will post a message on the publisher device. Type the message in the form and click Publish:

You can see in the “Messages” box that the message published by publisher has been received by the subscriber. Congratulations, you have successfully configured your first IoT Hub.

Going Further

To go further, you can subscribe to multiple topics and use wildcards (for more information, refer to our blog post “IoT Hub - Introduction to MQTT Topics”). Finally if you want to use more advanced features such as retained messages (see our blog post “IoT Hub: A Quick Introduction to the MQTT Protocol” for more information), you can start this tutorial again, this time choosing a dedicated or high availability IoT Hub.


Learn more about Scaleway IoT Hub, discover how to add Devices to the hub, check the IoT Hub metrics or get started in a few clicks with the IoT Hub Kickstarts.

Discover the Cloud That Makes Sense