copyright | lastupdated | ||
---|---|---|---|
|
2017-11-14 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:codeblock: .codeblock} {:pre: .pre}
{: #iotplatform_task}
Before you can begin receiving data from your IoT devices, you must connect them to {{site.data.keyword.iot_full}}. Connecting a device to {{site.data.keyword.iot_short_notm}} involves registering the device with {{site.data.keyword.iot_short_notm}} and then using the registration information to configure the device to connect to {{site.data.keyword.iot_short_notm}}. {:shortdesc}
{: #byb}
Before you start the connection process, you must ensure that your devices meet the following requirements for communicating with {{site.data.keyword.iot_short_notm}}:
- Your device must be able to communicate by using HTTP or MQTT protocols.
- The device messages must conform to the {{site.data.keyword.iot_short_notm}} message payload requirements.
For more information, see Developing devices on Watson IoT Platform.
Complete the following steps to connect your device to {{site.data.keyword.iot_short_notm}}.
{: #iotplatform_subtask1}
Registering a device involves classifying the device as a device type, giving the device a name, and providing device information. Then you provide a connection token or accept a token that is generated by {{site.data.keyword.iot_short_notm}}.
You can add devices one at a time from the {{site.data.keyword.iot_short_notm}} dashboard, or you can use the {{site.data.keyword.iot_short_notm}} API {: new_window} to add one or more devices at a time.
To add a device from the {{site.data.keyword.iot_short_notm}} dashboard:
-
Click the {{site.data.keyword.iot_short_notm}} service tile in your {{site.data.keyword.Bluemix}} dashboard.
-
On the service page, click Launch to start administering your {{site.data.keyword.iot_short_notm}} organization.
The {{site.data.keyword.iot_short_notm}} web console opens in a new browser tab at the following URL:
https://org_id.internetofthings.ibmcloud.com/dashboard/#/overview
Where *org_id* is the ID of [your {{site.data.keyword.iot_short_notm}} organization](iotplatform_overview.html#organizations){: new_window}.
- In the Overview dashboard, from the menu pane, select Devices and then click Add Device.
- Select or create a device type for the device that you are adding.
Each device that is connected to the {{site.data.keyword.iot_short_notm}} must be associated with a device type. Device types are groups of devices that share common characteristics.
When you add your first device to your {{site.data.keyword.iot_short_notm}} organization, no device types are available in the Device type menu. You must first create a device type: - Click Create device type.
- Enter a device type name such as
my_device_type
and a description for the device type.
Important: The device type name must be no more than 36 characters and can contain only:
- Alpha-numeric characters (a-z, A-Z, 0-9)
- Hypens (-)
- Underscores (_)
- Periods (.)
- Alpha-numeric characters (a-z, A-Z, 0-9)
- Hyphens (-)
- Underscores (_)
- Periods (.)
Important: The token must not contain repeated character sequences, dictionary words, user names, or other predefined sequences. 15. In the device information page, copy and save the following device information:
- Organization ID, such as
tubo8x
- Device Type, such as
my_device_type
- Device ID, such as
my_first_device
- Authentication Method, such as
token
- Authentication Token, such as
PtBVriRqIg4uh)_-Kl
Tip: You will need Organization ID, Authentication Token, Device Type, and Device ID to configure your device to connect to {{site.data.keyword.iot_short_notm}}.
Congratulations, you registered your device. Now you can configure your device to connect to {{site.data.keyword.iot_short_notm}}
{: #iotplatform_subtask2}
After you register a device with {{site.data.keyword.iot_short_notm}}, you can use the registration information to connect the device and start receiving device data.
{{site.data.keyword.iot_short_notm}} supports many device types. The basic process to connect a device typically includes the following steps:
- Set up your device for MQTT messaging and use Organization ID, Authentication Token, Device Type, and Device ID to authenticate.
- Send device messages to your {{site.data.keyword.iot_short_notm}} organization by using the MQTT protocol.
Tip: Many connection recipes are available for the commonly used devices. For a list of recipes, see the Device connection recipes {: new_window} that are available on IBM.com.
The following information is required when connecting your device:
- URL: org_id.messaging.internetofthings.ibmcloud.com
Where org_id is the ID of your {{site.data.keyword.iot_short_notm}} organization. - Port:
- 1883
- 8883 (encrypted)
- 443 (websockets)
- Device identifier: d:org_id:device_type:device_id
This combination of parameters uniquely identifies your device. - Username: use-token-auth
This value indicates that you are using token authorization. - Password: Authentication token
This value is the unique token that you defined or that was assigned to your device when you registered it. - Event topic format: iot-2/evt/event_id/fmt/format_string
Where the event_id specifies the event name that is shown in {{site.data.keyword.iot_short_notm}}, and format_string is the format of the event, such as JSON. - Message format: JSON
{{site.data.keyword.iot_short_notm}} supports several formats, such as JSON and text.
For more information about connecting your device, see MQTT Connectivity for Devices in the technical documentation.
The Organization Administration {: new_window} API documentation also contains the required information.
{: #restore_device}
Important: The {{site.data.keyword.iot_short_notm}} restore devices feature is available only as part of a limited beta program. Future updates might include changes that are incompatible with the current version of this feature. Try it out and let us know what you think {: new_window}.
If a device deleted by mistake, you can restore it within 14 days.
When the device is deleted, a device “memento” is created. The memento is a copy of the device document and is available for 14 days, after which it is deleted.
The following Restore a Device API enables you to use the memento to restore a previous version of the device:
POST /archive/device/types/{typeId}/devices/{deviceId}/restore
You can use the following API to retrieve a list of all of the device mementos:
GET /archive/device/types/{typeId}/devices/{deviceId}
For more information about the Restore Devices APIs, see Restore Devices APIs Beta .
The following recipes describe the complete flow that is used to register and connect devices to Watson IoT Platform.
-
How to Register Devices in IBM Watson IoT Platform {: new_window}
-
Connecting Raspberry Pi as a Device to Watson IoT using Node-RED {: new_window}
-
Connect an Arduino Uno device to the IBM Watson IoT Platform {: new_window}
-
Connecting a Sense HAT to Watson IoT using Node-RED {: new_window}
-
Connecting Raspberry Pi with Windows IoT Core as a Device to Watson IoT Platform {: new_window}