1 2 3 Previous Next

BeagleBone Black

82 posts

In some previous posts, I first set up Bluetooth on the Beaglebone Black and then set up Node-Red to convert the Bluetooth data to MQTT messages. In this third post, I'll be using OpenHAB to receive the MQTT messages, process them and use them for notifications, trending, etc ...






The installation of Java and OpenHAB is already covered in detail in one of my posts here on element14. The post can be found here: [AirCare] InTheAir - Week 5: openHAB and MQTT

In order to use OpenHAB with the SensorTag, different items, sitemap, rules, etc ... will be created though. You'll find them in the next paragraphs.






From Node-RED, all data is being published to the same topic, so in OpenHAB a master item has been defined to subscribe to the appropriate topic.

Other items have been defined in addition to the master item. They will be assigned with values parsed from the master item, categorising the data in different types such as temperature, humidity, buttons, etc ...


The items file contains the following:


debian@beaglebone:~$ cat /opt/openhab/configurations/items/sensortag.items

Group All

String SensorTag "SensorTag Raw Data [%s]" <sensortag> (All) {mqtt="<[eclipseIot:fvan-sensortag:state:default]"}

Number SensorTag_Temperature_Ambient "SensorTag Ambient Temperature [%.1f °C]" <sensortag> (All)
String SensorTag_Temperature_Object "SensorTag Object Temperature [%s °C]" <sensortag> (All)
String SensorTag_Humidity "SensorTag Humidity [%s %%RH]" <sensortag> (All)
String SensorTag_Pressure "SensorTag Pressure [%s hPa]" <sensortag> (All)
String SensorTag_Keys_1 "SensorTag Key #1 [MAP(bool.map):%s]" <sensortag> (All)
String SensorTag_Keys_2 "SensorTag Key #2 [MAP(bool.map):%s]" <sensortag> (All)

Number Chart_Period "Chart Period"


The screenshot below demonstrates the initial tests, comparing Node-RED's output to OpenHAB's input. A limiter was set in place to prevent flooding of data, limiting to 6 messages per minute per sensor used.

Screen Shot 2015-07-17 at 21.14.59.png




The sitemaps file is used to arrange the different items visually, in certain (sub)categories, even including charts. In this example, a chart has been defined for the ambient temperature item, with three possible display periods: hour, day, week.


debian@beaglebone:~$ cat /opt/openhab/configurations/sitemaps/sensortag.sitemap

sitemap sensortag label="SensorTag" {
        Frame {
                Text item=SensorTag
        Frame {
                Text item=SensorTag_Temperature_Ambient {
                        Frame {
                                Text item=SensorTag_Temperature_Ambient
                        Frame {
                                Switch item=Chart_Period label="Chart Period" mappings=[0="Hour", 1="Day", 2="Week"]
                                Chart item=SensorTag_Temperature_Ambient period=h refresh=10000 visibility=[Chart_Period==0, Chart_Period=="Uninitialized"]
                                Chart item=SensorTag_Temperature_Ambient period=D refresh=10000 visibility=[Chart_Period==1]
                                Chart item=SensorTag_Temperature_Ambient period=W refresh=10000 visibility=[Chart_Period==2]
                Text item=SensorTag_Temperature_Object
                Text item=SensorTag_Pressure
                Text item=SensorTag_Humidity
                Text item=SensorTag_Keys_1
                Text item=SensorTag_Keys_2


The result is the following:

Screen Shot 2015-07-20 at 11.14.40.png




Rules can be used to trigger actions based on certain events. In this particular case, two rules have been defined:

  • Categorise data
  • Temperature alarm


The first rule is triggered when the master item defined in the items file is updated to a new value. The rule then parses the content in order to categorise it and assign the contents to the item representing the correct sensor. Using some simple string operations, the useful content is extracted from the incoming data.


The second rule demonstrates the use of notifications using Prowl. For testing purposes, I have a notification triggered when the temperature is lower than 50°C. Obviously, this would need to be set to more realistic values, but it is a quick way of verifying the notification mechanism works.


To know more about notifications in OpenHAB using Prowl, be sure to check out the following post: http://www.element14.com/community/community/design-challenges/forget-me-not/blog/2014/10/20/cats-forgetmenot--final#jiv…


debian@beaglebone:~$ cat /opt/openhab/configurations/rules/sensortag.rules

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Math
import java.lang.Double
import java.lang.String

var Timer temperature_alarm = null

rule "Categorise data"
        Item SensorTag changed
        var state = SensorTag.state.toString()
        var output = ""

        if(state.contains("ambient")) {
                output = state.substring(state.indexOf('"ambient":')+10,state.indexOf('}'))

                output = state.substring(state.indexOf('"object":')+9,state.indexOf(','))
        else if(state.contains("pressure")) {
                output = state.substring(state.indexOf(':')+1,state.indexOf('}'))
        else if(state.contains("humidity")) {
                output = state.substring(state.indexOf('"humidity":')+11,state.indexOf('}'))
        else if(state.contains("right")) {
                output = state.substring(state.indexOf('"right":')+8,state.indexOf('}'))

                output = state.substring(state.indexOf('"left":')+7,state.indexOf(','))

rule "Temperature alarm"
        Item SensorTag_Temperature_Ambient changed
        var state = SensorTag_Temperature_Ambient.state as DecimalType

        if(state < 50.0) {
                if(temperature_alarm == null) {
                        pushNotification("<api key>","Ambient temperature", "too low: " + state)
                        temperature_alarm = createTimer(now.plusMinutes(1)) [|
                                temperature_alarm = null


Here's a screenshot demonstrating the data being categorised properly:

Screen Shot 2015-09-12 at 12.42.15.png


And some screenshot of the notifications being received on my phone:





It is also possible to transform the data in the visualisation layer of OpenHAB. For example, the buttons return a true/false state. More meaningful would be to have the state reported as pressed or released.

By creating a bool.map file in the transform folder and reference it in the items file, this can be done quickly. The file contains one translation per line. In the GUI, "true" will be replaced by "pressed" and "false" by "released". The "-=-" is there to avoid OpenHAB reporting translation errors when no data has been received yet.


debian@beaglebone:~$ cat /opt/openhab/configurations/transform/bool.map





Finally, persistence is what defines which data to store and with which type of storage (MySQL, RRD4J, ...). Persistence is required when using charts.


debian@beaglebone:~$ cat /opt/openhab/configurations/persistence/rrd4j.persist

Strategies {
        everyMinute : "0 * * * * ?"
        everyHour : "0 0 * * * ?"
        everyDay : "0 0 0 * * ?"

        default = everyChange

Items {
        * : strategy = everyChange, everyMinute, restoreOnStartup





This concludes this short series of post on how to retrieve data from a SensorTag via Bluetooth, convert it to MQTT using Node-RED and persist/monitor/trend it using OpenHAB.

This week's embedded.fm episode features Jason of BB:


110: Happiness Is a Warm Puppy — Embedded

In my previous post, I was able to retrieve data from the SensorTag 2.0 on the Beaglebone Black using command line tools such as "hcitool" and "gatttool". For this post, I'll be setting up Node-RED to collect the SensorTag data automatically and make it available for other applications to process or store.




What is Node-RED? Node-RED is a tool used to wire together different devices, APIs or online service in a visual way. The website is located at http://nodered.org/and contains a wealth of information on how to install and use Node-RED on different operating systems and devices.

Install Node-RED


Node-RED requires Node.js to be installed. Fortunately for me, this is the case by default on the Beaglebone Black. Just to be sure, I tried to install Node.js using "apt-get".


debian@beaglebone:~$ sudo apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version.
nodejs set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


As expected, Node.js is already installed and is even reported to be at the latest version. Installing Node-RED is very easy and only takes a couple of minutes. The command can be found on the Node-RED website: http://nodered.org/docs/getting-started/installation.html


debian@beaglebone:~$ sudo npm install -g --unsafe-perm node-red


Once installed, Node-RED can be run using the "node-red-pi" command. This will start the application, which can then be accessed using a webbrowser at http://device_ip:1880/.


debian@beaglebone:~$ node-red-pi

Welcome to Node-RED

15 Jul 19:45:03 - [info] Node-RED version: v0.11.1
15 Jul 19:45:03 - [info] Node.js version: v0.10.25
15 Jul 19:45:03 - [info] Loading palette nodes
15 Jul 19:45:12 - [warn] ------------------------------------------
15 Jul 19:45:12 - [warn] Failed to register 1 node type
15 Jul 19:45:12 - [warn] Run with -v for details
15 Jul 19:45:12 - [warn] ------------------------------------------
15 Jul 19:45:12 - [info] Settings file : /usr/local/lib/node_modules/node-red/settings.js
15 Jul 19:45:12 - [info] User directory : /home/debian/.node-red
15 Jul 19:45:12 - [info] Flows file : /home/debian/.node-red/flows_beaglebone.json
15 Jul 19:45:13 - [info] Server now running at
15 Jul 19:45:13 - [info] Creating new flow file
15 Jul 19:45:13 - [info] Starting flows
15 Jul 19:45:13 - [info] Started flows


Screen Shot 2015-07-15 at 19.45.55.png


Install node-sensortag


In order to have support for the TI SensorTag in Node-RED, a new node needs to be installed. Before being able to install it though, it is required to have the bluetooth development files installed first.

More information on the SensorTag node can be found on its GitHub page: https://github.com/sandeepmistry/node-sensortag.


debian@beaglebone:~/.node-red$ sudo apt-get install libbluetooth-dev


Once done, it should be possible to install the SensorTag node without issues.


debian@beaglebone:~$ cd ~/.node-red
debian@beaglebone:~/.node-red$ sudo npm install sensortag


When that is installed, Node-RED has to be run as "root" or with "sudo"in order to access the Bluetooth system calls. And because Node-RED is run as a different user, it is recommended to specify the path to the user directory where the SensorTag node was installed.


debian@beaglebone:~$ sudo node-red-pi -u /home/debian/.node-red/

Welcome to Node-RED

15 Jul 20:14:27 - [info] Node-RED version: v0.11.1
15 Jul 20:14:27 - [info] Node.js version: v0.10.25
15 Jul 20:14:27 - [info] Loading palette nodes
15 Jul 20:14:37 - [warn] ------------------------------------------
15 Jul 20:14:37 - [warn] Failed to register 1 node type
15 Jul 20:14:37 - [warn] Run with -v for details
15 Jul 20:14:37 - [warn] ------------------------------------------
15 Jul 20:14:37 - [info] Settings file : /usr/local/lib/node_modules/node-red/settings.js
15 Jul 20:14:37 - [info] User directory : /home/debian/.node-red
15 Jul 20:14:37 - [info] Flows file : /home/debian/.node-red/flows_beaglebone.json
15 Jul 20:14:37 - [info] Server now running at
15 Jul 20:14:37 - [info] Creating new flow file
15 Jul 20:14:38 - [info] Starting flows
15 Jul 20:14:38 - [info] Started flows


The SensorTag node should be available in the Node-RED GUI.

Screen Shot 2015-07-15 at 20.15.18.png



As a first test, I connected the SensorTag node directly to a debug output. This allowed me to confirm the Bluetooth connection between the SensorTag and the Beaglebone Black was properly set up without any manual intervention and that Node-RED was able to capture the data.


Screen Shot 2015-07-15 at 20.48.38.pngScreen Shot 2015-07-15 at 20.57.09.png


I started with a few parameters, tested a bit, and then enabled the others. As you may be able to see from the screenshots above, all that was required to set it up was to:

  • drag the necessary nodes in the sheet, in this case: sensortag & debug
  • enter the MAC address of the sensortag
  • select which parameters to report on
  • press the "deploy" button in the top right corner


It doesn't get any more simple than this! You can see the debug data in the column on the right.


After a successful first test, I added a second, more useful output: MQTT. This allows me to publish the SensorTag data to a MQTT broker and topic of my choice. Adding the MQTT output is simple:

  • drag the MQTT node in the sheet
  • connect it to the SensorTag node
  • configure a broker and topic
  • deploy

Screen Shot 2015-07-16 at 19.47.13.pngScreen Shot 2015-07-16 at 20.10.39.png

Using MQTTLens, I was able to subscribe to the topic and visualise the published data. It works! This is of course only a very simple example meant to demonstrate some basic features, and does not take any security into account, as all the data is just published on the internet for anyone to see. So keep that in mind if you plan to try this out.

In my next post, I'll be collecting the data to build historical data that can be used for trending, processing, ... Until then!

This post is part of my RoadTest review for the TI CC2650STK SimpleLink IoT SensorTag. As I plan to use the BeagleBone Black for data collection, I thought I'd blog about how to get BLE to work on it first.

photo (22).JPGphoto+1.JPG

Here we go ...


Preparing the BBB


Before we jump to setting up BLE on the BBB, we require an operational BBB with internet connection. The full setup of the BBB using Debian can be found in one of my earlier posts: [AirCare] InTheAir - Week 2: Preparing the Beaglebone Black


It covers the following topics:

  • preparing the SD card with Debian
  • expanding the filesystem, making use of the full SD card's available space
  • setting up network connectivity using wifi
  • connect a touchscreen display


Setting up Bluetooth




I hadn't use my BBB for a while before setting up the bluetooth, so the first thing I did was to update the software.


debian@beaglebone:~$ sudo apt-get update
debian@beaglebone:~$ sudo apt-get upgrade




Once the BBB's software was up-to-date, I installed the bluetooth software.


debian@beaglebone:~$ sudo apt-get install bluetooth


This resulted in a lot of packages being installed, for a total of 144MB of additional disk space.


The following extra packages will be installed:
  bc bluez bluez-alsa bluez-cups bluez-gstreamer cups cups-client cups-common cups-filters cups-ppdc dc fonts-droid fonts-freefont-ttf foomatic-db-compressed-ppds foomatic-db-engine foomatic-filters ghostscript ghostscript-cups hpijs hplip hplip-data libart-2.0-2
  libcupscgi1 libcupsdriver1 libcupsfilters1 libcupsimage2 libcupsmime1 libcupsppdc1 libescpr1 libgs9 libgs9-common libgutenprint2 libhpmud0 libijs-0.35 libjbig2dec0 liblcms1 libpaper-utils libpaper1 libpoppler19 libsane-hpaio libsensors4 libslp1 libsnmp-base libsnmp15
  mscompress poppler-data poppler-utils printer-driver-all printer-driver-c2050 printer-driver-c2esp printer-driver-cjet printer-driver-escpr printer-driver-foo2zjs printer-driver-gutenprint printer-driver-hpcups printer-driver-hpijs printer-driver-m2300w
  printer-driver-min12xxw printer-driver-pnm2ppa printer-driver-postscript-hp printer-driver-ptouch printer-driver-pxljr printer-driver-sag-gdi printer-driver-splix python-imaging python-pexpect python-renderpm python-reportlab python-reportlab-accel samba-common
  samba-common-bin smbclient ttf-freefont
Suggested packages:
  cups-bsd cups-pdf xpp hplip-cups openprinting-ppds cjet foomatic-db-gutenprint ghostscript-x hplip-gui hplip-doc system-config-printer gutenprint-locales liblcms-utils lm-sensors slpd openslp-doc snmp-mibs-downloader fonts-japanese-mincho fonts-ipafont-mincho
  fonts-japanese-gothic fonts-ipafont-gothic fonts-arphic-ukai fonts-arphic-uming fonts-unfonts-core psutils hannah-foo2zjs tk8.4 tix gutenprint-doc hpijs-ppds magicfilter apsfilter python-imaging-doc python-imaging-dbg python-renderpm-dbg pdf-viewer
  python-egenix-mxtexttools python-reportlab-doc cifs-utils
Recommended packages:
The following NEW packages will be installed:
  bc bluetooth bluez bluez-alsa bluez-cups bluez-gstreamer cups cups-client cups-common cups-filters cups-ppdc dc fonts-droid fonts-freefont-ttf foomatic-db-compressed-ppds foomatic-db-engine foomatic-filters ghostscript ghostscript-cups hpijs hplip hplip-data
  libart-2.0-2 libcupscgi1 libcupsdriver1 libcupsfilters1 libcupsimage2 libcupsmime1 libcupsppdc1 libescpr1 libgs9 libgs9-common libgutenprint2 libhpmud0 libijs-0.35 libjbig2dec0 liblcms1 libpaper-utils libpaper1 libpoppler19 libsane-hpaio libsensors4 libslp1
  libsnmp-base libsnmp15 mscompress poppler-data poppler-utils printer-driver-all printer-driver-c2050 printer-driver-c2esp printer-driver-cjet printer-driver-escpr printer-driver-foo2zjs printer-driver-gutenprint printer-driver-hpcups printer-driver-hpijs
  printer-driver-m2300w printer-driver-min12xxw printer-driver-pnm2ppa printer-driver-postscript-hp printer-driver-ptouch printer-driver-pxljr printer-driver-sag-gdi printer-driver-splix python-imaging python-pexpect python-renderpm python-reportlab
  python-reportlab-accel samba-common samba-common-bin smbclient ttf-freefont
0 upgraded, 74 newly installed, 0 to remove and 0 not upgraded.
Need to get 47.8 MB of archives.
After this operation, 144 MB of additional disk space will be used.
Do you want to continue [Y/n]? y




I got myself a cheap BT dongle from Trust, paying special attention to support for Bluetooth 4.0 (BLE).

photo (21).JPG


Plugged in the dongle in the BBB's USB port and check if the device was detected properly. If you have more than one USB device to connect, you may need a powered USB HUB to connect them all simultaneously.


debian@beaglebone:~$ lsusb
Bus 001 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub




With the software installed and the dongle plugged it, it's time to look at the software tools used to get some data from the SensorTag.




hcitool is used to configure Bluetooth connections and send some special command to Bluetooth devices.


First, check hcitool detects your bluetooth dongle.


debian@beaglebone:~$ sudo hcitool dev
  hci0 00:1A:7D:DA:71:0F


Perform a scan to find out the SensorTag's address.


debian@beaglebone:~$ sudo hcitool lescan
LE Scan ...
B0:B4:48:B8:23:01 (unknown)
B0:B4:48:B8:23:01 CC2650 SensorTag


Create connection to SensorTag, using previously scanned address.


debian@beaglebone:~$ sudo hcitool lecc B0:B4:48:B8:23:01
Connection handle 69




gatttool is a tool used to interact with BLE devices.


Use gatttool in interactive mode to send commands to the previously scanned address.


debian@beaglebone:~$ sudo gatttool -b B0:B4:48:B8:23:01 -I
[  ][B0:B4:48:B8:23:01][LE]>


Connect to the SensorTag, notice how the prefix changes from "[  ]" to "[CON]".


[  ][B0:B4:48:B8:23:01][LE]> connect


Request the characteristics of the device.


[CON][B0:B4:48:B8:23:01][LE]> characteristics
handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0006, char properties: 0x02, char value handle: 0x0007, uuid: 00002a04-0000-1000-8000-00805f9b34fb
handle: 0x0009, char properties: 0x20, char value handle: 0x000a, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x000d, char properties: 0x02, char value handle: 0x000e, uuid: 00002a23-0000-1000-8000-00805f9b34fb
handle: 0x000f, char properties: 0x02, char value handle: 0x0010, uuid: 00002a24-0000-1000-8000-00805f9b34fb
handle: 0x0011, char properties: 0x02, char value handle: 0x0012, uuid: 00002a25-0000-1000-8000-00805f9b34fb
handle: 0x0013, char properties: 0x02, char value handle: 0x0014, uuid: 00002a26-0000-1000-8000-00805f9b34fb
handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a27-0000-1000-8000-00805f9b34fb
handle: 0x0017, char properties: 0x02, char value handle: 0x0018, uuid: 00002a28-0000-1000-8000-00805f9b34fb
handle: 0x0019, char properties: 0x02, char value handle: 0x001a, uuid: 00002a29-0000-1000-8000-00805f9b34fb
handle: 0x001b, char properties: 0x02, char value handle: 0x001c, uuid: 00002a2a-0000-1000-8000-00805f9b34fb
handle: 0x001d, char properties: 0x02, char value handle: 0x001e, uuid: 00002a50-0000-1000-8000-00805f9b34fb
handle: 0x0020, char properties: 0x12, char value handle: 0x0021, uuid: f000aa01-0451-4000-b000-000000000000
handle: 0x0023, char properties: 0x0a, char value handle: 0x0024, uuid: f000aa02-0451-4000-b000-000000000000
handle: 0x0025, char properties: 0x0a, char value handle: 0x0026, uuid: f000aa03-0451-4000-b000-000000000000
handle: 0x0028, char properties: 0x12, char value handle: 0x0029, uuid: f000aa21-0451-4000-b000-000000000000
handle: 0x002b, char properties: 0x0a, char value handle: 0x002c, uuid: f000aa22-0451-4000-b000-000000000000
handle: 0x002d, char properties: 0x0a, char value handle: 0x002e, uuid: f000aa23-0451-4000-b000-000000000000
handle: 0x0030, char properties: 0x12, char value handle: 0x0031, uuid: f000aa41-0451-4000-b000-000000000000
handle: 0x0033, char properties: 0x0a, char value handle: 0x0034, uuid: f000aa42-0451-4000-b000-000000000000
handle: 0x0035, char properties: 0x0a, char value handle: 0x0036, uuid: f000aa44-0451-4000-b000-000000000000
handle: 0x0038, char properties: 0x12, char value handle: 0x0039, uuid: f000aa81-0451-4000-b000-000000000000
handle: 0x003b, char properties: 0x0a, char value handle: 0x003c, uuid: f000aa82-0451-4000-b000-000000000000
handle: 0x003d, char properties: 0x0a, char value handle: 0x003e, uuid: f000aa83-0451-4000-b000-000000000000
handle: 0x0040, char properties: 0x12, char value handle: 0x0041, uuid: f000aa71-0451-4000-b000-000000000000
handle: 0x0043, char properties: 0x0a, char value handle: 0x0044, uuid: f000aa72-0451-4000-b000-000000000000
handle: 0x0045, char properties: 0x0a, char value handle: 0x0046, uuid: f000aa73-0451-4000-b000-000000000000
handle: 0x0048, char properties: 0x10, char value handle: 0x0049, uuid: 0000ffe1-0000-1000-8000-00805f9b34fb
handle: 0x004d, char properties: 0x0a, char value handle: 0x004e, uuid: f000aa65-0451-4000-b000-000000000000
handle: 0x004f, char properties: 0x0a, char value handle: 0x0050, uuid: f000aa66-0451-4000-b000-000000000000
handle: 0x0052, char properties: 0x1a, char value handle: 0x0053, uuid: f000ac01-0451-4000-b000-000000000000
handle: 0x0055, char properties: 0x0a, char value handle: 0x0056, uuid: f000ac02-0451-4000-b000-000000000000
handle: 0x0057, char properties: 0x0a, char value handle: 0x0058, uuid: f000ac03-0451-4000-b000-000000000000
handle: 0x005a, char properties: 0x12, char value handle: 0x005b, uuid: f000ccc1-0451-4000-b000-000000000000
handle: 0x005d, char properties: 0x08, char value handle: 0x005e, uuid: f000ccc2-0451-4000-b000-000000000000
handle: 0x005f, char properties: 0x08, char value handle: 0x0060, uuid: f000ccc3-0451-4000-b000-000000000000
handle: 0x0062, char properties: 0x1c, char value handle: 0x0063, uuid: f000ffc1-0451-4000-b000-000000000000
handle: 0x0066, char properties: 0x1c, char value handle: 0x0067, uuid: f000ffc2-0451-4000-b000-000000000000


Request the device name using the proper characteristic, by handle.


[CON][B0:B4:48:B8:23:01][LE]> char-read-hnd 0x3
Characteristic value/descriptor: 53 65 6e 73 6f 72 54 61 67 20 32 2e 30


The response is hexadecimal. To make it human readable, it needs to be converted to ASCII. This can be done using some command line magic.


debian@beaglebone:~$ echo -e $(echo -e " 53 65 6e 73 6f 72 54 61 67 20 32 2e 30" | sed 's/ /\\x/g') | awk '{printf "%s\n", $_}'
SensorTag 2.0


(The above command is probably far too complicated for what I'm trying to achieve, so if any command line wizard is reading this, please help improve my magic ...)


Or using Python for example.


debian@beaglebone:~$ python
Python 2.7.3 (default, Mar 14 2014, 17:55:54)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "53656e736f7254616720322e30".decode("hex")
'SensorTag 2.0'




There you have it, BLE on the BBB. I was able to connect to the SensorTag and retrieve it's name. Once I've identified the other characteristics, I'll be able to take in the data I want and keep a history of it.

Gorgeous black solder mask!

I have always wanted to get my hands on a BeagleBoneBlackBeagleBoneBlack (BBB), and it seems that I chose the right time to do so. It hasn't been long now since the new spin of the BeagleBoneBlack started shipping with Debian pre-installed onto the board's permanent eMMC storage. This was enabled through the upgrade in size, from 2GB to the current 4GB, of the on-board flash, which was done for a couple of reasons: first of all, 2GB isn't that much space. The Raspberry PiRaspberry Pi recommends at least a 4GB SD card, by comparison. Also, the supply of the 2GB eMMC chips was starting to fade – 4GB being the lowest offering currently, so the move was done to maintain supply as well. Remember, though, that storage is not an issue – you can add a 64GB SD card if you wanted! It's mostly the access time that is the major difference.


Originally, as many BBB owners will know, the BBB used a distribution of Linux known as Angstrom Linux – so named because of its small size and fast booting. A perfect match, it would seem, for a small single-board computer. However, with a large number of the maker community using Raspberry Pi, and having the Raspbian spin of Debian available, many felt underwhelmed by the default settings and GUI of Angstrom after picking up a BBB.


As soon as the Rev C version of the BBB became available, sales went through the roof – as many will remember, during parts of 2014 it was almost impossible to buy one. This was largely due to the fact that it now had enough space for the pre-installed Debian, plus the increased processor speed and RAM. The huge, dual 46-pin headers helped, too – compared to other single-board computers this size, it's hard to believe that you can have this many pins brought out for user applications!


Upon opening the box, I was immediately impressed with the board. I must admit, I'm a bit of a TI fanboy, so that helped – but the black solder mask and the rounded corners made it look sleek and sexy. I eagerly fired it up, and was impressed with the boot time into Debian – one of the effects of having the OS in eMMC memory. Everything just worked out of the box – SSH was set up, plugging the USB into my laptop revealed a serial terminal, a built-in web server (which we'll talk about in a bit!) and an emulated USB flash drive! Clearly this was designed with development in mind. Having a serial terminal over USB is a great move – though there is a serial header on board, you don't even need to use it! This can make a big difference in the ease of troubleshooting and/or development. If SSH is not an option, plugging it into USB means you can work on the board with literally no other connections – no monitor, keyboard, DC input, Wi-Fi, Ethernet, nothing. Just a single USB cable. Now that is how it should be done! This is even more critical as there is only one USB host port, meaning to have more than just a keyboard plugged in you need a USB hub. For most developers this isn't an issue, but it's annoying to Check out the huge headers!have this extra box hanging off of the board. I've found the best way to work with the BBB is to have it plugged into a laptop, with an Ethernet cable for internet access (if you have a cable nearby – otherwise, you can use the empty USB port for Wi-Fi!).


Now, the real question today is what the differences are between Angstrom Linux and Debian. For those familiar with Linux and its varieties, you'll know that Debian is one of the big names. With a huge user base and many excellent developers (not to mention being the distro that Ubuntu is based on!) Debian provides a smooth experience, with a wide choice of desktop environments to choose from and an enormous package repository. This is a plus for developers as your favourite IDE and compiler are likely available (in my case, Code::Blocks was, of course, immediately installable). However, the flair and large package assortment is also the weakness on a platform like the BBB. Remember that this is just a small ARMsmall ARM processor with 512MB of RAM. Though overall responsiveness is acceptable, there are times when the processor gets bogged down which make it feel completely sluggish and unusable. This is part of the reason I wanted to compare it to Angstrom. From what I'd heard, Angstrom was a much more bare-bones, stripped-down distro aimed at lightweight computing and development. It seems on paper like a much better choice for writing code and doing embedded development.


So it was off to the BeagleBone website to try and find the Angstrom flasher – I wanted to install Angstrom to the eMMC to have a fair comparison against Debian. As the BBB has now completely switched to Debian, the Angstrom images are listed under “Older Images”. I noticed there were both SD card and eMMC flasher versions. I downloaded the flasher version, and burned it to a freshly formatted SD card. Flashing the BBB (or even booting from the SD card) is supposed to be very simple – insert the SD card, remove power, hold down the BOOT button (S2, down by the SD card slot), and then power up the board while continuing to hold the BOOT button. If you're flashing Debian to the eMMC, you'll be rewarded by the LEDs flashing in a back-and-forth pattern. Once the process starts, it can take anywhere from 15 to 45 minutes to write the flash. However, be warned – when flashing Angstrom, there are no such LED indications to let you know you're on the right track. It actually boots into Angstrom while it flashes! This really confused me, and so I spent ages unplugging and replugging the power, holding down the BOOT button for as many different lengths of time as seemed reasonable, and formatting/re-burning the SD card five or six times. I even found two different versions of the eMMC burner, dated a few months apart in 2013. Eventually, I just left it running overnight at the command prompt, and when I tried to boot back into Debian the next morning, it booted into Angstrom without the SD card! So, clearly it had worked. You just need to be aware of how the burning process works!

Get hacking!


The first thing I noticed after booting into Angstrom is that it uses a non-standard package manager. As a long-time Linux user, I feel comfortable using pacman, yum, apt-get, even the lower-level stuff like RPM and DPKG. However, Angstrom uses opkg, a manager I hadn't heard of but seems to accept similar commands to yum and apt-get – things like opkg install, opkg update and opkg upgrade worked flawlessly. I highly recommend running those last two (update and upgrade) out of the box, as it seems there are a large number of updates not included in the last release available on the BeagleBone website.


To do our comparison testing, I'm going to be using a piece of software called the Phoronix Test Suite. This is an open software benchmarking application which is cross-platform and freely available! It also has a companion site called openbenchmarking.org which contains tons of pre-written tests that you can execute directly from the command line. Today, we'll be using two tests, one to test the hardware, and one to test the system. To test the hardware, we run a series of compression tests, which will stress the processor and give us a baseline. We shouldn't see too much of a difference, but the OS does indeed schedule tasks and give priority, so this will also test the system a bit as well. For the system testing, we'll encode audio in a variety of formats – this will also stress the processor, but according to what I've read it seems to be more of a system stress test as it really pushes the OS to see how well it manages tasks. For whatever reason, some of the tests wouldn't run on Debian, and some wouldn't run on Angstrom – I've marked these with DNR. This is almost certainly just a compatibility problem, as these tests were designed for full-size systems, in most cases. I've included the results of the same tests done on a Raspberry Pi Model B+ overclocked to 900MHz. This isn't a wholly fair comparison, but should give readers familiar with the Pi a sort of baseline with which to compare.


As you can see, the results are slightly mixed. Angstrom performed much better on the compression tests, but falls short on FLAC and MP3 encoding. I can't say this is exactly what I expected, although without knowing more about how the kernel is compiled for each distribution, my only theory is that Debian generally has more focus on multimedia applications, which gives it the slight edge in audio encoding. Angstrom is much lighter, which probably explains the compression test results being so varied.


Now that the BeagleBoneBlack comes pre-installed with Debian, I imagine that the vast majority of users will stick with it. However, after using both, I've started to take a liking to Angstrom. On some tasks it feels much snappier and responsive, though Debian's wider software support is also a plus. Angstrom's smaller installation size, the original reason the BBB developers chose it in the first place, is another plus if size becomes an issue. The older BBB revisions, will, of course, have to stay with Angstrom on the eMMC as they cannot hold Debian. You can still boot and run Debian from an SD card, so that option is there as well, though of course the performance won't be as good. My recommendation, especially to newer users, would be to stick with Debian unless you have a good reason to switch.


However, the real shocker was how poorly the Raspberry Pi performed in some categories! While it performed better at encoding FLAC and MP3, it fell apart in the compression category, with the exception of 7-Zip compression. I was really surprised that the LZMA compression was almost 400 seconds longer than the BBB with Angstrom! However, as I mentioned earlier, these two boards are for very different purposes, which is actually revealed through these tests. The Raspberry Pi is optimized for multimedia and GUI interaction, whereas the BBB is optimized for embedded software and hardware development. This is shown by the huge GPIO headers on the BeagleBoneBlack – 80 pins in total to the RPi's 40 on the B+ and only 26 on the original models.

Beautiful layout!


Whichever board you end up choosing, there are vast amounts of cool hardware add-ons and thousands of software libraries and tutorials available online. I highly recommend checking out both boards if you have the chance – you'll see that they fit their categories exceptionally well. The BeagleBoneBlack is the sort of device I would put into an autonomous robot. The Raspberry Pi could also be used, but the advantage of the huge GPIO and multiple hardware protocols is evident in such an application. The Raspberry Pi is the board of choice for projects like the Super Pi Boy – building a Pi into a Game Boy case, with an upgraded colour LCD and an SD card full of emulated games! The Pi's excellent multimedia support, coupled with the good support for touchscreens and LCDs, really shines through in such an application.


Thanks for reading, and stick around for more projects in the near future! Let me know below what projects you've used these boards for, and what your pros and cons for each would be.


All test results are measured in seconds!


BeagleBoneBlack with Debian









7-Zip Compress







Parallel BZIP2







GZIP Compress







LZMA Compress













































BeagleBoneBlack with Angstrom









7-Zip Compress







Parallel BZIP2







GZIP Compress







LZMA Compress














































Raspberry Pi Model B+ with Debian

Overclocked to 900MHz









7-Zip Compress







Parallel BZIP2







GZIP Compress







LZMA Compress













































Video Overview:


Flashing the BBB:

NASA Jet Propulsion Laboratory prototyped a new rover design with the BeagleBone Black!


"Testing a Space Rover Under Alaskan Ice"



Here's a screenshot of the BeagleBone:

Screenshot from 2015-06-15 16:40:18.png

Fixing the problems with the BBView and the latest Beaglebone Debian image.


So since the new Debian update for the Beaglebone some problems have surfaced with using the BBView. Here I hope to help people fix those errors and get full use of their BBView.


Not many steps, and it is very easy to do.


     1.    Firstly we need to download the newest Debian Image from Here http://beagleboard.org/latest-images

          Make sure you download the latest SD image (to boot from SD) or the flasher image (to reflash the EMMC with the new image)


     2.    Flash the image onto the SD card using your preferred means, dd command in linux /  win32DiskImager in windows are my preferred means.



     3.     Connect a an HDMI screen and keyboard, or or a TTL serial cable to the Beaglebone. If using the TTL cable you will also need a computer running a serial terminal program                (eg putty for windows)



     4.    Boot the Beaglebone Black from the new microSD card.

              Insert the microSD card.

               This will either boot the board from the microSD, or flash the new image onto the EMMC if you are using the flasher (This could take a while if using the flasher image)



     5.    When the board is booted, login using the username:root and password:debian



     6.     You will need some files to change the display output these files can be downloaded from HERE for Debian. Or from here.

               Just extract the downloaded zip file onto a USB stick and plug this into your Beaglebone Black



     7.    Now we need to change a few of the files to get the BBView to work

              In the terminal type....

root@beaglebone:~# mkdir /media/udisk
root@beaglebone:~# mount /dev/sda1 /media/udisk
root@beaglebone:~# cp -f /media/udisk/zImage /boot/vmlinuz-3.8.13-bone70 
root@beaglebone:~# cp -f /media/udisk/*.dtb  /boot/dtbs/3.8.13-bone70 
root@beaglebone:~# tar -xvf /media/udisk/kernel_modules.tar.gz -C /
root@beaglebone:~# cp -f /media/udisk/xorg.conf /etc/X11/
root@beaglebone:~# sync




root@beaglebone:~# cd /boot/dtbs/3.8.13-bone70
root@beaglebone:~# cp am335x-boneblack-lcd4.dtb am335x-boneblack.dtb
root@beaglebone:~# sync




root@beaglebone:~# cd /boot/dtbs/3.8.13-bone70
root@beaglebone:~# cp am335x-boneblack-lcd7.dtb am335x-boneblack.dtb
root@beaglebone:~# sync



     7.     Now shutdown your board. Connect your BBView and power it back up again.


Your BBView should now work as a screen for your Beaglebone Black. Have fun.


Make your own BeagleBot

Posted by callum.ds May 15, 2015

The BeagleBot


How to make your own Beaglebone black bot that you can control over WiFi.


So I've just done a project with the Beaglebone Black and I've managed to make a little robot car that can be controlled via WiFi from any browser on the same network.

Sounds cool, and it kind of is, but there's a lot that can be improved and changed. If any of you guys do improve it or add anything to it then please please please let me know even if it doesn't quite work, then maybe we can help you get it to work.


But first we need to build Bob (Yes, I named it)

BBB Bots almost finished.jpg


The Steps:





1. Get stuff (easy):

    Stuff we need (there's quite a bit)

Where to buyFarnell Order Codequantityproduct
cpc.farnell.comHK012091ROBOT KIT CHASSIS
uk.farnell.com243798124379811WIFI DONGLE
uk.farnell.com165068516506852BATTERY HOLDER, LEADED, 4 X AA
uk.farnell.com234525723452571Alkaline AA Batteries (any will do, get rechargeable if you prefer)
uk.farnell.com207536620753662Continuous rotation servos

PCB, RAW, 100X160

uk.farnell.com156468215646821Step-Down Voltage Regulator
uk.farnell.com247467524746751Prototyping Board
uk.farnell.com945108094510801100 µf radial capacitor
uk.farnell.com9451129945112911000 µf radial capacitor
uk.farnell.com120954612095461100µH inductor


You will also need.....

  • Soldering station (Soldering iron, heat mat, solder, and whatever PPE you need)
  • A bit of wire (some capable of taking up to 5V at 3A, and some thinner gauge just for controlling servos etc)
  • A few male to male and male to female jumper wires may also come in handy
  • pliers thin nosed
  • screwdriver (flat or philips)
  • super glue (be careful) or double sided tape
  • a bit of foam (or another way to hold the BBB and batteries in place and allow them to be removed)
  • duct tape or another way to attach the Beaglebone flap to the chassis
  • A sharp craft/Stanley knife (Be VERY careful when using this, get someone to help if you're not confident. And mind your fingers)



2. Build the chassis (very easy)


Get all the chassis stuff out, we're just using the main base platform, ball bearing at the back, and the wheels.


Use the bolts provided to screw the ball bearing wheel to the back of the chassis making sure the bolts go down so that they stick out the bottom and not stick out the top, or else we won't be able to fit our batteries in correctly.


Super glue/stick/attach the servos to the bottom of the chassis like the picture below

Then route the wires to the top. You may need to enlarge the hole to get the connectors through.....


Next we need to cut the flap for the Beaglebone Black to rest on. Measure out however big you want it (making sure the Beaglebone fits onto it with spare room for the foam) then score the PCB board down the line you want it to break, be very careful and use a cutting rule if possible. Keep scoring from both sides until almost through the board then carefully snap the board. If you don't have a cutting rule or you are not too confident with a craft/Stanley knife then use a hacksaw or similar.


Carefully stick the flap to the front of the chassis to create a hinge. that allows the flap to lift up and down so we can access the batteries later.


Now we can cut out the foam to fit the Beaglebone Black and the Batteries. Measure and outline the Beaglebone onto the foam then cut out the shape to make a Beaglebone sized hole in the foam then cut around the hole so all you're left with is an outline of foam which we can stick onto the flap.

Now repeat for the batteries.


Now we can stick/glue the foam onto the flap and chassis. Make sure the Beaglebone foam holder goes on the top of the flap and the battery holder goes right at the back of the chassis.



3. Soldering the Prototyping Board for the power connections (You WILL need some basic electronics knowledge and some previous soldering experience for this bit)

This bit is probably the hardest bit of the project because it's very fiddly and requires you to have at least a basic understanding of electronics.


Firstly get your protoboard and score it then snap it in half, then score and snap in half again the other way to get a quarter (scoring down the holes makes it easier to snap). This quarter is the bit we're going to use.


Now by carefully following the circuit diagram below solder all the components in place.

Circuit Diagram for the BeagleBot power board

The batteries need soldering in series.

On the DC jack the inner pin is positive and the outer metal shell is ground. Check you have the correct wires the correct way round before soldering or else you will blow your Beaglebone!

Also make sure the capacitor and diode polarisation is correct.


After checking the voltage insert the DC jack into the Beaglebone and wait for it to boot. Once successfully boot shut it down. Congratulations you now have a working battery powered Beaglebone.



4. Installing the packages on the Beaglebone (easy)

This bit is easy peasy.

Plug in and boot the Beaglebone.

Make sure you have internet connection either through Ethernet or WiFi.

Now install everything we need.

In the command terminal type the following lines.

sudo apt-get update
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus -y --force-yes --fix-missing
sudo pip install Adafruit_BBIO
sudo apt-get install apache2 php5 libapache2-mod-php5 -y --force-install --fix-missing
systemctl disable cloud9.service
systemctl disable gateone.service
systemctl disable bonescript.service
systemctl disable bonescript.socket
systemctl disable bonescript-autorun.service
systemctl disableavahi-daemon.service
systemctl disable gdm.service
systemctl disable mpd.service



5. Get the webserver running (fairly easy)

Now we need to get the webserver running.

First extract the .zip folder with the files in it onto a memory stick.

Insert the memory stick into the Beaglebone and reboot it.

In the terminal copy the files onto the board

sudo cp -R /media/<path_to_memory_stick>/www/* /var/www/
sudo chmod -R www-data:www-data /var/www

Now let's check that Apache is running on the correct port (port 80)

Use whichever editor you prefer, but here I'm using nano to make it simpler for beginner users

sudo nano /etc/apache2/ports.conf

Find the line related to listening ports, and make sure it is referring to port 80, change it if needed.

then press ctrl+x then y then enter to save the file.

then type

sudo service apache2 restart

to restart apache with the new settings


now we need to get the Beaglebone to connect to the wifi network.



6. Get the python script running (easy)

For this all we need to do is make sure the script is executable and make sure python can run it fine

in the terminal type

sudo chmod a+x /var/www/*.py
python2.7 /var/www/move_php.py

You should hopefully see the words

"Move_php script running..."

on your screen if it is worki

press Ctrl+C to stop python



7. Auto run the scripts we need running (easy)

For this we are going to use crontab, it is a service that runs in the background and is used to automate the running of tasks, exactly what we need.

In the terminal type

sudo crontab -e

In the crontab window add to the bottom the following lines

@reboot sudo service apache2 start
@reboot sudo python2.7 /var/www/move_php.py &

Notice the & sign at the end of the second line. This is very important, as it tells python to run in the background. If you do not include this then python will run in the foreground and prevent the boot sequence from continuing.

Now when we reboot apache2 should auto start and the python script should also run in the background. You can check this by rebooting your Beaglebone then in the terminal typing

ps -e | grep python

this should return a process I.D. for the python script running in the background


8. Assembling Bob (very easy, but can be fiddly)

This bit is very easy but can be a bit annoying to get perfect.

Place the Beaglebone in the foam holder on the flap, and the batteries in the foam holder at the back of the main chassis.

Route all the wires in a neat fashion to where the Beaglebone is on top of the flap.

Follow the picture in the zip file named BeagleBot_connections.png to connect everything (except the power) up to the correct pins, you may need to use jumper wires. If you don't have any jumper wires then you can simply cut the wires the connectors off of the wires you can't connect, strip them twist them and tin them, then you can insert them into the header on the BeagleBone.

Once everything is plugged in, tuck away/neaten up any wires hanging around the place until it looks neat and tidy. It might be a good idea to use electrical tape to hold wires down and out the way. At all costs prevent short-circuits.


9. Power (very easy)

Once your BeagleBot is ready to go, plug in the power and wait for it to boot. If you have not set up a static I.P from your router then you will need to connect to the Beaglebone during boot either by ssh over the wifi or via a serial cable to get the I.P. address.

Once you have the I.P address and your board is fully powered and not tethered to anything via a wire you are ready to go!


10. GO!! (fun)

Open up a browser window on any PC/phone/tablet that is connected to the same network as the BeagleBot and enter http://<I.P. of your BeagleBot>/move.php into the address bar.

Once the page is loaded tap the buttons to send your BeagleBot on its way.

Hello everyone,

I've been playing with the BeagleBone Black for a long time now.

If you're just getting started I've created a 4 part series on how to get started with the BeagleBone Black.


You can access the complete list of tutorials here: http://randomnerdtutorials.com/category/bbb-series/


Or you can choose a topic that interests you:


Thank you for reading and I hope you find this information useful.

If you have any questions feel free to ask and I'll try to help you.

Hi Guys ,


First of all Thanks a ton Element14 for sending one of the BeagleBone Black to test I recently have interfaced a 2.2" SPI LCD 240x320 To the Element14 Beagle Bone Black. Below is a Working demonstration of the Display in action



I also made a breakout board for the above featuring

1. Easy Plug and play capability (Modular design)

2. Easy UART Access using a Standard arduino mini FTDI module



Quick Observations,

1. The board is officially BeagleBone Black compliant !! Still No BeagleBone Black Logo is present on board ??

2. This board uses the Latest AM3358 Chip instead of AM3359 one on previous versions.

3. It is an Exact replica of the original BeagleBone Black, and works PREFECTLY.

4. Finally, By default the E14 BBB comes with Debian pre-installed, my old BBB 2G version came with Armstrong installed  


Thanks again to Element 14 for sending me a BeagleBone Black.

and please comment below if you want to know more.

Hi Everyone.


We are pleased to announce that Canonical has released Snappy Ubuntu Core-- and it's compatible with the BeagleBone Black! Running Snappy Core on smart devices delivers bullet-proof security, reliable updates and the enormous Ubuntu ecosystem at your fingertips – bringing your favorite cloud platform to a wide range of IoT devices and autonomous machines.


And the BeagleBone Black is one of the two key recommended ARM based development boards for this core! Over at Beagleboard.org, Jason Kridner says: “BeagleBone Black and Snappy Ubuntu Core together answer the pervasive questions around the Internet of Things, so I am obviously thrilled. Experts and developers often ask me how they can normalize their application environment and have confidence in the security of the system. With a reference design of Snappy on BeagleBone Black, Canonical and BeagleBoard.org have partnered to ensure anyone can build an IoT prototype quickly and affordable, without any barriers to taking their designs to production.”


Here are just some of the advantages developers get by using Snappy Core:


  • You can just package your IoT app like a mobile app and put it into an IoT app store
  • Transactional upgrades - you don't have to worry about handling complex stuff like patching operating systems, updating apps, rollback in case something goes wrong. Snappy Ubuntu Core does all of that for you.
  • Security, security, security! Android for IoT is just asking for viruses and trojans. Now transpose this to the Internet of Things: do you really want you house, work or city to be taken over by some mischievous hacker? We run each app in a secure container, and the operating system is mounted read-only.
  • Free to use and open source... of course.
  • 70% of penetration on the cloud. So you get a lot of stability on many familiar platforms. No more needing to learn a different operating system for each new platform, like wifi, TV, switch, robot, etc: One OS to rule them all.


Here are a couple of videos to help you get started with Snappy Ubuntu Core.


First, how to install and run Snappy on your BeagleBone Black:




Next, what Snappy Ubuntu Core means for smart devices running ARM or x86 processors:


Let us know what you think! And have fun getting into Snappy Ubuntu Core!


error logging password

Posted by vijuomp Jan 20, 2015

after i enable the bbb-view caps and i have remove flash drive after that again when i powered bbb then in putty when i logged it shows access deneid

For those of you who have been following along with my BeagleBone Black and Drupal series,  you could see this post coming. In my first installment I showed you how to build a website on the BeagleBone Black using the Drupal CMS, and followed it up with Controlling the BeagleBone Black's GPIO Pins with Drupal. This tutorial is going to take things a step further and show you how to take that knowledge, and use it to trigger some relays to turn mains powered electronics on and off. While the method I am going to use would not be ideal for conrtolling an entire home, it works quite well for controlling things like props in a haunted house and other low-amperage things like small fans, lights, and such. Just to make things easier, I am going to recap a good bit of my previous tutorial here. You will still need to go through the Drupal setup steps in the first tutorial though.




Prerequisites: What you need to know to be able to complete this project.

  • Understand how Drupal-based websites work.
  • Understand how PHP can be used to parse commands to the web server's terminal.
  • Understand the basics of how Transistors work, and why they should be used for applications like this.
  • Understand how the BeagleBone Black accesses its GPIO Pins.


Hardware Required: What hardware is needed to complete this project.

  • BeagleBone Black (Rev C recommended) BeagleBone Black (Rev C recommended) running the latest Debian image.
  • 5mm Green LED
  • 1x 460Ω 1/4w Resistor
  • 3x 3.3kΩ 1/4w Resistors
  • 3x 100Ω 1/4w Resistors
  • 3x 2n3904 General Purpose NPN Transistors
  • Female to Male Jumper Wires
  • Male to Male Jumper Wires
  • 5V Power Source for BeagleBone Black



Getting started: Building the discrete circuit and connecting to the Beaglebone Black.


Just like last time, we need to set up a transistor that will be used to supply the trigger voltage to the relay coils. The transistor circuit is needed because the BeagleBone Black is only able to supply about 8mAh to each of its GPIO pins and connecting something that draws more than 8mAh can damage the board's ARM chip. We can turn on a general-use PNP transistor with just a few mAh which will let us power the LED externally, and prevent any damage to the board. This is also handy for controlling relays and other components that can be triggered via the GPIO pins. Follow the diagram below to build the simple circuit. Instead of setting up the circuit to illuminate a LED, this time we will configure it to trigger the relay. We will be using a cheap 8-channel relay board to connecto to our circuit, so we will need a common ground, as well as two signal lines to the first two relays.




With the breadboard populated with our transistor circuits and connected to our BeagleBone Black, lets move onto the software side of things. We will come back and connect the relay board later in the tutorial.



Setting up the GPIO Pins in Debian: Using the terminal to configure specific GPIO pins in Debian.


To test the circuit we need to access our BeagleBone Black via SSH. I covered how to do this in the BeagleBone Black RSS News Reader tutorial, but will post it here as well.


To access the BeagleBone Black via SSH I will be using a terminal for Windows called Putty, as well as an add-on called MTPutty, which allows me to run multiple putty instances from within a single tabbed interface. Both Putty and MTPutty are available for free, and take just a few moments to download and install. Chances are, if you are reading this, you already know how to use Putty. If you are using a Mac you can simply use the built-in Terminal to access your Black Via SSH. To connect to your Black, you need to enter the following credentials.


With these settings configured, click ok and then double click the BeagleBone Black name in the server list. This will open up a new terminal tab and you will be prompted to enter a username. Unless you have modified the root user, you should enter root as the user name.




BeagleBone has made it easy here as there is no password and after entering the username, the connection will finish, and you will be placed in your "home" directory.



Now that you are SSHed into the BeagleBone Black we will need to prepare GPIO_67 (P8:08), GPIO_68 (P8:10), and GPIO_44 (P8:12) . The pinout diagram can be seen below.




Before we get started with testing, lets take a moment and talk about how the BeagleBone Black's GPIO pins are addressed by the Linux-based Debian operating system. The BeagleBone Black addresses its GPIO Pins by reading the contents of files which are located in the sys/class/gpio directory in the board's operating system. The most basic functionality is to write the pin high or low, and is what we will be doing in this tutorial.


To use a GPIO Pin you first need to tell Debian that you are going to use a particular pin in a specific GPIO header. The following code uses GPIO 8.8 as an example, but any GPIO Pin can be accessed by creating these files. Enter the following commands into the BeagleBone Black's terminal.


The first thing we need to do is create a few new directories in the /sys/class/gpio/sys/class/gpio directory.

echo 67 > /sys/class/gpio/export
echo 68 > /sys/class/gpio/export
echo 44 > /sys/class/gpio/export


At this point you will need to let the BeagleBone Black know whether or not the specified GPIO pins are input or output.

echo out > /sys/class/gpio/gpio67/direction
echo out > /sys/class/gpio/gpio68/direction
echo out > /sys/class/gpio/gpio44/direction


With this command, the BeagleBone Black no longer supplies 2.3V to the header and it is considered to be turned off. In order for us to set the GPIO Pins high or low we need to set their value to  either 1 or 0. We can do that with the following commands where the gpio# variable is set to the corresponding pin #. An example for gpio_67 is listed below.


Set the GPIO Pin High

echo 1 > /sys/class/gpio/gpio67/value


Set the GPIO Pin Low

echo 0 > /sys/class/gpio/gpio67/value


Remove control of the GPIO Pin when finished.

echo 67 > /sys/class/gpio/unexport


You will also need to chown and chmod the directory for each GPIO pin used. This can be done by entering the following commands.

chown -R www-data:www:data /sys/class/gpio/gpio67/value
chown -R www-data:www:data /sys/class/gpio/gpio68/value
chown -R www-data:www:data /sys/class/gpio/gpio44/value
chmod 777 /sys/class/gpio/gpio67/value
chmod 777 /sys/class/gpio/gpio68/value
chmod 777 /sys/class/gpio/gpio44/value


Testing The Circuit: Using the terminal to trigger the GPIO Pin.


With those basics out of our way, we can test out setup by turning the LED connected to GPIO_67 on and off. Connect a 9-volt battery to our breadboard and head back to the terminal window and follow the steps below to turn the LED on and off via the command line.




With everything connected, we should be able to use the command line to set GPIO Pin 67 high, which should in turn activate the transistor and allow the LED to light up.

Set the GPIO Pin High

echo 1 > /sys/class/gpio/gpio67/value


If everything was followed correctly, you will see the LED light up




Now set the GPIO Pin to low to turn off the circuit.

Set the GPIO Pin Low

echo 0 > /sys/class/gpio/gpio67/value



Setting up the Relay Board: Connecting the Relay Board to the BeagleBone Black.


If those commands worked, then everything is set up as expected. We can now connect the 8-channel relay board and test to see if it is working correctly. I'm using a cheap relay board I bought on Ebay a while back, but Newark and MCM Electronics both have several you can purchase. My board is quite simple and only requires a VCC input of 5V and a GND connection. Each relay has a trigger pin broken out, and these are where you will attach the GPIO pins via the transistor circuits we built earlier. Since my board only requires 5V to trigger the relay coils, I am going to power it from the BeagleBone Black. Generally this is frowned upon, but since I am only using two relays at once I am letting it slide. If you try triggering more than 2 relays at once, they could try to pull more current from the BeagleBone Black than it can supply and the relays will not trigger and the board could be damaged. If you plan on triggering all 8-relays I would suggest powering it with an external 5V 2amp power source. You could also use the 9-volt battery and a L7805 +5V Linear Voltage Regulator to trim 9-12V down to 5V. Follow the instructions below. I could not find my resistor assortment, and had to risk connecting the relays directly to the BeagleBone Black since they would only be used for the duration of this tutorial.




  • For this tutorial,  connect the two relays to the BeagleBone Black by connecting the VDD_5V (P9:05) pin to the relay boards VCC connection header.
  • Connect the BeagleBone Black's Ground DGND (P9:01) to the Relay Boards GND pin via the transistor circuit.


As I mentioned above, I could not find my resistors to complete the transistor circuits, so follow the directions below to connect the relays to the transistor circuits.


  • Connect the transistor that is connected to the  BeagleBone Black GPIO_68 (P8:10) pin to the relay 1 pin on the relay board.
  • Connect the transistor that is connected to the  BeagleBone Black GPIO_44 (P8:12) pin to the relay 2 pin on the relay board.


Now with those relays connected, its time to test that they work. Click back into the terminal and enter the following commands. If all is right, both relays should click on and off. Note that some relay boards are set as normally closed, and will appear to function the opposite you think they should. You will have to reverse the on and off commands for the relays to function correctly. This is as easy as swapping the 0 and 1 around in the code.


Turn Relay 1 on:

echo 0 > /sys/class/gpio/gpio67/value


Turn Relay 1 off:

echo 1 > /sys/class/gpio/gpio67/value


Turn Relay 2 on:

echo 0 > /sys/class/gpio/gpio67/value


Turn Relay 2 off:

echo 1 > /sys/class/gpio/gpio67/value


If they clicked on and off, then proceed to the next step. If they did not then repeat the process to see if you missed something.



Configuring the Drupal website: Adding the additional control buttons to the website.

With all of the hardware working its now time to configure the website that will let us control each relay as well as the LED remotely. Instead of writing 2000 more words and making this tutorial impossibly long, I have recorded another video to guide you through the configuration process. Check it out below and remember to subscribe to the channel if you like what I am trying to do!



When you get to the page creation phase, you can find the needed code examples pasted below.


LED Code:


Relay 1 Code:


Relay 2 Code:


With the website now configured, you should have a working remote automation system. You can use this to control a number of things such as lamps, irrigation systems, and even props in things like haunted houses, or film sets. I first designed this system to control a simple fog machine for my home on Halloween via my smartphone, but sadly the fog machine burnt out a week before the project was complete. So as you can see in the video below, I am using it to control a light bulb on my office desk. I plan on streamlining the system before next Halloween, and writing a few tutorials here on automation with the BeagleBone Black using triggers such as an Android app, motion sensors, and even pressure plates. If there is enough demand, I would consider turning it into a monthly series so leave me a comment if this is something you might like to see.


I have been working on an idea for my project. I am using my BBB to get the weather forecast and to let me know if I need to take an umbrella when I go out. (To be honest I don't use an umbrella but this is is for a "proof of concept" idea).


I am using python here to collect the forecast from Weather Underground, the api page is very helpful, and when I have the forecast as a json document I can extract the data I am looking for and do stuff with it. Currently I am displaying the weather forecast form my local area for the day that the program is being run and the next day. I have coded the place that I want the weather for into the string that makes up the URL, as my project is going to be setup per user I think that this is OK. See code below:


# program to grab the weather forecast from weather underground
# author Mark Venn
# based on code from "Getting Started with Raspberry Pi"
# currently collects the forecast for current day and next day. Lights an LED if the chances of rain are over 60%

# imports
import requests
import Adafruit_BBIO.GPIO as GPIO
import time

# configure GPIO pins


# wunderground api key

key = 'xxxxxxxxxxxxxxxx'

# build string using hard coded web address & api key variable
ApiUrl = 'http://api.wunderground.com/api/' + key + '/geolookup/forecast/q/UK/Bembridge.json'

while True:

    # get the weather forecast from wunderground and store in variable
    r = requests.get(ApiUrl)

    # take response and parse it into python dictionary object
    forecast = r.json

    # extract relevant data.
    # use variable to collect day of the week
    day = forecast['forecast']['txt_forecast']['forecastday'][0]['title']
    # display next day
    nextDay = forecast['forecast']['txt_forecast']['forecastday'][2]['title']

    # chance of rain
    rain = forecast['forecast']['txt_forecast']['forecastday'][0]['pop']
    rain = int(rain)

    # display current day
    print day

    #directly display the required info
    print forecast['forecast']['txt_forecast']['forecastday'][0]['fcttext']

    print nextDay
    # print rain

    #directly display the required info
    print forecast['forecast']['txt_forecast']['forecastday'][2]['fcttext']

    if rain >= 60:


# prints entire json document
#print forecast

The data I need for the forecast is held in fcttext in 2 key / value pairs and this is displayed.

root@beaglebone:~# python text_forecast_v3.py


Mostly cloudy. Lows overnight in the low 40s.


Cloudy and becoming windy. Periods of light rain early. Turning colder. High 46F. Winds N at 20 to 30 mph. Chance of rain 40%.


Mostly cloudy. Lows overnight in the low 40s.


Cloudy and becoming windy. Periods of light rain early. Turning colder. High 46F. Winds N at 20 to 30 mph. Chance of rain 40%.


Cloudy. Lows overnight in the low 40s.


Light rain early. Then becoming windy in the afternoon. Turning colder. High 47F. Winds N at 20 to 30 mph. Chance of rain 40%.


I am displaying this in the console at the moment, I might use some kind of GUI at a later date; my son odion is often telling me that I should put stuff into GUIs but A console is good enough for me for now

The code to get the forecast could be run on any machine that can run python 2.7 but now we come to the reason for running this on the BBB. There is a single LED connected to P8-8 and when the value of the precipitation chance in percentage is over  60% this LED lights up. The whole check is done every 3 minutes at the moment but I will be playing with the timings later. It is likely that I can get away with every 6 hours or so but I will see.


I have taken the idea for this from the "Getting Started with Raspberry Pi" book and made a few changes as well as converting it to the BBB; I will probably set this up on the Pi next and see if there are any differences in the way it works.

The Weather Underground api looks very wide ranging and I will see what else I can get out of it, I think that as we in the UK head into winter something that pulls the expected maximum and minimum temperatures will be useful. I have found where this info is held in the json document:


"high": {




"low": {




Will have to play around with this info and see how I can make use of it.


I will be using my BB_VIEW display to see how I can display the info, not sure what or how yet, this will be in another blog. I am going to be writing about my experiences with my new Pi B+ so check out my blogs on there.

Bye for now, off to check if my LED is alight yet!


Beaglebone Black

BB View 4_3 LCD Display

Filter Blog

By date:
By tag: