Contents


Overview

Skill Level: Any Skill Level

Beginner to Intermediate

IngredientsHardware RequirementsRaspberry Pi 28 GB microSD card (with Raspbian “Jessie")5 Amp power supplyUSB mouseUSB keyboardWiFi dongle (or old school ethernet cable)HDMI cableHDMI monitor (or TV) Service/Software RequirementsAn active account on IBM Bluemix (which requires an IBM ID). Bluemix gives users a free trial period.PrepareValidate your RasPi2 has Raspbian “Jessie" installed on the microSD cardTypically, Raspberry […]

Ingredients

Working knowledge of Linux

An internet connected workstation/laptop

**Shout out to IBMers Darin Tracy, Anthony Blount, Kevin Enright**

Step-by-step

  1. Ingredients

    Hardware Requirements

    • Raspberry Pi 2
    • 8 GB microSD card (with Raspbian “Jessie”)
    • 5 Amp power supply
    • USB mouse
    • USB keyboard
    • WiFi dongle (or old school ethernet cable)
    • HDMI cable
    • HDMI monitor (or TV)

     

    Service/Software Requirements

    An active account on IBM Bluemix (which requires an IBM ID). Bluemix gives users a free trial period.

  2. Prepare

    Validate your RasPi2 has Raspbian “Jessie” installed on the microSD card

    Typically, Raspberry Pi comes with NOOBs installed to help you install the default supported operating system of your choice. I think you are awesome enough to skip right to the goodness with Raspbian “Jessie”, which can be downloaded here: https://www.raspberrypi.org/downloads/raspbian/

    There have been many improvements since Raspbian “Wheezy” (an updated Python, easier WiFi setup among other things), and getting started with “Jessie” will make this recipe a lot easier to implement. If you are not sure how to load an OS onto a microSD, there is some pretty good resources out on the Internet. Here is one in particular that is nice: http://elinux.org/RPi_Easy_SD_Card_Setup. Basically, you will need a microSD card reader, and some simple software (such as Win32DiskImager for Windows). I also use SDFormatter for Windows to reformat my microSD card when I botch my Linux image with highly experimental stuff that requires me to wipe out my microSD card and start from a clean base Raspbian install.

     

    Plug it in, fire it up!

    Connect your USB mouse, USB keyboard, HDMI output (monitor or tv), network (cable or WiFi dongle), and insert the microSD card (with “Jessie”) into the appropriate slots on your RPi2.

    Plugin the power adapter to you RPi2…fire it up! (login: pi/raspberry)

  3. Install the IBM IoT Gateway Kit

    The next set of steps comes right from an IBM blog entry called “Setting up the Iot Kit” by Anthony Blount. Full credit to Anthony, Darin Tracy and Kevin Enright, my fellow IBMers for this blog entry and accompanying IoTGateway Kit assets…you guys, ROCK! I have made slight modifications for clarity, but the original entry can be found here:

     "Setting up the Iot Kit" (Anthony Blount)

    https://www.ibm.com/developerworks/community/blogs/cee6c09c-a315-4b04-ad14-57d6a60fa8bb/entry/setting_up_the_iot_kit?lang=en

     

    How To Install The IoT Kit

    For this guide, you will need to place some things in the home directory of the logged in user, which we will be assuming is pi. Keep in mind that you must have sudo privileges to complete this installation.

     

    To Install IoT Gateway Kit:

    From Github (recommended):

    Install Informix:
    You need the Informix Dynamic Server for ARM, which you can find at the following link. Please ensure you use this ARM6 copy of Informix, as ARM7 is not yet fully supported. On your internet connected Raspberry Pi 2, open a web browser and navigate to the Informix download:

    “Informix Developer Edition for Linux ARM v6 32 (Raspberry PI)”

    https://www-01.ibm.com/marketing/iwm/iwm/web/reg/pick.do?source=ifxids&S_TACT=109HF36W&lang=en_US

    Enter your ID and password, then select the version of Informix you'd like to download (choose the ARM6 Developer's Edition, called “IBM Informix Dynamic Server Developer Edition (Informix Developer Edition for Linux ARM v6 32 (Raspberry PI))”).

    Fill out the information, select I agree, and it will take you to the download page. Once your download has completed, create the following directory on your Raspberry Pi 2 /home/pi/iot-gateway-kit-depend , and place the Informix tar file in that directory.

     mkdir /home/pi/iot-gateway-kit-depend

    cd /home/pi/iot-gateway-kit-depend

    cp /home/pi/Downloads/ids.12.10.UC5DE.Linux-ARM6.tar .

     

    Install the IoT Gateway Kit:
    Switch to the directory containing iot-gateway-kit-depend (in this example, /home/pi ) and download the Iot Kit components from GitHub via the following commands:

     cd /home/pi/iot-gateway-kit-depend

    git clone https://github.com/IBM-IoT/iot-gateway-kit

    You should now have both directories iot-gateway-kit-depend and iot-gateway-kit in your working directory.Then run the iot_install script as user pi (do not use sudo), the script is found in the top level of the repository. The script will configure Informix and other utilities, and install Node.js. It will also install Node-RED and related components of the Iot Kit to the Informix home directory, which by default is /home/informix .

     . /home/pi/iot-gateway-kit/iot_install

    After installation, the Node-RED server will be up and running. You can access Node-RED by opening your browser and typing http://127.0.0.1:1880 in the address bar.

     

    At this point, your Raspberry Pi 2 will have the following installed: IBM Informix, Node-RED, and some really cool Zwave packages (if you should ever want to get a TI sensor tag talking to your RPi2). This is an interesting setup, because it effectively leverages your RPi2 as a gateway for one or more devices. You could use the RPi2 to consolidate, aggregate, or even perform some basic analytics or functionality **locally** before sending data to the IBM Watson IoT Platform public gateway and Bluemix. It's an interesting option, you don't have to use it, but an interesting application of an innovative way to use an RPi2.

  4. Connect your Raspberry Pi 2 to the Watson IoT Platform

    From your Bluemix application, click on the “Internet of Things” service.

    Under the “Connect your devices” section, click on “Launch dashboard”. This will take you to your IBM Watson IoT Platform organization space. This IoTF organization was setup when you added the “Internet of Things” service to your Bluemix application. This IoTF organization is as space used for connecting devices (like your RasPi2) to the IBM Watson IoT Platform gateway so that you can communicate with your Bluemix application.

    Register your Raspberry Pi 2

    Click the “Devices” tab.

    At the bottom of the screen, click “Add Device”.

    • Click on “Create Device Type” and specify a Name of “Raspberry Pi 2”. Click “Next” on the lower right corner of the screen.
    • Click “Next” all the way through the next set of screens, until you get to the “Create” option on the lower right corner of the screen.

    At the bottom of the screen, click “Add Device”.

    • Select the “Raspberry Pi 2” device type you just created.
    • Enter a unique device id, which will distinguish your Raspberry Pi 2 from all other devices that you might connect to the IoTF (you can use “1” or something more sophisticated like your RPi2's mac address).
    • Click “Next” all the way through the next set of screens, until you get to the “Create” option on the lower right corner of the screen. You should now see your device registered in your Device tab.

     

    Validate your Bluemix Access (API Key/API Token)

    When you created your Bluemix application with the IoT Boilerplate and specifically, the “Internet of Things” Bluemix service, an important link was made between your Bluemix application and the IBM Watson IoT Platform.

    Validate your secure connection from Bluemix to IBM Watson IoT Platform

    From your Bluemix application, on the “Internet of Things” service, expand the “Show Credentials” pane. Note, the “apiKey” field.
    Under the “Connect your devices” section, click on “Launch dashboard”. This will take you to your IIBM Watson IoT Platform organization space.

    Click on the “Access” tab

    Click on the “Bluemix Apps” tab.

    You should see see 1 entry that matches with the “apiKey” field that you just saw in your Bluemix “Internet of Things” Service credentials pane. This is the linkage between your Bluemix app and your IoTF organization. For simplicity, this was abstracted from you when you created your Bluemix application and added the “Internet of Things” service.

    Just as an FYI, if you wanted to have your device connect to your IBM Watson IoT Platform organization, without using Bluemix, you could use the “Access” > “API Keys” tab to generate an API Key and Token, that your devices could use too.

     

     

  5. Create an

    You can sign up and register devices to an IBM Watson IoT Platform organization by using IBM Bluemix. Note: To register your devices using IBM Bluemix, you must first create a Bluemix account.

     

    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.
    • Use the Internet of Things Platform Starter boilerplate from the Catalog to try out a sample Node-RED flow.
    • To register devices, you must first create an IoTF organization. To do this, create an instance of the Internet of Things Platform Service, which is found by scrolling to the Internet of Things section of the Catalog in Bluemix. When you have added the service, select it in your dashboard to open the service page.
  6. Create a Node-RED flow

    Create a Node-RED flow in your Bluemix application

    This will create a simple workflow so that your Bluemix application will read incoming messages from the IBM Watson IoT Platform and echo a message to the debug tab in your Node-RED workflow editor (on t

    1. Logon to Bluemix and select your IoT application.

    he right panel).

    1. Towards the top of your Bluemix dashboard, click the “Routes:” URL to access your Node-RED workflow editor.
    2. Click the red button “Go to your Node-RED flow editor”
    3. Click the “+” to add a new work flow, called “Sheet 2”.
    4. From the “Input” section on the left palette, choose the “ibmiot” node and drag/drop into the workflow editor.
      1. Double click the “ibmiot” node:
      2. For the “Authentication” drop down choose “Bluemix Service”
      3. For “Input Type” choose “Device Event”
      4. Click “Ok”
    5. From the “Output” section on the left palette, choose the “debug” node and drag/drop into the workflow editor, to the right of the “ibmiot” node.
      1. Double click the “debug” node:
      2. For the “Output” drop down choose “complete msg object”
      3. For “to” choose “debug tab”
      4. Click “Ok”
    6. Using your cursor, left click from the “ibmiot” node and draw a connector to the “output” node.
    7. On the extreme right side of the “msg” node, click the grey box, so that it is now green. This will ensure that the debug message will appear in the debug tab.
    8. Click the red “Deploy” button in the upper right hand corner.

     

    Create a Node-RED flow on your Raspberry Pi 2

    This will create a simple workflow so that your Raspberry Pi 2 will generate messages to the IBM Watson IoT Platform and your Bluemix application Node-RED flow will handle a message sent from your RPi2.

    1. Logon to your Raspberry Pi 2 Node-RED application
    2. Open any web browser, and go to http://<raspberrypi_ip>:1880/#
    3. Click the “+” to add a new work flow, called “Sheet 1”.
    4. From the “Input” section on the left palette, choose the “inject” node and drag/drop into the workflow editor.
      1. Double click the “inject” node:
      2. For the “Payload” drop down choose “string” and below it, type “1”
      3. Click “Ok”
    5. From the “Output” section on the left palette, choose the “debug” node and drag/drop into the workflow editor, to the right of the “inject” node.
      1. Double click the “debug” node:
      2. For the “Output” drop down choose “complete msg object”
      3. For “to” choose “debug tab”
      4. Click “Ok”
    6. From the “Output” section on the left palette, choose the “ibmiot” node and drag/drop into the workflow editor, to the right of the “inject” node.
      1. Double click the “ibmiot” node:
      2. For the “Authentication” drop down choose “API Key”
      3. For the “API Key” drop down choose “Add new iotiot…” and click the edit pencil
        • For the “Name” type “IoTF”
        • For the “API Key” type, copy/paste the “apiKey” field from your Bluemix application, on the “Internet of Things” service, expand the “Show Credentials” pane
        • For the “API Token” type, copy/paste the “apiToken” field from your Bluemix application, on the “Internet of Things” service, expand the “Show Credentials” pane.
        • Click “Add”
    7. Continue with the “ibmiot” out node, for the “Output Type” drop down choose “Device Event”
      1. For “Device Type” type “RaspberryPi2” (this should exactly match the Device Type you created for your device in IoTF)
      2. For “Device Id” type “1” (this should exactly match the unique Device Id you created for your device in IoTF)
      3. For “Event Type” type “on”
      4. For “format” type “json”
      5. For “data” type “1”
      6. Click “Ok”
    8. Using your cursor, left click from the “inject” node and draw a connector to the “msg” node.
    9. Using your cursor, left click from the “inject” node and draw a connector to the “ibmiot” node.
    10. On the extreme right side of the “msg” node, click the grey box, so that it is now green. This will ensure that the debug message will appear in the debug tab.
    11. Click the red “Deploy” button in the upper right hand corner.
  7. Send a message from your RPi2 to your Bluemix IoT Application

    1. Logon to your Raspberry Pi 2 Node-RED application
    2. Open any web browser, and go to http://<raspberrypi_ip>:1880/#
    3. Click the “Sheet 1” tab
    4. On the extreme left side of the “inject” node, click the grey box, so that it is now green. This will ensure that the inject message will appear in the debug tab also.

     

    1. Logon to Bluemix and select your IoT application.
    2. Towards the top of your Bluemix dashboard, click the “Routes:” URL to access your Node-RED workflow editor
    3. Click the red button “Go to your Node-RED flow editor”
    4. Click the “Sheet 2” tab
    5. On the “Debug” tab to the right, your message originating from your RPi2 should appear in the debug tab.

9 comments on"Raspberry Pi 2 + Watson IoT Platform + Bluemix + Informix"

  1. Small error in Install the IoT Gateway Kit:
    git clone https://github.com/IBM-IoT/iot-gatway-kit should be ../iot-gateway-kit

  2. Recipes@IoTF February 13, 2016

    Nice recipe !!

    Do you mind linking this recipe – https://developer.ibm.com/recipes/tutorials/how-to-register-devices-in-ibm-iot-foundation/ that shows how one can create the IoT Organization and register devices in it?

  3. can you name the exact place i put the informix file? it’s really giving me fits:/

  4. it keeps saying no file found in depend and to move it to depend and press any key. can someone please respond?

  5. im having some serious problems installing informix
    can anyone give me a hand?

  6. the download link is for solaris. that’s why it wouldn’t install correctly. someone needs to fix this recipe.

  7. […] Raspberry Pi 2 + IoT Foundation + Bluemix + Informix […]

Join The Discussion