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:
- You have an account and are logged into console.scaleway.com
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:
5 . Click Create to create your hub.
That’s it, the Hub is created. Now you have to allow devices to connect to it.
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 allow low security 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:
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:
The second 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.
6 . Click Close to return to the Hub’s configuation page.
You have added 2 devices to your Hub, we will now use them to send a message from one device to the other.
To exchange messages between our two devices, we open two web-based MQTT clients, each one connected with the identifier of one of the devices we added previously.
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:
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.
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.