Create an Internet of Things Platform Starter Application
- Connect to IBM Bluemix : https://console.ng.bluemix.net
- Select Internet of Things and hit the¬†+¬†button
- Now select Internet of Things Platform
- Click the Create button
Now you've got your instance
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.
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.
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.
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
- Checkout the demonstration source code from TE Connectivity GitHub example
git clone https://github.com/TEConnectivity/piweathershield-ibm-watson-iot-python.git
- Create the device configuration file
cp sample-device.cfg mydevice.cfg
- You can now run the software for this device
python ibm-watson-iot-demo.py -v -c mydevice.cfg
The software will measure all the sensors and push their data to the IBM Cloud every seconds
Node -RED GUI installation
- Open the TE Connectivity Github Node-RED¬†started¬†and deploy it to Bluemix
- 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
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 !