Skill Level: Any Skill Level

This recipe will help you connect TE Connectivity digital sensors on a Raspberry Pi , send measures using MQTT protocol on IBM Watson Platform and display measurements with Bluemix application


For this reciepe you need :

  • A Raspberry Pi 2 or 3 with the latest official Debian image running
  • A TE Connectivity Pi Weather Shield
  • A Bluemix account with organization and space



  1. Create an Internet of Things Platform Starter Application


    • Now select Internet of Things Platform


    • Click the Create button


    Now you've got your instance

  2. Connect to Watson Plateform

    • Click on Lauch Dashboard


    • You will be¬†redirected to the IBM Watson Plateform


    Observe that a new Organization is created where you can add, connect and manage IoT devices.

    At this step, we have successfully created the IBM Watson IoT Platform organization.

  3. Configure Watson Plateform

    Add device type

    Each device connected to the IBM Watson IoT Platform is associated with a device type. Device types are intended to be groups of devices which share common characteristics. So in order to add devices in IBM Watson IoT Platform, one need to create a device type. Following are the instructions for creating a Device Type.

    • Go back to the IBM Watson IoT Platform dashboard, click Devices tab, device types tab, then click on the Create Type button as shown below

    • Click on Create device type

    • Specify a name for the device type to be added and optionally a description as shown below and click next


    Observe that a template page is given where you can select and define one or more attributes. All of these attributes are optional. They will be used as a template for new devices that are assigned this device type. Attributes that you do not define may still be edited individually later when you add the device. You can define one or more attributes by selecting them and clicking Next as shown below

    • Define the selected attributes Manufacturer and Model as shown below, then click next

    • ¬†Observe that a new device type is added in the IBM Watson IoT Platform Organization

    We have successfully created a device type in IBM Watson IoT Platform organization.




    Add device

    A device can be defined that has a connection to the internet and has data it wants to get into the cloud. And devices can accept commands from applications as well. You need to add the device in IBM Watson IoT Platform Organization before connecting it to the IoT. Carry out the following steps to add the device in IBM Watson IoT Platform


    • In the IBM Watson IoT Platform dashboard, click Browse tab and then Add Device button as shown below

    • Choose the device type ‚ÄúRaspberryPi‚ÄĚ that we created in the last step, then click Next


    • Enter a unique device id, which will distinguish your device from all other devices that you might connect to the IoT (you can use 1 or something more sophisticated like your devices MAC address, without “:”), then click Next as shown below. Also note that the values of ‚ÄúManufacturer‚ÄĚ and ‚ÄúModel‚ÄĚ attributes are populated from the device type ‚Äúiotsample-devicetype‚ÄĚ. These values can be overridden, attributes not set in the device type can be added as well


    • Add a Metadata and click next (it's optional)
    • Click on next, the token will be generated automatically
    • As shown below, you will be given a summary page to verify the details before adding the device to IBM Watson IoT Platform. Verify and click Add
    • At this step, the device is registered to your Organization and you will be provided with the registration details as marked below. To get your device connected, you need to add the credentials to your device.

    Conserve the Device Crentials because you will not be able to retrieve this information later !!


    • ¬†Click the cross button to get back to the main dashboard and observe that the device is added in your Organization



    Now we have successfully added a device in the IBM Watson IoT Platform organization.


    Generate API Keys

    To give external applications (i.e., the Node-RED application described later) access to your organization, you need to generate API access key/token pairs. Once pair in enough for this demo. To do so, follow these steps:

    • In Watson IoT Platform dashboard, select Access from the left pane, select API Keys and click on +Generate API Keys

    • A window appear with the API Key and the Authentification Token

    Like the Device Crentials, you need to conserve this information since you won't be able to recover it later !


    The first step is finish you have all informations to connect your Raspberry PI to Bluemix.

  4. Raspberry Pi setup

    • Open a terminal session on your Raspberry Pi (though SSH or directly from the Pi)
    • Install pip
    sudo apt-get install python-pip
    • Install the IBM IoT and Pi Weather Shield pip packages
    sudo pip install ibmiotf
    sudo pip install pi-weather-shield
    git clone
    cd piweathershield-ibm-watson-iot-python
    • Create the device configuration file
    cp sample-device.cfg mydevice.cfg
    nano mydevice.cfg
    • You can now run the software for this device
    python -v -c mydevice.cfg

    The software will measure all the sensors and push their data to the IBM Cloud every seconds

  5. Node -RED GUI installation


    • Provide an app name¬†at your convenience and Deploy
    • The deployment can take several minutes


    • Once successful you can “View Your App”


    • This will open the Node-RED application in your brower


    • You can now click on¬†Go to your Node-RED flow editor
  6. Node -RED GUI configuration

    • Node-RED comes with a pre-configured flow for the Raspberry Pi Weather Shield


    • Note that the IBM IoT provider is disconnected from our Raspberry Pi


    • We will now need to connect it to our Raspberry Pi
    • Double on the IBM IoT to configure it


    • Select Authentication with API Key then¬†Add¬†Aew ibmiot



    • Insert the API Key and API Token you previously generated



    • Finally, specify your Device Type, Device Id and Event



    • You can now Deploy your flow



    • And visualize it through the dashboard tab



    • ¬†Enjoy your live data visualization !


Join The Discussion