Updating Bluez on RPi

Update (Jul 9, 2019):
Now, Raspbian Buster, released on 6/20/2019, has bluez 5.50 by default!

This post shows how to update BlueZ on Raspberry Pi from 5.43 (the default version comes with Raspbian Stretch) to 5.50 (released notes [1]). In this post, I assume that you already have a Raspberry Pi 3 B+ or Raspberry Pi Zero W running Raspbian Stretch.

Steps [2]
1. Check Current BlueZ Version
1-1. Before starting, let’s check the current BlueZ version.

bluetoothctl -v

In case of Raspbian Stretch, the BlueZ version should be 5.43.

bluetoothctl -v5.43

2. Install Dependencies
2-1. Update the package list.

sudo apt-get update

2-1. Install the dependencies.

sudo apt-get install libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev -y

3. Install BlueZ
3-1. Download BlueZ source code.


3-2. Uncompress the downloaded file.

tar xvf bluez-5.50.tar.xz && cd bluez-5.50

3-3. Configure.

./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental 

3-4. Compile the source code.

make -j4

3-5. Install.

sudo make install

3-6. Reboot Raspberry Pi 3.

sudo reboot

4. Verify Update[3] [4]
4-1. Verify the BlueZ version by issuing the command below.

bluetoothctl -v

The result should be like this:

bluetoothctl -vbluetoothctl: 5.50

[1] BlueZ Release Notes
[2] Installing Bluez 5.44 onto Raspbian? – Stack Exchange
[3] Bluetooth LE upgrade not working – Raspberry Pi Forum
[4] Why does bluetoothd show version 5.37 after installing Bluez 5.45? – Stack Exchange


SI004 – NonInstrument

Most of my research these days is about getting to the heart of how we interact with musical instruments, exploring the essence of a nuanced touch that a piano player has or that subtle vibrato that makes one guitar player different than another. As a departure or brief interlude I’ve been thinking also about how to make an instrument that plays itself. It’s not a new idea, there are plenty of generative art projects that create their own ambient soundtracks but I’d like to look into how an instrument might create music from data it gathers from an environment.

The NonInstrument is a sonic interaction experiment that scans bluetooth devices and creates melodies from the UID of the device. The project explores how our devices are constantly talking to each other without us even being aware of these exchanges.

What’s a UID?

A unique identifier (UID) is a numeric or alphanumeric string that is associated with a single device. In other words, a unique sequence of numbers or letters that can be used to identify your device from ever other device in a huge ocean of devices.

The UID can be found in the line Address: F4-5C-89-AB-18-48

How it works

With the Sonic Interactions Kit (SIK) I installed Bluez, the Linux Bluetooth system, there’s a decent guide on how to install it at Adafruit. Then I wrote a simple Python script that uses Bluez to scan for devices and send the UIDs to PureData (Pd) using UDP protocol. Once that data is in Pd, the data is parsed into ascii and number values which are then converted from MIDI notes into frequencies. Each UID becomes a sequence of 16 notes which are saved into Tables/Arrays. The sequences are then played back and playback tempo and delay can be adjusted by potentiometers on the Lots of Pots expansion board (LOP) on the Pi.

Here’s it in action on Instagram

For the next steps on this project I’m thinking about putting the device in public locations to see what it picks up – scanning people’s devices and recording the melodies. I imagine each place will have a totally different sound and texture.

Some questions come up like:

  1. How do I make this device portable and durable? Battery-powered and in a metal pedal case maybe
  2. Should the device have it’s own amp and speaker to playback while on location?

How do you think I this project should evolve? Leave a comment below.


SI01 Experiment 1 – SenseSynth

I’m going to start documenting each Sonic Interactions experiment for the purpose of marking where I am in the process. Each one of these is merely a rough sketch to build upon and are in no means finished. My first experiment takes data from the accelerometer of a SenseHat and uses it to change parameters of a simple synth.

Goal: use an accelerometer to control the frequencies of a synth, experiment with gestural interfaces for music

How do we tame the wild data coming out of the accelerometer to use in a musical way in synth?
How do we use the joystick and middle click to add to the interaction?


  1. Write a python script to retrieve data from sense-hat and send to Pd
  2. Use data from python in Pd to alter the frequencies of oscillators:

3. Determine the mapping of data to synth parameters, I started with this:

The Pitch (x plane) from the Accelerometer was mapped to OSC 1 (oscillator frequency)
The Roll (y plane) was mapped to OSC 2
The Yaw (z plane) was mapped to OSC 3

All the code from this experiment can be found at the Sonic Interactions Github project. Python script is here
and the Pd file is here.

Let me know what you’d want to see done with this experiment next?
To make it more musical or more expressive, would you add a finer scale to the sensitivity of the accelerometer data so that you could, for example, play scales more easier?


Installing the latest PureData on a Raspberry Pi

After a fair bit of deliberation I was able to install Pure Data 0.49 on the Pi running Raspbian Stretch. I’ll walk through this step by step in case you’re not familiar with command line in Linux.

The default way to install PureData (Pd) is:

sudo apt-get install puredata

The only problem with this method of installing Pd is that you’ll get 0.47.

STEP1. Open Terminal

STEP2. Creating folder to organize compilation (optional):

mkdir src

STEP3. Enter in src folder / install dependencies / download pd source code / unpack downloaded file:

cd src
sudo apt install build-essential autoconf automake libtool gettext git libasound2-dev libjack-jackd2-dev libfftw3-3 libfftw3-dev tcl tk
tar -xzf pd-0.49-0.src.tar.gz

STEP4. Compiling Pd:

cd pd-0.49-0
./configure --enable-jack --enable-fftw

STEP5. Confirming if compilation are ok:

cd bin

STEP6. If it run, you can install Pd in your raspbian:

cd ..
sudo make install


Sensors into OSC with Python

How do we move from analogue to digital? There seems to be quite a number of ways including 2D & 3D scanning, photography, and sensors. For the purposes of intentionally limiting our options we’re going to create a physical interface with potentiometers and buttons. We’ll be using the LOP board with a Raspberry Pi.

Once we’ve soldered the potentiometers and header on the LOP board we have to install a few things and enable some of the system level software on the RPi.

Starting with enabling SPI

  1. Run sudo raspi-config .
  2. Use the down arrow to select 9 Advanced Options.
  3. Arrow down to A6 SPI .
  4. Select yes when it asks you to enable SPI,
  5. Also select yes when it asks about automatically loading the kernel module.
  6. Use the right arrow to select the <Finish> button.

Installing the Python Tools:

sudo apt-get update
sudo apt-get install python-setuptools
sudo apt-get install python-pip python-dev

Now we're ready to run the code, wait! we need to 


import spidev
import time
import os
import OSC
import RPi.GPIO as GPIO

# Open SPI bus
spi = spidev.SpiDev(),0)

# Open osc

send_address = "" , 9000
c = OSC.OSCClient()

# Function to read SPI data from MCP3008 chip
# Channel must be an integer 0-7
def ReadChannel(channel):
 adc = spi.xfer2([1,(8+channel)<<4,0])
 data = ((adc[1]&3) << 8) + adc[2]
 return data

# Define sensor channels
l0 = 0
l1 = 1
l2 = 2
l3 = 3
l4 = 4
l5 = 5
l6 = 6
l7 = 7

# Define delay between readings
delay = 0.1

while True:
 # Read the light sensor data
 ll0 = ReadChannel(l0)
 ll1 = ReadChannel(l1)
 ll2 = ReadChannel(l2)
 ll3 = ReadChannel(l3)
 ll4 = ReadChannel(l4)
 ll5 = ReadChannel(l5)
 ll6 = ReadChannel(l6)
 ll7 = ReadChannel(l7)
 print("channel 1: ",ll0)

# send off the OSC message with sensor values

msg = OSC.OSCMessage()

Mineblock Product Design

Design Process

To me, the MINEBLOCK project represents an excellent example of the convergence of a vast number of technical, digital, physical and human constraints. Knowing that being able to keep a close eye on all of these considerations simultaneously was going to be next to impossible, I asked a few friends to help with the product design aspect of the project. I requested Jason Miller’s assistance, he’s a recent graduate of the Emily Carr University Industrial Design program and the talented Afshin Mehin of Woke Design ( who I meet working on the Recon Instruments project and acted essentially in a consulting capacity.
The following article documents our design process and perhaps acts as a bookmark for some of the issues that we encountered along the way. The software for MINEBLOCK went through about six small iterations to get to the point of a satisfactory user experience but the product design, the challenge in this realm was sewing a number of different technologies together to work seamlessly and alleviate end users from difficult configurations, this took roughly 4 weeks. In comparison, the product design which also took 4 weeks went through about twice as many iterations and varied greatly from the original intention. The prototyping of the product was framed by the criteria of Form, Material and Construction, which lead to discussions about final production techniques and cost of labour. The physical prototyping was done in parallel with the software prototyping and sometimes informed each other. In retrospect this was although difficult with a small team, it was clearly the right way to proceed and without the clear interplay between physical and digital the product would not have ended up in such an elegant minimal style.

Early Sketches

– exploring horizontal bottom, vertical and diagonal board placement


The Cube

Since the early days of the project, I was adamant the product reflect Minecraft’s unique visual language in a subtle understated way, the cube was the most obvious form to begin experimenting with. Because the large lego-like perfect cubes were the elemental construction blocks of Minecraft, it seemed only fitting to have the MINEBLOCK reference the same aesthetic. I was set on having the enclosure for MINEBLOCK be wood but was unsure of the size, type and the construction. I believe that there’s an interesting tension or contrast between the digital nature and precision of the Raspberry Pi and the organic materiality of a wooden box.

The size of the Raspberry Pi was one hard constraint with it’s longest dimension being 85mm and secondly with RPi Model B the I/O was one three sides of the PCB and the fourth side had a SD card. One of the questions that came up was, does the MINEBLOCK allow for access to all the inputs and outputs or should it conceal the ones that are not necessary?
For the first physical prototype a lego box was assembled with my 8 year old son to give us a sense of the size of a cube that would contain a Raspberry Pi. Early on, it seemed that a cube would be quite large and was starting to give the impression of an object that is not portable. This would be an issue as one of the key values of the MINEBLOCK is its portable nature.

Lego box

wooden plywood construction

The next prototype was a wooden box constructed of quarter-inch plywood glued together. This ended up feeling somewhat large both in your hand as well as in a backpack or handbag. It became immediately clear that MINEBLOCK should not be a pure cube and convey the sense of cubes in another way.
For more cube explorations see MetaCube Article (written for Tangible Computing Course July 2014)

Flattened Cube

The next round of prototypes took the shape of a flattened cube, all with different types of wood and construction. First we tried laser-cutting side panels with box joints for a simple construction but visually the prototype looked cluttered and rather than referencing the visual world as Lego or Minecraft, its reading was more in the Arts & Crafts realm. Then we tried hollowing out a 2 x 4″” piece of wood to contain the Raspberry Pi and as a group we agreed unanimously about the direction of using a solid block of wood.

CNC (Computer Numerical Cutter) cut flattened cube

Laser-cut and box-jointed

Over the next week we experimented with a variety of ways of hollowing out wood. The first approach was arguably the easiest. Using a computer numerical control (CNC) machine we were able to get a clean accurate cut in the form of the Illustrator file that we provided the operator with. Our first attempt was with soft spruce 2x4x4″ block and cost 6 minutes of time on the CNC ($1.50/min). The second approach was the quickest, using a drill press and Forstner bit (See diagram) to drill 5 holes into the block of wood. Even with the final chiselling to finish/clean up some of the unwanted residue this approach was fast but inaccurate, hard to reproduce and gave us little insight into the actual future production technique. The third approach was to build a template jig to help guide a handheld router with a 1/4″ routing bit. This technique was challenging as each pass of the router was to be 1/4″ maximum which ended up being 5 passes. This technique would not be appropriate for production as it took a great deal of time and it would be extremely difficult to yield consistent results in this manner.

Drill Press to hollow out block

RaspberryPi in hollowed wooden block

The final experiment was to return to the CNC machine with our final choice of wood, Birch and the exact depth for hollowing a block. This approach also cost 6 minutes in time and the results were accurate and beautiful. Additionally the machine operator assured us that if you were to do a larger number of blocks you could have them all be hollowed out of one large plank and then cut would be an efficient way to produce a larger production run. This approach was by far the most promising production technique.


CNC prototypes at Makerlabs

Closing the box

We tried a number of ways of giving the box a lid or closing panel. The option that seemed most appropriate was the 1/4″ acrylic bottom plate, which if in a smoked, dark tint would give the impression that the wooden box was floating with a slight drop shadow. Next came the issue of exposing the inputs and outputs of the Raspberry Pi. The biggest issue being birch’s density and thickness not allowing us to laser-cut onto the hollowed block. After many experiments we discovered that the best way would be to laser cut two acrylic panels that would allow for the RPi’s inputs and outputs. These panels could be cut out of the same material as the bottom plate and could be glued together to reduce the number of pieces while still allowing users to be able to access their RPi by only loosening a few screws on the bottom plate.

Large cutouts for RPi I/O

Lasercut tinted acrylic panels

Our MINEBLOCK size changed quite a bit over our process. The final change was to make the cube 105 x 105 x 45mm. Although this was only a 1/4″ smaller than our original cube if felt much better in your hand.




Identity Design

I may have left the brand identity component to the end of this article but it is by no means less important or the one we thought about the least. The were many sketches and ideas for how the visual language would be represented on the MINEBLOCK. Where would the logo sit? How would the block exude a cube visual language? How would it touch on the Minecraft aesthetic in a subtle way. The initial logo had a simple isometrically-drawn cube in it and the idea of bringing that cube into a 3D representation came about.

Initial Logo design

We experimented with quite a few approaches before we decided on one. Here are some of the more successful ones:

  1. laser-cut cube
  2. shallow router indentation of cube
  3. Cube cutout
  4. Acrylic block glued into corner

Lasercut Burned Logo

cube cut out and embossed with router

Final Design

MINEBLOCK with acrylic cube glued into corner

Acrylic Bottom plates in fluorescent colours adds a beautiful glow


Connecting directly to RPi

One of the first things you do with a Raspberry Pi is connect it to a wifi or ethernet network but what if you don’t have an extra keyboard or screen available, but you have a laptop?

There are times when a HDMI monitor is not available to use with your Raspberry Pi.  In those circumstances it can be very useful to remote connect using a nearby network and a laptop (see the Guide to…Remote Connections).  However, sometimes there isn’t a network available either!

So how can we make use of a laptop screen and keyboard when there is no network?

As discussed in Meltwater Raspberry Pi Hardware’s Guide to Remote Connections, there is the option of using a TTL-serial cable, however this provides rather slow access.  The serial connection won’t support X11 (which allows us to run graphical programs), and you won’t be able use VNC or shared folders if you have them setup.

The answer is a simple network cable!

It is advisable to set this up before you need it so you can be sure that it is configured and working correctly.  As long as you have an SD-Card reader available, you can switch between the configurations using a laptop (or directly on the Raspberry Pi if you have a screen/keyboard at the time).

Remember if you need the wired network for your computer (i.e. to get internet) then you shall have to make a choice about which one you wish to use (or get an extra network port by adding a USB network dongle).  If you use wireless connections, then you can still have both!

Any standard network cable should be suitable (needs to have a male RJ45 connector on each end), most cables available will be fine for our needs.

Note: You can use a normal network cable since the Raspberry Pi LAN chip is smart enough to reconfigure itself for direct network connections (in the past older computers would have needed a special “cross-over” cable).

Before you boot up your RPi you’ll need to edit the /boot/cmdline.txt file. This can be done either on the RPi itself using nano or your preferred editor or by mounting the SD card on another computer with a card reader and editing the file there:

Here’s how you do that:

sudo nano /boot/cmdline.txt

5. Edit cmdline.txt and add the IP address at the end (be sure you don’t add any extra lines).

For network settings where the IP address is obtained automatically, use an address in the range 169.254.X.X ( –

type “ip=” at the end of the cmdline.txt file.

If you’ve edited the cmdline.txt file on another computer you’ll need to put it back into the RPi and boot it up.
Otherwise, you’ll then need to reboot your RPi by typing:

sudo reboot

Make sure your static IP stuck, you’ll see the IP address announced during the bootup procedure.
You should get a result similar to this:

The IP address is

Or you can double check to discover your RPi’s static IP:

sudo hostname -I

On your laptop

Connect an ethernet cable between your laptop and the RPi and open the Terminal and ssh into your Raspberry Pi:

ssh pi@

You’ll be asked to create a network certificate and then prompted for a password to your RPi, by default it is “raspberrypi” if you haven’t changed it.


Wifi my Pi

Over the week I’m working on two current areas of practical research for Mineblock. The first has to do with one of the biggest gotchas of working with networked devices, particularly ones with no screen: getting it on the network and talking to it. The second is about installation and interaction: choosing the level of flexibility. This post is about the work on networking. I’ll write up the rest soon.

The problem with setup/connecting to wifi

For Raspberry Pis in general, people generally use them either with a screen and keyboard, getting networking information using the screen, or else headlessly, i.e. without a screen. This is where the problem comes. Moving the devices between networks means that you need to get them on the network to talk to them and for them to talk to the outside world, without being able to see the usual information on a screen.

For example,  I was able to get a Raspberry Pi (RPi) connected at my home office months ago but bringing it over to the Centre For Digital Media felt like starting from scratch. It had its home network programmed into it (using wpa supplicant, a linux networking tool that allows you to plug in and use wifi devices and specific which networks with passwords that they should attempt to connect to in a textfile.)

When moving it off a network it knows about, you’ll have to do one of two things in order to connect it up:

  • connect the RPi to a screen via its HDMI port and use a keyboard to enter the network information
  • connect it up to your own computer via an ethernet connection and share your network with it and then connect to it over ssh to use wpa supplicant or similar to get it on a network

The first of these may not be very convenient, because smallish HDMI screens may not be available. Modern TVs usually have HDMI sockets, but not all monitors do, and in any case you don’t necessarily want to carry one around with you. The second approach is feasible with Mac OS X (though not when the wifi network is certificate-protected), and it’s not for everyone.

Once you have managed to tell the device how to get on to a network, you then may need to connect to it the next time you want to talk to it. For a developer working on a RPi, typically you’ll want to try something out and reboot it.

If you are sharing your network with it, you can do this again, either finding the IP address via the console or nmap and sshing to it that way, or by installing Avahi on it and thereby giving it a known name so you can connect to it on the same network (e.g. ‘mineblock.local’). (Typically anything giving out IP addresses using DHCP will tend to give out the same one to the same device, but you can’t rely on that).

If you have not installed Avahi on it, or if you are on a different network, you will need to find its IP address somehow. Again, you will need to either connect it up to a monitor and keyboard to see its IP (‘ifconfig’), or use nmap or Mac OS X console if you’re on the same network / sharing; or use some sort of display connected to the GPIO. Or you could make it say its IP address using Espeak, which is easy to do but is often hard to hear and difficult to remember the IP address by just hearing it.

Reconnecting and developing

For Mineblock ease of use is of utmost importance, the target audience being busy non-techie parents. I am working to make it easy for others who don’t have huge amounts of time or great skills in networking on linux-like systems to get started. None of the current solutions are very easy. It’s a substantial hurdle to getting things working for people.

People will have two distinct problems to contend with:

  • telling the device about the network
  • talking to the device on the network

The two problems have parallels in the consumer area too. Printers, networked web cameras and other consumer devices have this problem: they need to get on the network (perhaps with no easy user input device or feedback device) and other devices need to talk to them once they are on there. It’s obviously something that many Raspberry Pi and Arduino developers have thought about. Now that products like Nest have made network configuration seem so easy it has raised the bar for all networked objects.

A possible solution

For now and to solve the immediate problem, I’ve decided to take a similar approach to BBC’s Radiodan project that I saw at the Solid conference a few weeks ago. If the Mineblock doesn’t find a wifi network it knows about, it broadcasts its own wifi network with a known name and uses Avahi to enable the consumer to connect to it at a known identifier via ssh. The consumer can then ssh in and add wifi networks using wpa supplicant. In the future I plan to make it more easily configurable over a web interface, but for now, this greatly simplifies the issues of having connecting to it on various networks.


Creating RaspberryPi Disk Images

UPDATE: I’m using Etcher now. It’s an incredibly easy way to format disks and works cross-platform.

Etcher’s 3 step process. simple.

This is the first of a series of articles about RaspberryPi, I’ll start with a few introductory tutorials to get you up and running.

The first thing you’ll want to do once you have a Raspberry Pi is set it up with an operating system. If you’re wondering about the best place to buy a Raspberry Pi, I’ve been happy ordering from Newark Canada. Unlike an Arduino that runs only the small program that you upload into it, RPi boots up with a full operating system (typically some type of Linux distribution) that’s on its SD card. There are several variations of the RPi OS that can be found there at’s distribution list.

For now let’s start by installing the general purpose operating system Raspbian – a version of Debian Linux specifically configured to run on the Raspberry Pi and is recommended by the Raspberry Pi Foundation as the operating system to install.

Downloading Raspbian

You’ll be able to download Raspbian for free from the Raspberry Pi website. Look for Raspbian with the subtitle ‘Debian Wheezy’, download either the torrent or direct download.

Once you have the ZIP file downloaded to your computer, unarchive it. Sometimes double-clicking on the Zip file doesn’t expand the archive and you end up with a archive of a Zip file. If that’s the case you’ll need to open the Terminal and type in:


The result will be the disk image (.img file) that you will flash to the Raspberry Pi’s SD card. You will need an SD card with at least 4GB capactity. I suggest you look at the list of SD cards that are compatible with Raspberry Pi. I’ve been using 16GB SanDisk Extreme Class 10 disks, they work well.

Erase then Unmount the SD Card

Macs come with an app in /Utilities called Disk Utility, select the SD Card item in the list on the left. Click the “Erase” tab that appeared on the right hand pane. You’ll see a “Format” option and a “Name” field. Choose “MS-DOS (FAT)” as the format and enter a name. For the FAT-32 format, the name must be uppercase, I suggest something like “RASPBIAN.”

Then select the name of the SD card in the left column again and click “Unmount.” It’s important that the disk be unmounted.

Flash the Disk Image

Go back to the Terminal and type the following command, ensuring you replace the “[FILESYSTEM]” value with the one you noted earlier and the “[DISK IMAGE NAME]” with the proper file name obtained above.

sudo dd bs=1m if=[DISK IMAGE NAME] of=[FILESYSTEM]

For me, the command would look something like this:

sudo dd bs=1m if=2012-12-16-wheezy-raspbian.img of=/dev/rdisk4

Hit enter, and wait until the command to complete. This takes a while and unfortunately it the dd command doesn’t give us any signs of progress. You can hit the CMD T keys to get a bit of data about how much it has copied. Depending on the SD card’s speed this process can take up to 10 minutes. Once dd flashes the disk image, you can remove it from your Mac and plug it into your Raspberry Pi.

If you’d like to do this on something other than a Mac have a look at these comprehensive instructions.