Simple Messaging
Last updated
Last updated
IBM Cloud is a cloud service that offers, among other things, an IoT platform that lets IoT devices connect and send data that can later be analyzed using IBM cloud services. This IoT platform offers a REST API as well as an MQTT broker interface. In this tutorial we will learn how to set up IBM Cloud and connect to it using our network simulator.
Before starting, sign up for a free IBM Cloud account at https://www.ibm.com/cloud, and then log in to your account. You will be asked to create an organization and a space: follow the instructions and then you will be taken to your account’s dashboard. Click Catalog in the top menu, then the Internet of Things category in the left menu, and then Internet of Things Platform:
Now you have to create a service: insert a name for the service (for example: IoTIFY) and then click Create; then, on the welcome page click Launch. You are now taken to the IBM Watson IoT Platform dashboard.
Once the service is launched, the next step is to create a device type: on the left menu, click Devices, activate the Device Types tab, and then click the Add Device Type button; on the next screen, enter a name for your type and click Next. You can optionally define template data or add metadata to the device type, but this is not mandatory, and you can simply skip these steps when creating the device type. Click Finish to complete the device type registration.
Now you can go to the Browse tab, click on Add Device; in the Device Type field, select the previously created device type from the drop-down menu. The only mandatory data to insert for a new device is the device ID: choose an ID for your device, then go through the following steps and finally click Finish.
The next screen shows all the info for your device, including an authentication token: take note of this token now, since it will be needed when setting up the IoTIFY network simulator:
The setup phase in IBM Cloud is completed: now it’s time to send data to it from our network simulator.
You can start by importing our predefined template from the link below
Or, You can create one yourself.
To create a new template, go to the TEMPLATES
tab of IoTIFY Network Simulator and click on New Template
Then, select MQTT(S)
as connection protocol, give the template a name of your choice (for example, IBMcloud) and click on CREATE
.
The next screen allows you to customize the template. In the MQTT parameters section, do the following configuration:
select MQTTS (TCP)
as protocol
insert a string with the format <org-id>.messaging.internetofthings.ibmcloud.com
as endpoint URL, where <org-id>
is the identifier of your organization in your IBM Cloud account. You can find this information on the top right of your IBM Watson IoT Platform dashboard, below your account's IBM ID.
The topic of the MQTT messages sent by the devices must be of the form iot-2/evt/<event_id>/fmt/json
, where is a name of your choice that identifies the events published by a device.
Then, asClientID
you have to insert a string with the format d:<org-id>:<device_type>:<device_id>
, where
<org-id>
is the same as above
<device_type>
is the name of the device type associated to your device in IBM IoT Platform
<device_id>
is the identifier of your device.
In the credentials ections, you have to supply authentication credentials: insert use-token-auth
as username, and the authentication token assigned when you created your device as password:
The MQTT message contents must be formatted in JSON and must contain a single top-level property called d. For example:
Click on PREVIEW to verify if your template has been configured correctly; then, if the preview is successful, save your template and you are all set up to send data to IBM Cloud.
In IoTIFY Network Simulator, launch a new simulation, and as your virtual devices start sending MQTT messages you will be able to see your generated data in the IBM IoT Platform dashboard: click on your device in the dashboard, and you will see events as they come in from our simulator:
Clicking on an event will show you the corresponding message contents, generated by the simulator according to your template:
That’s it! Enjoy using our network simulator with IBM Cloud!