NavigationContentFooter
Jump toSuggest an edit

IoT Hub - Quickstart

Reviewed on 04 July 2024Published 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.

Before you start

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization

How to create an IoT Hub

  1. Click IoT Hub in the Managed Services section of the side menu. If you have not already created a Hub, the IoT Hub creation page displays.
  2. Click Create 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.
    • High Availability (HA) Plan: Not only are resources dedicated to the hub, 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 hub or Create hub and add device.
    Note

    If you want to directly add a first device to the hub, click Create a hub and add 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 Managed Services 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 device to 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 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 device to 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 the 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.

Was this page helpful?
API DocsScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCareers
© 2023-2024 – Scaleway