Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

MQTT with IBM Bluemix

MQTT with IBM Bluemix

750 replies posted 500 likes received 500 replies posted

MQTT with IBM Bluemix

IBM Watson IoT Platform provides powerful application access to IoT devices and data to help you rapidly compose analytics applications, visualization dashboards and mobile IoT apps. It is a service that is available in IBM Bluemix. Watson IoT Platform allows you to perform powerful device management operations, and store and access device data, connect a wide variety of devices and gateway devices. It provides secure communication to and from your devices by using MQTT and TLS. Instances of the Watson IoT Platform can be created in the Bluemix dashboard. The Watson IoT Platform can be integrated with other Bluemix services and accessed by using the Bluemix dashboard. MQTT.fx tool is used to monitor the messages exchanged between cloud and device.

This Help Article discusses how to use CYW943907AEVAL1F EVK for connecting to IBM Bluemix.

Create a Bluemix account in console.bluemix.net. In Bluemix Console, register a device and device type. Note down the Token number you get while registering the device.

  1. Open the pub_sub_bluemix.zip file provided along with this post in WICED Studio 5.1 or above.
  2. Open the file wifi_config_dct.h to configure the Device Configuration Table (DCT). Modify the values of the macros CLIENT_AP_SSID and CLIENT_AP_PASSPHRASE to match your Wi-Fi access point SSID and password respectively. Ensure that the AP is connected to the internet.
  3. In pub_sub_bluemix.c file, following macros have to be set with proper values to connect to the IBM Bluemix.

                #define   ORG_ID                                                             " "

                #define   DEVICE_TYPE                                                  " "

                #define   DEVICE_NAME                                                 " "

                #define   TOKEN                                                               " "

ORG_ID is unique organization ID you get after creating account. Click on the upper right corner of Bluemix console. Red box shows the organization ID. Type the device type, device name and authorization token you get while registering the device.


As we are making the unsecured connection, change the Security settings in Bluemix console. Go to Security Section. Click on the edit tab.


Select 'TLS Optional' option from the list.


After updating the above information, create make target, run & download program to device CYW943907AEVAL1F.

To verify the output, open the MQTT.fx tool. On the main window, click on the setting tab.


In the pop-up window, set the broker address in the following format:


To generate Client ID and password, open the Bluemix Console. Select APPS section from the Bluemix console window and click on Generate API key.


In the pop-up window, you will see the API key and Authentication token generated as below. Copy the credentials and click on Generate.


Now paste these credentials as User Name and Password in User Credentials tab.

  • The MQTT client ID is in the following format: a:org_Id:appId
  • The MQTT user name is the API key, for example, a-org_Id-a84ps90Ajs
  • The MQTT password is the authentication token, for example, MP$08VKz!8rXwnR-Q

For more information, you can browse the link: MQTT connectivity for applications

Click on OK.


Click on Connect to connect to the IBM Bluemix. You should see a green circle after connection.


Devices can subscribe to commands which have following format:


command_id is the ID of the command, for example, update. It can be any string permitted by MQTT.

format_string is the format of the event payload, for example, json, text, bin.

Type Subscribe topic and click on Subscribe as shown in below figure.pastedImage_19.png

Similarly devices publish the events which have the following format:


device_type and device_name are the type and name of the device you have registered.

For more information, you can browse the given link.

Type some message in the box below and click on Publish. You will see that message on UART terminal.



Not applicable


Thanks for the information,

Everything is working fine.

in ibm bluemix it is showing the connection status as : connected.

and i don't know where the data has be stored in the bluemix device.

can you help me on this where the data will be stored in ibm bluemix device?



Moderator 750 replies posted 500 likes received 500 replies posted

Kindly let me know whether you are referring to the CYW943907AEVAL1F kit or the Bluemix server by 'Bluemix device'?

I am inferring it is the CYW943907AEVAL1F kit. The eval kit handles it through queues. Address of the memory location is passed during MQTT initialization and the data is stored at this location. When a message is received, it is stored at this location by pushing it to a queue.