Overview

Skill Level: Any Skill Level

intermediate

Ingredients

  • DragonBoard410c (pre-loaded with Linux)
  • Power supply

 

Step-by-step

  1. Step1: Prepare the IoT cloud service

    Signing up with IBM Bluemix:

    Go to IBM Bluemix. If you are an existing Bluemix user, log in as usual.
    If you are new to Bluemix you can sign up for their free 30 day trial.

    Create an IBM Watson IoT Platform Service instance:

    Once logged into the IBM Bluemix account, open the IBM Bluemix Catalog and select the Internet of Things Platform Service.

    Create and start an instance of the Internet of Things Platform Service.

    Create an Organization:

    The first time you start the Internet of Things Platform Service you will be asked to setup an organization. Just follow the onscreen instructions.

    Add your device:

    Once you created an organization through Bluemix, you can register and add a your device.

    • Select the IoTF organization dashboard and click ‘Add a new device.
    • Follow the on screen instructions

    During the device registration process you will get the following information:

    • Organization ID
    • Device Type ID
    • Device ID
    • Authentication Method
    • Authentication Token

    ! Please keep note of this information as you will need it at a later step !

  2. Step2: Prepare your device

    Download the MQTT-client app:

    To install the IBM Watson IoT Platform client library and MQTT-clientapp for Embedded C follow the instructions below.

    • To install the latest version of the library, enter the following code in your command line.

    • [root@localhost ~]# git clone https://github.com/ibm-messaging/iotf-embeddedc.git
    • Extract the downloaded compressed file:
    • cd iotf-embeddedc
      tar xvzf org.eclipse.paho.mqtt.embedded-c-1.0.0.tar.gz
    • The extracted client app has the following file structure:

      |-lib - contains all the dependent files
      |-samples - contains the helloWorld and sampleDevice samples
      |-sample device.c - sample device implementation
      |-helloworld.c - quickstart application
      |-README.md
      |-Makefile
      |-build.sh
      |-iotfclient.c - Main client file
      |-iotfclient.h - Header file for the client

    Build the MQTT-client app:

    Before you can run the sample MQTT-client app you need to build it from source:

    Switch to the samples folder and execute Make:

    cd iotf-embeddedc/samples
    make

    You should see the following output on the screen:

    cc sampleDevice.c -I ./../ -I ./../lib ./../iotfclient.c ./../lib/MQTTClient.c ./../lib/MQTTLinux.c ./../lib/MQTTFormat.c ./../lib/MQTTPacket.c ./../lib/MQTTDeserializePublish.c ./../lib/MQTTConnectClient.c ./../lib/MQTTSubscribeClient.c ./../lib/MQTTSerializePublish.c ./../lib/MQTTConnectServer.c ./../lib/MQTTSubscribeServer.c ./../lib/MQTTUnsubscribeServer.c ./../lib/MQTTUnsubscribeClient.c -o sampleDevice
    strip sampleDevice

    Configure the MQTT-client app connection parameters:

    In order for the MQTT-client app to connect to the Watson IoT service it needs the correct connectionpoarameters you received during step1. The connection parameters can be passsed through the commandline or simply passed in through a device configuration file:

    Open the device configuration file in your favorite file-editor : iotf-embeddedc/samples/device.cfg

    nano iotf-embeddedc/samples/device.cfg

    Add the configuration parameters you retrieved during Step1.

    org=$orgId
    type=$myDeviceType
    id=$myDeviceId
    auth-method=$token
    auth-token=$token

    Start the sample MQTT-client app:

    To start the client app simply type:

    ./samples/Device

    Once started the client app should connect to the service and you should see the following output on the screen:

    Connecting to registered service with org <your org>
    Publishing the event stat with rc 0
    Publishing the event stat with rc 0
    Publishing the event stat with rc 0
    ...

    The sample MQTT-Client app is now connected to the Watson IoT service and produces sample data.

  3. Step3: Verify connection in the IBM Watson IoT Platform Dashboard

    Once the Client-app is started we can verify the connection and incoming data on the IoT Dashboard:

    • Log into your IBM bluemix account and start the IOT Dashboard
    • You should see the incoming JSON messages from the client app on your board:

  4. Where to go from here…

    This recipe showed the basic steps required to establish a connection between the MQTT-client app on your device with the IoT service in the cloud.

    Now it’s up to you to expand on this example and build your own IoT application using the DragonBoard 410c and IBM Watson IoT service.

    Also check out the other recipes for inspiration and don’t forget to post your recipes to inspire others.

    For instance:

    • Expand the sample MQTT client app to access the DragonBoard hardware:
      • Read DragonBoard410c hardware state
      • Read values of connected sensors
      • Controll connected actors (lights, motors, etc…)
    • Expand the cloud service by combining the Watson IoT Service with other Bluemix applications to work on the data from the device :
      • Data Visualization
      • Data storage
      • Data analytics

    For details regarding the DragonBoard410c see:
    arrow.com/dragonboard410c

  5. Purchase the DragonBoard410c

    You can purchase the DragonBoard410c directly from Arrow’s website:

7 comments on"DragonBoard410c recipe"

  1. […] taking advantage of the capabilities of the DragonBoard 410c and the IBM Watson IoT platform, the DragonBoard 410c Recipe can help you get started in a few easy steps. After signing up for a free trial of IBM Bluemix or […]

  2. […] taking advantage of the capabilities of the DragonBoard 410c and the IBM Watson IoT platform, the DragonBoard 410c Recipe can help you get started in a few easy steps. After signing up for a free trial of IBM Bluemix or […]

  3. ValerieLampkin June 29, 2016

    The source code has been updated, so users should execute the setup.sh – before running the make in Step 2 “Build the MQTT-client app”

  4. blairanderson August 11, 2016

    and the new executable is ./samples/sampleDevice

    hmmm, connects and publishes with success but I don’t see any indication of data being received on my dashboard

  5. I followed the above steps and i dont see the device publishing anything. Can you please let me know what may be missing. When adding the device, I did note the values as below and added them in the device.cfg
    org=rgcggg
    type=iotsample-devicetype
    id=9900114850abd
    auth-method=token
    auth-token=mz2lh*Da_l0e07R9*k

    linaro@linaro-gnome:~/test/iot-embeddedc/samples$ ./sampleDevice
    Connecting to registered service with org rgcggg

  6. a samll correction in my above comment
    id=9900114850ab is 12 digit

Join The Discussion