Skill Level: Any Skill Level




Have at least completed the "Getting started with IBM Watson IoT platform" tutorial 


  1. Intro to MQTT from the device side

    The primary mechanism that devices and applications use to communicate with the IBM Watson IoT platform is MQTT; this is a protocol designed for the efficient exchange of real-time data with sensor and mobile devices.

    We define two primary classes of thing: Devices & Applications

    The class of thing that your MQTT client identifies itself to the service as will determine the capabilities of your client once connected as well as the mechanism through which you will need to authenticate.

    Applications and devices also work with different MQTT topic spaces. Devices work within a device-scoped topic space, whereas applications have full access to the topic space for an entire organization.

    A managed device is required to subscribe to the following topic to handle requests and responses from the IoT Platform:

    A managed device will publish to topics specific to the type of management request being performed:

    The managed device will publish device management responses on iotdevice-1/response
    For other topics a managed device may publish to, refer to Device Management Protocol and Device Management Requests.
    Message Format
    All messages are sent in JSON format. There are two types of messages.

    Requests are formatted as follows:

    { “d”: {…}, “reqId”: “b53eb43e-401c-453c-b8f5-94b73290c056” }

    d carries any data relevant to the request
    reqId is an identifier of the request, and must be copied into a response. If a response is not required, the field should be omitted.

  2. 1. Install the MQTTlens plugin

    This is a really nice plugin that can be used to simulate messages from any device:


  3. 2. Create an Internet of things platform starter app on Bluemix

    If you have not completed the tutorial in the requirments. First follow the steps in the Bluemix Starter project to create a Cloud Application that will capture your simulated devices messages:


    Finally register the planned device with the Bluemix App:


    TIP: use lowercase for your device type and device id.

  4. 3. Configure your plugin to simulate a device

    Hostname: <BLUEMIXAPPID>.messaging.internetofthings.ibmcloud.com

    e.g. kzut1k.messaging.internetofthings.ibmcloud.com


    e.g. d:kzut1k:iotdevice:iotdevice1

    Username: use-token-auth

    Password: selected password or generated token

  5. 4. Generate an MQTT message

    Check your own details for connecting to your app in the show credentials of the “internet of things platform” service it should look something like:


    “iotf-service”: [
    “name”: “Internet of Things Platform-4m”,
    “label”: “iotf-service”,
    “plan”: “iotf-service-free”,
    “credentials”: {
    “iotCredentialsIdentifier”: “a2g6k39sl6r5”,
    “mqtt_host”: “kzut1k.messaging.internetofthings.ibmcloud.com”,
    “mqtt_u_port”: 1883,
    “mqtt_s_port”: 8883,
    “base_uri”: “https://kzut1k.internetofthings.ibmcloud.com:443/api/v0001”,
    “http_host”: “kzut1k.internetofthings.ibmcloud.com”,
    “org”: “kzut1k”,
    “apiKey”: “a-kzut1k-fqwfykkofh”,
    “apiToken”: “J@BV+u7mXwc17&OZhR”

    Take the details and enter them into your plugin as follows:

    Publish: iot-2/evt/iotsensor/fmt/json

    Message: {“d”:{“<KEY>”:”<VALUE>”}}





  6. References…

    Continue reading MQTT:


    Continue reading MQTT Devices:


7 comments on"Create an IOT Simulator of any IOT Device (MQTT)"

  1. This is my first recipe, so any comments or questions please let me know. Thanks for reading!

  2. PatrickHourigan May 17, 2016

    Very handy recipe, This would work well with the Apache Spark recipe to feed it differentiating MQTT messages based on simulated device types.

  3. Lovely recipe, Eoin! Could be used as a building block in lots of other projects

  4. Sorry guys just noticed the order was changed after adding the pictures, I’ve added numbers to the steps to prevent that happening again.

  5. kevincao1971 May 26, 2016


Join The Discussion