The IBM Watson IoT Platform is a fully managed, cloud-hosted service that makes it simple to derive value from Internet of Things (IoT) devices. When combined with the IBM Bluemix platform, Watson IoT provides simple, but powerful application access to IoT devices and data. You can rapidly compose analytics applications, visualization dashboards, and mobile IoT apps. Create IoT applications that feed insights to your backend enterprise applications.
This recipe shows how one can setup an Watson IoT Organization and register devices in it. Registering for an account on Watson IoT Platform and connecting your first device is simple and will take less than 10 minutes to complete.
Create IBM Watson IoT Platform Organization
When you create a service “Internet of Things Platform” in IBM Bluemix, a new Organization will be created for you. This IBM Watson IoT Platform organization is a space used for connecting and managing devices to the IBM Watson IoT Platform, so that your applications can access their live and historical data.
You can create an IBM Watson IoT Platform organization by using IBM Bluemix. Follow the below steps to do the same,
- Open your favorite browser and go to Bluemix. If you are an existing Bluemix user, log in as usual. If you are new to Bluemix you can sign up for a free 30 day trial.
- Once you signed up to Bluemix, click this link to create the Watson IoT Platform service in Bluemix.
- Type a name for your service and click Create button as shown below,
- Observe a Welcome page, click on Launch button to enter into the IBM Watson IoT Platform organization space. The IoT organization is a space used for connecting and managing devices to the IBM Watson IoT Platform, so that your applications can access their live and historical data.
- Observe that a new Organization is created where you can add, connect and manage IoT devices.
At this step, we have successfully created the IBM Watson IoT Platform organization.
Create Device Type
Each device connected to the IBM Watson IoT Platform is associated with a device type. Device types are intended to be groups of devices which share common characteristics. So in order to add devices in IBM Watson IoT Platform, one need to create a device type. Following are the instructions for creating a Device Type
- Go back to the IBM Watson IoT Platform dashboard, click Devices tab, device types tab, then click on the Create Type button as shown below,
- Observe that there are 2 options provided now, namely Create device type and Create gateway type. As this recipe focuses on adding a device and not a gateway, click Create device type and proceed, (Gateways are a specialized class of devices in the IIBM Watson IoT Platform. Gateways are devices which serve as access points to theIBM Watson IoT Platform for other devices. Gateway devices can register new devices and can send and receive data on behalf of devices connected to them. Refer to the documentation for more information about the Gateway),
- Specify a name for the device type to be added and optionally a description as shown below and clieck next,
- Observe that a template page is given where you can select and define one or more attributes. All of these attributes are optional. They will be used as a template for new devices that are assigned this device type. Attributes that you do not define may still be edited individually later when you add the device. You can define one or more attributes by selecting them and clicking Next as shown below,
- Define the selected attributes Manufacturer and Model as shown below, then click next,
- Define optional Metadata in JSON format as shown below, you can choose not to set this attribute as its optional, then click Create,
- Observe that a new device type is added in the IBM Watson IoT Platform Organization,
At this step, we have successfully created a device type in IBM Watson IoT Platform organization.
Add Device in IBM Watson IoT Platform
A device can be defined that has a connection to the internet and has data it wants to get into the cloud. And devices can accept commands from applications as well. You need to add the device in IBM Watson IoT Platform Organization before connecting it to the IoT. Carry out the following steps to add the device in IBM Watson IoT Platform,
- In the IBM Watson IoT Platform dashboard, click Browse tab and then Add Device button as shown below,
- Choose the device type “iot-sample-device-type” that we created in the last step, then click Next as shown below,
- Enter a unique device id, which will distinguish your device from all other devices that you might connect to the IoT (you can use 1 or something more sophisticated like your devices MAC address), then click Next as shown below. Also note that the values of “Manufacturer” and “Model” attributes are populated from the device type “iotsample-devicetype”. These values can be overridden, attributes not set in the device type can be added as well.
- Add a Metadata and click next, (you can choose not to add Metadata as its optional),
- In the next page, you can either add your own authentication token, or allow the IBM Watson IoT Platformto generate a token for you. The IBM Watson IoT Platform generated token will be 18 characters long and will contain a mix of alphanumeric characters and symbols. The token will be returned to you at the end of the registration process. In case if you want to add your own token, enter the token as shown below, then click Next,
- As shown below, you will be given a summary page to verify the details before adding the device to IBM Watson IoT Platform. Verify and click Add,
- At this step, the device is registered to your Organization and you will be provided with the registration details as marked below. To get your device connected, you need to add the credentials to your device. So make a note of them.
- Click the cross button to get back to the main dashboard and observe that the device is added in your Organization,
So, now we have successfully added a device in the IBM Watson IoT Platform organization.
Generate API Keys
The earlier sections in this recipe helped you to create a Device-Type and add a Device to it. The Device credentials enables the connectivity from the Device side. To initiate a connection from the Application side, you would need API-Keys and the associated Authentication Tokens.
The following set of steps shall help you to generate a set of API-Key and it's associated Token.
- In the Watson IoT Platform Dashboard, click on Apps option, as available on the left hand side column
- Click on the 'API Keys' tab, one available in the listed options
- You should now see a Generate API Key option available on the right hand side, as depicted in the following image.
- You are now provided with the API Key & Authentication Token Information, that gets generated for you.
- Optionally add a comment
- Click on Generate to complete the process of generated API Key and it's associated Authentication Token, as shown in the following image
You have now successfully generated API credentials that enables you to initiate Application side connectivity.
In this recipe we demonstrated how to setup an IBM Watson IoT Platform Organization, create a Device Type and register a Device using theIBM Watson IoT Platform dashboard. Also, you can use the IBM Watson IoT Platform ReST API, or the Client Libraries to create the Device Type and register Devices in IBM Watson IoT Platform.
Where to go from here?
1. Browse through various tutorials available in DeveloperWorks Recipes to know how to connect specific devices toIBM Watson IoT Platform, visualize the events originating from these devices, control, process and analyze these device events using applications. Say, for example, if you want to connect a Raspberry Pi device to IBM Watson IoT Platform, follow this recipe.
2. Browse through various IBM IoT Programming guides to develop your own device or application code There are several client libraries available for use with theIBM Watson IoT Platform. The client libraries are designed to allow users to interact with their devices and applications using their preferred language, and to simplify this interaction as much as possible.