Skill Level: Any Skill Level

Beginner. With little or no coding experience.




  1. Introduction

    Tasker is an automation application on the Android platform. It allows actions to be performed based on contexts (application, time, date, location, event, gesture). Therefore connecting an Android device (with Tasker) as a managed device in the IBM Watson IoT Platform, we can create an improvised IoT device that can react to a devices motion, light or GPS sensors for example.

  2. Setup the IBM Watson IoT Platform Service

    • In the IBM Bluemix platform dashboard select the CATALOG option in the main banner.
    • Select the Internet of Things Platform service and create the service on the subsequent page.
  3. Create the Android Device in the IBM Watson IoT Platform

    • Back in the IBM Bluemix platform dashboard.
    • Click the Internet of Things Platform entry in the Services section which was setup in the previous step.
    • You will be presented with three main options, click Launch Dashboard.
    • Now shown will be the device management page titled with your Organization ID. Click the DEVICES tab to show the currently managed IoT devices.
    • Click the Add Device button to begin entering details about the Android device.
    • Click Create device type. Enter the name of the device and give it a description. In this example we will use “Android_IoT_Device” as the name. Then click Next.
    • In the Define Template step. The description attributes are all optional, select the attributes which you would use to define the device.
    • The subsequent steps allows the input of the optional attributes, continue until the Create button is presented. Then click this button to create the device type.
    • The device type will be created and the Add Device page is presented. Select the device type created in the previous step in the drop down and click Next to begin creating the device.
    • The Device Info page is now presented. Enter the Device ID and click “Next”. In this example we will use “AndroidTasker”.
    • Click Next until the Security page is presented. In this example we will use an auto-generated token by simply clicking Next.
    • A Summary Page is now presented to show the device details. Click Add to create the new device.
    • The next page displayed shows the device credentials, make a note of these settings they will be required when setting up the Android device.
  4. Setting up your Android Device

    • Install the Tasker application from the Play Store. (This is a paid application)
    • Install MQTT Tasker plugin from the Play Store. This is required to generate the MQTT protocol messages which communucate with the IBM Watson IoT Platform.
  5. Creating your first Tasker profile

    In this tutorial we will create a Tasker profile which waits for the phone to be shaken. Once this is detected, it actions the task which sends the MQTT message to the IBM Watson IoT Platform. Beyond this example, any of the other sensors on the phone could be polled or even listen for message, network or application activity.

    • Launch Tasker application on the Android Device.
    • Ensure that the Profiles Tab is selected and click the “+” button on the bottom right to start creating the first profile.
    • In the popup of available profile events, click the Event option.
    • In the Select Event Category dialog select Sensor.
    • Then select Shake in the Select Sensor Event dialog.
    • Then the Event Edit page should now be presented. Click the back arrow on the top left to create the profile. Once the new profile is created, you can then associate an existing task or create a new task.
  6. Creating your first Tasker task

    Once we have a profile created, the next step is to create a task, which contains the action to communicate with the IBM Watson IoT Platform.

    Using the MQTT plugin, generate the message which is understood by the IBM Watson IoT Platform.

    • Select New Task which will create a new task for the current profile.
    • Give the New Task a name. In this example I have called it “IoT Foundation” .
    • You will be presented with the Action page. Click the “+” at the bottom.
    • In the Select Action Category dialog, select Plugin.
    • In the Action Plugin dialog, select MQTT Publisher.
    • You will now be presented with the Action Edit page for the MQTT publisher, click the pencil icon to configure the MQTT message to be sent.
    • The MQTT details are configured as follows (See MQTT protocol reference). At this stage you will need the device credential details which were obtained when registering the device in the IBM Watson IoT Platform.
    • Server Address : <Organisation ID>.messaging.internetofthings.ibmcloud.com
    • Port: 1883
    • Client ID: d.<Organization ID>:<Device Type>:<Device ID>
    • SSL/TLS: Unchecked
    • Username: “use-token-auth”
    • Password: Authentication Token
    • Topic: iot-2/evt/<event name>/fmt/<format>
    • Payload: In the example I send a single value with the value of a Tasker variable “%VAR”. This is set to “Hello” in Tasker, but shows the possibility for sending programmatic datapoint values.
    • QOS: 0
    • Retain Flag: Unchecked
    • Click Accept once all details have been entered.
    • On the Action Edit page, click the top left back arrow to save the task.
  7. Verifying the connection with IBM Watson IoT Platform

    • Navigate to the IBM Watson IoT Platform dashboard
      • At the IBM Bluemix dashboard click on the IBM Watson IoT Platform Service
      • or navigate directly via https://<OrganizationID>.internetofthings.ibmcloud.com/dashboard
    • Click on the DEVICES tab to show the list of registered devices.
    • Click on the “AndroidTasker” device from the list to show device details.
    • On this page pay attention to the Recent Event and Sensor Information sections.
    • Shake the Android device to activate the messaging task.
    • If the message received by the IBM Watson IoT Platform is correctly formatted and authenticated, the Recent Events and Sensor Information will start to be populated, confirming a valid connection.
  8. Next Steps

    Once you have connected an Android IoT device, have a try of the “Internet Of Things Platform Starter” Boilerplate in the IBM Bluemix catalog.

    See how the managed Android IoT device can be wired up using Node-RED in Bluemix.

9 comments on"Connect an Android Device as a Managed Device in the IBM Watson IoT Platform using Tasker"

  1. Hi,
    Thanks for this great post. I was looking for something like this.
    I followed all the steps what you have described here, but still my Android phone is unable to connect to IoT Foundation. Could you please help me to resolve this issue.

    Thanks and Regards

  2. I’ve had the same issue. Not sure the MQTT information is still working. The shake is definitely being registered locally because I had it activate the flash when it detects it. Just no connection up into the IoT service.

  3. tomleightonIIC May 14, 2016

    Hi there, I’ve noticed a small but crucial typo in the entering settings stage.

    The instructions say “Client ID: d.::” whereas it should be “Client ID: d:::”
    Note the colon after the ‘d’

    Hope this helps!

    • tomleightonIIC May 14, 2016

      Seems as though those code bits got reduced however after the ‘d’ there needs to be a colon (:) not a period (.)

  4. JennSkeivik August 07, 2016

    I had the same issue with no connection to the IoT Foundation- try setting your timeout in the MQTT publisher action to something other than the default of 0. Mine is set to 30 and it connects just fine now.

  5. Thakns for sharing suhc post. Connecting an android device to IBM Watson loT is now an easy proces.. http://www.xmod.me/

  6. Hi
    I just set up my Android MQTT publisher… with the same VAR… however no events generated.
    how do I set the VAR to hello ???

  7. Somehow it’s not connecting

  8. Somehow it’s not connecting. No events message generated…

    in the payload section I set {“d”:{“value”:5}}

Join The Discussion