What do you need to get started:
- An IBM ID and password
- An IBM DevOps Services account
- A Bluemix account
Setup BlueMix environment.
Step 1: After registration, we go to the CATALOG section on menu side and choose Internet of Thing Foundation Stater.
Step 2: Go to the DASHBOARD, click on recent created application to access control page. IBM will add automatically 2 services are IBM Cloudant and Internet of Thing Service to our application.
Configure IoT Application
Step 1: Click our app’s ROUTES path to browse to the app website:
On the left side is the list of available nodes (input and output “connectors” and functions to perform on input data or to produce an output). On the right side are the properties of the node that’s selected in the worksheet.
Step 3: Remove all nodes from the sheet and create a new flow datagram. New flow graph includes 1 “IBM IoT APP In” node connected to debuger and cloudant node.
Step 4: Click on IBM IoT App In Node and change Node’s configuration:
- Authentication method define the way device authenticate to connect to BlueMix platform.
- Bluemix Service: Using Inbound authentication service. This is the common way to authenticate devices connect to IBM IoT service.
- Quick Start: No need any authentication service.
- API Key: Authenticate using API key. The key is found in Node properties.
- Input Type: Define data which is received from devices such as: Event, command or status.
- Device ID and Event: Define device IDs or event will be received.
Step 5: Click on Device Status Debug node to configure output debug message.
- Output: define message fields which want to show.
- To: define place to display messages. Debug tab are located in the right side of screen.
Step 6: Click on cloudant node to configure cloudant database:
- Service: define database service which is added into our application.
- Database: define the name of database used to save data.
- Operation: define method used to save data.
Configure IBM IoT Service:
Step 1: Click on Interenet of Thing service and launch dashboard.
Step 2: Click on device section on menu and add a new device:
- First, we will choose device types. In this case, we choose “MQTT device” or we can create own device type
- Fill device ID, this value is used to identify and distinguish between devices
- Skip metadata and Security step. After successful creation, device is showed on device page.
Connect device to IoT service using Python application:
Step 1:Download and install ibmiotf library using command “pip install ibmiotf”.
Step 2: The constructor builds the client instance, and accepts an options dict containing the following definitions:
- org – Your organization ID.
- type – The type of your device.
- id – The ID of your device.
- auth-method – Method of authentication (the only value currently supported is “token”).
- auth-token – API key token (required if auth-method is “token”).
Step 3: Use ‘connect’ method to connect created device to IoT service.
Step 4: After connect successfully, we use ‘publishEvent’ method to publish data to IBM IoT service. The parameters is requested are topic name, datatype and data respectively.
You can see more application detail at https://github.com/hunglkuit/BlueMix-Tutorial