Experience Generative Art
An open platform based on Raspberry Pi, Philips Hue and MIDI instruments

In this tutorial we'll take you step-by-step through building a standalone generative art platform from a virgin Pi 3. This project was initiated to celebrate IoT Day on April 9th, 2017, at which time it looked like this.

Hardware Prerequisites

You'll need a Raspberry Pi 3, a Philips Hue kit with bridge and lightbulbs, and a reelyActive minimal starter kit. The following (placeholder) drawing illustrates how the pieces connect together.

Preparing the Pi

Follow our Make a Pi Hub tutorial up to and including the Install Node.js and forever step.

DHCP server on eth0

In order to directly connect the Philips Hue bridge to the Pi and provide it an IP address, the Pi must be configured as a DHCP server on eth0. From the command line, run the following:

 
sudo apt-get install dnsmasq
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.default
            

This will install the dnsmasq software which we'll configure by editing the dnsmasq.conf file by running sudo nano /etc/dnsmasq.conf from the command line. Paste in the following lines and save:

 
interface=eth0
dhcp-range=10.0.50.2,10.0.50.99,255.255.255.0,12h
            

This will configure the Ethernet interface to serve IP addresses in the range from 10.0.50.2-99 using DHCP, with a 12-hour lease. Restart the service from the command line for changes to take effect:

 
sudo service dnsmasq restart
            

ALSA for MIDI

The midi package depends on ALSA. Install the prerequisite by running the following from the command line:

 
sudo apt-get install libasound2-dev
            

Installing GeneraBLE

The generable package for Node.js bundles all the code for the generative art platform. From the command line, run the following:

 
mkdir ~/reelyActive/generable
cd ~/reelyActive/generable
npm install generable
            

It may take a minute or two to install and build the software. Once this is complete, from the command line run nano generable.js to create a file called generable.js, then paste in the following contents and save:

 
var generable = require('generable');
var server = new generable( { httpPort: 3000 } );
            

Running GeneraBLE

Run the generable.js file you created by entering node ~/reelyActive/generable/generable.js from the command line. Then point the Pi's browser to localhost:3000, or, if your PC is on the same WiFi network as the Pi, point your favourite browser to port xxx.xxx.xxx.xxx:3000 where the Xs represent the Pi's IP address.

Configure the Philips Hue bridge

From the GeneraBLE webpage, follow the link to Hue (/hue) which will scan for a Philips Hue bridge connected to the Pi's Ethernet interface. When a bridge appears in the list, first press the button on the Hue bridge, then click the Connect button in the webpage. GeneraBLE will store the bridge credentials and automatically reconnect each time it is run. Only if the bridge's IP address changes will you need to repeat this step.

Configure the MIDI interface

From the GeneraBLE webpage, follow the link to MIDI (/midi) which will scan for connected MIDI interfaces. From the list, select the desired MIDI interface. GeneraBLE will store this interface and automatically reconnect each time it is run. Only if the connected MIDI interfaces change will you need to repeat this step.

Enjoy!

If a reelyActive starter kit is connected and receiving BLE packets, you should observe generative behaviour on the lights and MIDI interface. If not, try restarting generable.js. Have fun!


What's next?

We'll be improving this tutorial to make getting set up even easier. We'll also improve and document the generator.js file which defines the behaviour of the platform (and was hastily prepared on IoTDay!).

Our starter kits include a one-month trial of our Pareto platform which is the easiest way to put your data to good use. Also, if you expand on this platform and would like to share your work, please get in touch!

Make a Pi Hub Get Pareto Return to diyActive