Professional Documents
Culture Documents
Get Started With Watson Iot Platform - Hello World!!!
Get Started With Watson Iot Platform - Hello World!!!
Get Started With Watson Iot Platform - Hello World!!!
Recently we had a lot of request in support on How to Get Started with Watson IoT
Platform or on how to send a simple Hello World!!! message via the Watson IoT
Platform. There are uncountable resources out there that can help you with this
topic, but sometimes not everything is clear enough or easy, therefore I hope that
this article will help get started as easy as possible.
There are many ways to accomplish this and Ill try to cover some of them.
Resources? This is what Ill be using for starters
1. One piece of Centos 7 VM
2. Latest ibmiotf libraries (as this moment they are on 0.2.4 level)
3. Python 2.7.5 (using this version as it is shipped with Centos 7)
Perquisites: In order to install the ibmiotf libraries you need to have install pip.
Install pip
1. Download it from here
https://pip.pypa.io/en/stable/installing/
Use: wget https://bootstrap.pypa.io/get-pip.py
2. Install pip
Use: python get-pip.py
Install ibmiotf libraries
1. pip install ibmiotf
If you see this at the end the it means that it was installed successfully:
Successfully installed ibmiotf-0.2.4 iso8601-0.1.11 paho-mqtt-1.2 pytz2016.6.1 requests-2.11.1
As you can see, it automatically installed other necessary packages.
Now, you should be all setup to connect to the Watson IoT Platform.
As guiding you can follow:
Python for application developers
https://newconsole.ng.bluemix.net/docs/services/IoT/applications/libraries/python.html
Deploy and IoT Starter application
Getting started with Watson IoT Platform Starter
https://new-console.ng.bluemix.net/docs/starters/IoT/iot500.html
This will help you further to get an application id and deploy a Node-Red instance
that we use in this scenario.
ibmiotf
sys
ibmiotf.application
ibmiotf.device
time
options = {
"org":"xxxxx", //this is Organization ID
"id":"MyApp", //this Application ID
"auth-method":"apikey", //this is the authentication mechanism
"auth-key":" x-xxxxx-xxxxxxxxxxxx", //this is the API Key
"auth-token":" xxxxxxxxxxxxxxxxxxxx"//this is the Authentication Token
}
//connect to the Watson IoT Platform
try:
appClient = ibmiotf.application.Client(options)
appClient.connect()
except ibmiotf.ConnectionException as e:
print(str(e))
sys.exit()
Deploy the flow in Node- Red and you can run the script to publish the message. You
should be able to see in the debug tab of the Node-Red the: Hello World!
message.
Hope this will help you to get started and stay tuned for many more articles of this
type.