Jump toUpdate content

Quickstart

Reviewed on 26 May 2021Published on 26 May 2021

Scaleway IoT Hub is a resilient and multi-protocol message broker with export capabilities. Devices can connect to the Hub to exchange messages, by which they get access to cloud services. Hub Routes also allow Devices to push messages to other, non MQTT, services.

In this Quickstart, we show you how to create your first IoT Hub to connect objects, Scaleway services and applications.

Requirements:

How to create an IoT Hub

  1. Click IoT Hub in the IoT Station section of the side menu. If you have not already created a Hub, the IoT Hub creation page displays.

  2. Click Create a Hub. The hub creation wizard displays.

  3. Enter a name for your Hub and choose the geographical region to deploy your hub.

  4. Choose a product plan for your IoT Hub. Currently three product plans are available for Hubs:

    • Shared plan: This is a cost-effective, straightforward plan. Good for proofs-of-concept or DIY projects. The price is kept low by sharing resources between users, but it is therefore forbidden to use MQTT features which require memory (no messages with QoS1, QoS2, retained and no anonymous devices). Although this plan does not limit the number of devices, you will be billed for devices exceeding the number allowed within the free tier.
    • Dedicated Plan: This plan offers dedicated resources for the Hub, which means more predictable performances and full support of the MQTT protocol.
    • HA Plan: Not only are resources dedicated to the Hub, but they are also replicated so that the broker is highly available. This setting is ideal for workloads that require greater robustness for their Hub.
  5. Click Create a Hub or Create a Hub and Add a Device.

    Note:

    If you want to directly add a first device to the hub, click Create a Hub and Add a Device and continue with the documentation IoT Hub - Devices

How to add a device

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.

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

  1. Click IoT Hub in the IoT Station section of the side menu. The list of your IoT Hubs displays.

  2. Click the name of the IoT Hub on which you want to add a device. The hub’s overview page displays.

  3. Click Add Devices in the Devices tab of your Hub.

  4. Enter the details of the first Device:

    • Check the name of the hub the new device will be assigned to.
    • Enter the name of the first device: publisher
    • Click 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.

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

  6. Enter the details of the second device:

    • Check the name of the hub the new device will be assigned to.
    • Enter the name of the first device: subscriber
    • Click 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.

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

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

How to send 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 the first device to see its status page.

  2. Click 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.