Connect a Raspberry Pi to IBM Watson IoT Platform

to deploy the flow in Node-RED and observe that the readings are printed in the console.

Device configuration file org = yourOrganizationCode type = iotsample-raspberrypi id = b827eba84426 auth-method = token auth-token = yourAuthToken End of Configuration file

As a next step, go through the following recipes that will help you to create an end to end IoT solution,

The logs in this sample are done using the syslog. You can find the logs in the /var/log/syslog.

Create a simple flow to start receiving the device events

And for the command, the code is present in rebooting the PI

1.8.2017, 18:31:21node: da9634e9.dcc13iot-2/type/RbpIoT/id/ID/evt/status/fmt/json : msg.payload : Object

Now Im in Node Red and if I go back to the dashboard API Keys – I see only the key , but not the authentication Token !

[ res = publishMQTTMessage(&client, publishTopic, json); ] returns a 0 and eventually -3 but not for a very long time.

I see things like Device Id, Device Type, API Key, etc but not the Authentication Method ?

The command implementation is on the same function. ?

Use a Raspberry Pi to connect to IBM Watson IoT Platform. Then you can visualize the data generated by the Raspberry Pi

At this step, we have successfully created the Watson IoT service and registered your device(s) in it.

In this step, we have successfully configured the IBM IoT App In Node to receive the Raspberry Pi events from the Watson IoT Platform.

password using the tokens generated when adding a device on WIoTP

Where is the Authentication Method in the dashboard ? I am unable to figure it out ?

Unpacking iot (1.0-1) over (1.0-1)

Changing it to multiple lines got the iot process back running.

Access the NodeRED application to receive events from the device

But I have a little bit of off-topic question:

Yes. You would need to add -lwiringPi in the compile step of the Makefile.

Just one more thing, I can see where you are sending data to Node-Red, the cpustat.c. However, where are you checking the command that is received?

Please let us know if you have any questions.

Found this error once i going to run this command

dpkg: dependency problems prevent configuration of iot:

Go throughConnect your device as Gateway to Watson IoT Platformrecipe to connect your gateway and devices behind the Gateway to IBM Watson IoT Platform

Please let us know if you have any questions.

Register your Device In Watson IoT Platform

Send commands to your Raspberry Pi device

authentication. Set the Device Type, Device Id fields appropriately. Set the

Preparing to unpack iot_1.0-2_armhf.deb

out node from the output pane and configure it to use

When I click the trigger, I get the same Error as above: Syntax error: Unexpected token d

This IoT Recipe makes use of theCreate Toolchainbutton to help deploy the necessary services on to Bluemix. Click on theCreate Toolchainbutton provided below, provide a custom name to your application and choose to click on Create button, to quickly deploy the Watson IoT Platform Node-RED Bluemix starter app. Post successful deployment, you shall have both the above mentioned services, up & running on Bluemix along with a Cloudant NoSQL DB at your disposal.

I have got my Pi working with this recipe, but how do I stop it from sending the sensor information (d.myName, d.cputemp, etc.) every second? I had another Pi added awhile back and it is still in the device list but it isnt sending this information every second, but I dont remember what I did to it to get it to stop sending this information.

Refer toConfiguring Boards & Cards in the new Watson IoT Dashboardrecipe to view the Raspberry Pi events in Watson IoT Platform using the boards and cards.

As shown the above payload instructs the sample to wait for 3 seconds and reboot the device.

Create Gauges for visualizing physical quantities like Vehicle Speed, Temperature, pressure

Package libssl1.0.0 is not installed.

2. Minimim 8GB SD card with Rasbian operating system


iot depends on libssl1.0.0 (= 1.0.0); however:

curl: (23) Failed writing body (0 != 16384)

The flow should look like the following,

dpkg: dependency problems prevent configuration of iot:

Errors were encountered while processing:

Preparing to unpack iot_1.0-2_armhf.deb

Can I get some help on the Command Support section how do I do it ? is there some programming that I have to do.

Create visualization charts for the real time data from your devices

Is it required ? If I open the NodeRed It does not ask for it.

Note: All the properties in the configuration file are mandatory. Currently, only token based authentication is supported.

Carry out thesteps present in this recipeto register your device(s) in IBM Watson Internet of Things Platform.

Connect your Raspberry Pi to IBM Watson IoT Platform in simple steps and visualize the data generated by the Pi in Watson IoT Platform dashboard. Also, you can use a NodeRED application to receive events and send commands back to the device.

Visualize the Raspberry Pi events in Watson IoT Platform dashboard

Could you please help on how to install the dependencies.

if I would like to develop my own Watson application where to start?

Connect yourRaspberry Pito the internet. Ensure you are able to reach (Ping) and connect to it.

fill in the configuration file with the details that you copied when registering the device.

How can I retrieve the Authentication Token once I have generated the API Key.

Find the MAC address of your Raspberry Pi by running the following service command:

I click on Generate API Key, then I get a API KEY and the token . I click on OK.

The workspace contains some nodes that are not properly configured:

To explore and make use of full capabilities of Watson IoT Platform, we need to setup and register your device(s) in it. This section shows how you can setup the same.

I was hoping it will download some code ?

Unpacking iot (1.0-1) over (1.0-1)

Please let us know if you have any questions.

[] ability to launch branded kits from enterprise partners (no Raspberry Pi kit yet) shows a commitment to establishing a strong connection to best position AWS IoT cloud as a []

With the new boards and cards capability in the Watson Internet of Things platform, you can build your own Custom dashboardwithout writing any code. You can use the boards as the landing page of interest and then make use of the cards within them to:

and configure the payload as follows

Access the Node-RED application in Bluemix

This sample supports the Reboot Command. When the user sends this command, the Raspberry Pi will reboot based on the seconds provided in the payload.

Next, Im in the Dashboard. and in Download and extract your starter code to set up your development environment.

just few mouse clicks. There is no coding involved.

We have tried it from our end, it usually takes a minute or 2 to notice the network is not connected. It depends on the network stack of your linux. When MQTTClient gets the message that the network is not connected, MQTTAsync_isConnected will return false and the reconnect logic will kick in. This code will take care of reconnect logic as well. So as soon as the client becomes disconnected, it will try to reconnect.

The installer is available at the source code is available at In case you want to change the default behavior, you can modify the code and build it.

In this blog, the contents of the device.cfg are listed in a single line. Seems the sudo service iot start does not like it, and keeps failing when I restarted it.

More precisely, the reboot is implemented in line 126

iot depends on libssl1.0.0 (= 1.0.0); however:

Recipes are community-created content. They are neither monitored nor endorsed by IBM. If you find inappropriate content, please useReport Abuseto let us know. For more information on community content, please refer to ourTerms of Use.

Hi, I tried to download the installer from Github but my raspberry pi shows Warning: Failed to create the file iot_1.0-2_armhf.deb: Permission denied

The iot process starts and publishes events to theIBM Watson IoT Platform Quickstart. The process runs as a system service, and starts whenever Raspberry Pi starts. To verify the process is running, use the command:

Say if I want the raspberry pi to do something other than reboot.

Package libssl1.0.0:armhf is not configured yet.

If you want to understand to how to send a command to the raspberry pi, you can refer this recipe which sends a command using Node-RED.

So, I broke it up into multiple lines and started the iot process, and now the iot process is running.

In this step, we saw how to send a command to the device to control it using a Node-RED application.

dpkg: error processing package iot (install):

Create Donuts charts, bar charts to display the current value of the data points

This function is called when a command is received in Raspberry Pi. So then it parses the json to get the time for reboot and then uses it to reboot the device.

dpkg: error processing package iot (install):

button in Pre-requisites section. Access your Node-RED application by clicking on

You have deployed the Node-RED service on to the Bluemix by clicking on the

Im using the Raspberry Pi 2, wheezy v 4.1.13. What version are you running and are you using ether or a Wifi Dongle? Also is there any documentation on what is actually performed when calling MQTTAsync_isConnected? And by reconnect logic does this mean youre making calls to the network stack to try and restart a particular network interface or is it just the reconnect logic that I see in the sample C code.

Processing triggers for systemd (232-25+deb9u1)

Note: If you are aUserusing theUnited Kingdom Regionin your Bluemix environment, then please make use of the steps mentioned in the IoT RecipeDeploy Internet of Things Platform Starter service on Bluemixto deploy the setup. Alternatively, you can also try using theDeploy to Bluemixbutton, to deploy the setup under yourUnited Kingdom Region, provided your Jazzhub account is validated.Users of US South Region can ignore this step.

Open the Bluemix Dashboard and click on the Application service that you have currently deployed (using theCreate Toolchainbutton), if you have already moved away from it. You should see the Watson IoT Platform listed under the Connections. Click on the WIoTP service and choose the click on Launch button to launch the WIoTP Dashboard.

Yes we can use this with wiring Pi. This is a sample and can be extended with wiring Pi.

I have a raspberry Pi that is generating data in json format. I have created the iot device in Watson IoT Platform but still showing the device disconnected. No data from msg.payload in node-red application.

When I disconnect ether/wifi it takes up to +15min for this example to notice its not connected anymore. any ideas why?

Watson IoT Platform Registered connection

I think, the following needs to be done in Python to connect to a device registered on Watson IoT platform. However, the connection never goes through; keeps failing as Connection reset by peer. So, what do I need to do to make the connection happen from a Pi to the WIoTP?

Is this iot service a essential component, or just an example program? Im a bit confused because I cannot get the device ID without installing it in my Raspberry Pi. However, after the registration, it just keep sending test events and I have no way to change its behavior.

Where or how do I send the commands ?

which means I have to regenerate it again and save it somewhere. I wished the Authentication Token was also visible when I clicked on the API Keys, in the dashboard.

Hello, where exactly is the code for logging and command?

I think you might be referring to a Bluemix related question? If you visit the IoT forum and post a question someone from the team will help you

During the device registration process you will get file configuration information containing the following details, copy these when you get them.

Please let us know if you have any more questions.

I have tried with in Raspberry Pi B. But I feel the functionality must be almost same in Pi2 as well. I have tried with ethernet and WiFi.

But this issue occurs because the library still does not get the correct code from the interface that the connection has been lost.

The iot service has been started on pi and device.cfg configured as well.

Watson IoT Platform Quickstart connection

1. Raspberry Pi Model B/ Model B+/ 2

When you add a device to your IoT Foundation organisation you get your device credentials, which you need to put onto the device to connect it to your organisation. For example

Processing triggers for systemd (215-17+deb8u7)

Go throughConfigure Cloudant NoSQL DB as Historian Data Storage for IBM Watson IoTto store your device events in Cloudant NoSQL DB

<ername_pw_set(use-auth-token,password)< p=””> </ername_pw_set(use-auth-token,password)<>

Any help will be appreciated. Thanks!

sudo nano /etc/iotsample-raspberrypi/device.cfg

Real-time data analytics in Watson IoT Platform Showcases how to create rules and actions to monitor assets in real-time with

I am following the steps for Send Commands to your Raspberry Pi Device and getting an error for the Trigger Reboot node Syntax error: Unexpected token d in the payload. Also, if I write the payload as delay : 3, there is no error but my Raspberry Pi doesnt reboot. Can anyone suggest a solution?

See the Data and storage consumption of your devices

Vikki Thanks for the responses above, I got past that.

field to match the type you used to register your device with. Leave the

List of registered devices and etc..

node to the IBM IoT node as shown below to output the datapoints in the debug panel.

Hmmm, what changes need to be done to include the wiringPi library? Must be something with Makefile.

And in the debug section I receive every second a message like this :

Thanks Kiran. Ran into the same issue myself. Your solution fixed it.

If I click the above link to download It goes to this page

Considering that youve only mentioned develop my own watson application, and there isnt any specification on the Industry, Technology and nature of deployment, Ill take the luxury of suggesting the following link to get started, which shall help you further drill down your need and come up with your application:

The API key authentication tokens are non recoverable for security reasons, this is stated at the time of creation.

It appears [ if (!MQTTAsync_isConnected(client)) ] does nothing once it has connected for the first time.

<nnect()< p=””> </nnect()<>

45 comments onConnect a Raspberry Pi to IBM Watson IoT Platform

When the Raspberry Pi Sample is running in registered mode, it supports the receipt of Commands sent by an Application.

This sample uses the open source Paho client libraries to make the MQTT calls. So the documentation for the isConnected can be found in The reconnect logic is in the sample code. The logic is present just in the code, and it does not make calls to the network interface.

mqttc = mqtt.Client(client_id=d:orgId:deviceType:deviceName)

You can stop the iot process with the following command:

The iot service is not an essential component and is just an example program. The device Id could be any id as long as its unique in a given Bluemix organization. What the iot service does is provides the MAC Address of the Raspberry Pi.

Connect a Raspberry Pi to IBM Watson IoT Platform

Errors were encountered while processing:

Go throughHow to connect Raspberry Pi as managed device to Watson IoT Platformto take advantage of device management capabilities present in Watson IoT Platform

Parallelly, you can also access the Node-RED editor directly by accessing the following URL

With events now being sent to Watson IoT, the next step is to access the application in Bluemix to receive the events.

Real-time visualization of device data

Very informative post. I also using raspberry pi stater kit and I bought it some days ago from But I dont have idea to install this with my system. This post helps me a lot. Can you give some other reference regarding installations. It helps me a lot. Thanks.

Get your Device and Bluemix setup ready

Leave a Comment