Overview

Skill Level: Any Skill Level

PrepareGet Debian Linux for your BeagleBone (if you have BeagleBone Black rev C, you already have Debian and can skip this step). You can install Debian Linux on a Micro SD card and boot the BeagleBone from there. For downloading Debian Linux and booting from a Micro SD card, see http://beagleboard.org/latest-images.With Debian Linux running, connect […]

Ingredients

  • BeagleBone Black
  • TI SensorTag CC2541
  • Bluetooth Low Energy (type 4) USB adaptor to connect the SensorTag to the BeagleBone

Step-by-step

  1. Prepare

    1. Get Debian Linux for your BeagleBone (if you have BeagleBone Black rev C, you already have Debian and can skip this step). You can install Debian Linux on a Micro SD card and boot the BeagleBone from there. For downloading Debian Linux and booting from a Micro SD card, see http://beagleboard.org/latest-images.
    2. With Debian Linux running, connect your BeagleBone to a Windows, Mac, or Linux computer using the supplied USB cable. If you are using Windows or a Mac, you need to install some drivers to access your BeagleBone; see http://beagleboard.org/Getting Started.
    3. Run SSH on your computer and log in to the BeagleBone: ssh root@192.168.7.2
    4. Connect your SensorTag to your BeagleBone. Insert the USB BLE adaptor into the BeagleBone USB socket.
    5. Connect your BeagleBone to the Internet.
  2. Connecting to the IBM Watson IoT Platform Quickstart Service

    1. In your BeagleBone SSH window, clone the GitHub project: git clone http://github.com/ibm-messaging/iot-beaglebone
    2. Enter the command: cd iot-beaglebone/samples/nodejs
    3. Run the sample by entering: ./setup.sh.
      • This installs required node packages – async, sensortag, properties, MQTT – using npm.
    4. Now run the sample with: node iot_sensortag.js
      • This sample runs in the foreground and will need to be restarted if the connection is lost of the SensorTag disconnects.
    5. Press the button on the side of the SensorTag, it will now start sending sensor data to the IBM Watson IoT Platform.
    6. The sample will display the MAC address needed for the Quickstart site on the console.
    7. When messages are being sent, the LED 3 (close to the ethernet socket) with flash once per message.
  3. Visualizing your data

    1. Take the MAC address from the previous step, and remove all colons, and ensure all the letters are lowercase. This forms the device ID of your device.
    2. Enter your device ID here.
  4. Register your Device In Watson IoT Platform

    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.

    Carry out the steps present in this recipe to register your device(s) in IBM Watson Internet of Things Platform.

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

  5. Connecting to the IBM Watson IoT Platform Registered Service

    1. Once you have access to an IBM Watson IoT Platform organization through Bluemix or the Marketplace, you can click to ‘Add a new device’ on the IoT organization dashboard.
    2. During the device registration process you will get device properties, copy these when you get them. They will look like this:
      org=xyzzyztype=iotsample-ti-bbstid=01c7ca014599auth-method=tokenauth-token=ijeifwiefiweff@
    3. Run SSH on your computer and log in to the BeagleBone: ssh root@192.168.7.2
    4. Enter command: cd ~/iot-beaglebone/samples/nodejs
    5. Stop the script if it’s running (ctrl-C).
    6. Create a new file called device.cfg using nano device.cfg
    7. Paste the properties into the editor.
    8. Exit nano and save (Ctrl-X, y).
    9. Restart the script with node iot-sensortag.js
  6. Command Support

    Now the BeagleBone and SensorTag Sample is running in registered mode and supports receiving of commands sent by an application.

    1. The script responds to commands from the blink command-id. This makes LED 0 blink at a fixed rate.
    2. You can write an application which sends the payload { “rate”: 2 } to the topic iot-2/type/iotsample-ti-bbst/id//evt/blink/fmt/json
    3. The numeric value is the rate in blinks per second. A value of 0 will stop the LED blinking.
    4. The script may be used as a starting point for your own work. You can make direct modifications to the script on the BeagleBone platform using nano, vi or your favorite editor. You are, of course, welcome to fork the repository at https://github.com/ibm-messaging/iot-beaglebone

Join The Discussion