-
Create an account on http://www.ibm.com/cloud-computing/bluemix, if you do not yet have one.
-
Select New Dashboard if that option is presented.
-
Go to your dashboard and click Use Services or APIs to add a new service.
-
From the Selected Plan drop-down list, choose a pricing plan.
-
Under Connect your devices, click the Launch dashboard button.
This opens a new IBM Watson IoT Platform window. -
Click the Create device type button.
This opens the Create Device Type page.
-
From the Choose Device Type drop-down list, select the new device type you created in the previous section, and click Next.
-
In the Device ID field, type the ID of your device and click Next.
-
In the Security step, auto-generate an authentication token by clicking Next.
-
Make a note of the Authentication Token displayed under Your Device Credentials.
If you have followed all the steps above, you should have all the information that your program needs to connect to the MQTT* server:
hostname
- use [Your organization ID].messaging.internetofthings.ibmcloud.com
, along with the ssl://
(for C++) or mqtts://
(for JavaScript*) protocol
client_id
- use d:[Your organization ID]:[Your device type]:[Your device ID]
topic
- use iot-2/evt/status/fmt/json
username
- use use-token-auth
password
- use the string with the authorization token of your device
When running your C++ code on the Intel® Edison board or Intel® IoT Gateway, you need to set the MQTT* client parameters in Intel® System Studio*. To do that:
-
Go to Run configurations and, in the Commands to execute before application field, type the following:
export MQTT_SERVER="ssl://[Your organization ID].messaging.internetofthings.ibmcloud.com:8883"; export MQTT_CLIENTID="d:[Your organization ID]:[Your device type]:[Your device ID]"; export MQTT_USERNAME="use-token-auth"; export MQTT_PASSWORD="[Your authorization token]"; export MQTT_TOPIC="iot-2/evt/status/fmt/json"
-
Click the Apply button to save these settings.
-
Click the Run button to run the code on your board.
When running your JavaScript* code on the Intel® Edison board or Intel® IoT Gateway, you need to set the MQTT* client parameters in the Intel® XDK IDE. Add the following entries to the config.json file:
"services": {
"mqtt": {
"hostname": "mqtts://[Your organization ID].messaging.internetofthings.ibmcloud.com:8883",
"client_id": "d:[Your organization ID]:[Your device type]:[Your device ID]",
"topic": "iot-2/evt/status/fmt/json",
"username": "use-token-auth",
"password": "[Your authorization token]"
}
}
When running your Python* code on the Intel® Edison board or Intel® IoT Gateway, you need to use the MQTT* interface by setting the client parameters. Add the following entries to the config.json file:
"services": {
"mqtt": {
"server": "[Your organization ID].messaging.internetofthings.ibmcloud.com",
"port": "8883",
"client_id": "d:[Your organization ID]:[Your device type]:[Your device ID]",
"topic": "iot-2/evt/status/fmt/json",
"username": "use-token-auth",
"password": "[Your authorization token]"
}
}