IoT

Raspberry Pi as managed device to IBM Watson IoT Platform

In my previous post I connected a Raspberry Pi to IBM Watson IoT platform now I’m going to show a Raspberry Pi as managed device to IBM Watson IoT Platform

I my first prototype I used the Quickstart connection to connect the device to platform and the steps are very very simple. To explore and make use of full capabilities of Watson IoT Platform it is necessary to register and to setup the device. You can read this article about how to register the device in IBM Watson Internet of Things Platform. When you register a device you can send commands to Raspberry device, for example you can reboot the device. To do this you can use a node-RED flow with the IBMIoT node.

The IBMIoT node is an “inject” node and where you can configure the event type and the data that contains the json format of a command, to reboot in a second the Raspberry the command is  “{“d”:{“reboot”:1}}”.

An another way to send command to an IoT device is by the device management feature. The device management feature enhances the IBM Watson IoT Platform service with new capabilities for managing devices. For example for Raspberry Pi by the IoT platform you can use this feature to:

  • Firmware Update
  • Device Reboot
  • Location Update
  • Diagnostic update

You can read the complete  documentation for detailed information about IBM Watson IoT Platform device management capabilities.

The managed devices have to contain a management agent which can understand the Internet of Things Foundation Device Management Protocol, and send a Manage Device request to the IoT Foundation Device Management server.

The Device Management Protocol defines a set of supported operations. A device management agent can support a subset of the operations, but the Manage device and Unmanage device operations must be supported. A device supporting firmware action operations must also support observation.

The Device Management Protocol is built on top of MQTT. In my Raspberry I installed the Java Client Library for IBM Watson IoT Platform .

In order to become a managed device you can follow these steps:

  • connect by ssh you Raspberry Pi
  • clone the IBM iot-device-samples project using git clone:
git clone https://github.com/ibm-messaging/iot-device-samples.git
  • run the maven build:
run sudo apt-get install maven

cd iot-device-samples\java\device-management-sample

mvn clean package
  • Modify the DMDeviceSample.properties file present under target/classes directory structure by entering your device information and registration details like Organization ID, Device Type, Device ID, Authentication Method and Authentication Token
## connectivity parameters
Organization-ID = <Your Organization ID>
Device-Type = <Your Device Type>
Device-ID = <Your Device ID>
Authentication-Method = token
Authentication-Token = <Your Device Token>

Run the Device Management sample agent by specifying the following command:

mvn exec:java -Dexec.mainClass="com.ibm.iotf.sample.devicemgmt.device.SampleRasPiDMAgent"

Observe that the device connects to IBM Watson IoT Platform and lists down various device management operations that the sample agent can perform.

  • type “manage” with an optional lifetime parameter (in seconds) to become a managed device:
    manage 3600
Raspberry Pi as managed device to IBM Watson IoT Platform
Raspberry Pi is connected as Managed device now

Now in action menu you can initiate an action:

Raspberry Pi as managed device to IBM Watson IoT Platform
IoT Platform actions for device managed

and you can reboot you device 🙂

Raspberry Pi as device managed
Raspberry Pi as device managed

Your Feedback is Welcome.

 

 

 

Related Articles

Back to top button