How to Raspberry Pi, Johnny five and Octoblu

Citrix Synergy 2015 was the first time I looked in to a product called Octoblu which has been part of the Citrix family since december 2014. Octoblu is best explained as an Internet of Things integration platform or as they say it

Our original mission was to connect everything to everything (people, systems, and things)

Of course we have seen other IoT workflow platforms like IFTTT(If This Then That) but all these platform have a consumer focus and lack context. What we need is a platform that can do If This And This Or This and et cetera then that, that and that et cetera.

After playing around with some basic workflows on Octoblu I decided it was time to start a project including the Raspberry Pi and some sensors. Although not that hard in the end I found it challenging to get it all running. This guide will show you how to spin up a new Raspberry Pi, create your first led on and led off Johnny Five script and connect the Raspberry Pi to Octoblu as an Octoblu Gateway.

Starter kit

There are multiple starter kits available online for the Raspberry Pi, I ordered one from Kiwi Electronics in the Netherlands. As shown below it includes a breadboard, some leds and switches. I also ordered a Temperature/Humidity sensor, although there are some cheaper ones available I decided to order a digital pre soldered DHT22 model.

Raspberry Pi 2 Octoblu Starter Kit

 

 

 

 

 

 

The first step after switching on a Raspberry Pi is the basic configuration and updating all the default files and components especially for the RPi 2 as this can be very unstable with an outdated Debian build.

Basic RPi configuration after first boot

Run Raspi Config which is the basic Raspberry Pi configuration tool.

sudo raspi-config
  • Expand File System
  • Advanced
    • Enable device tree
    • Enable SPi

Reboot the Raspberry Pi:

sudo reboot

Updating and upgrading

Copy and Paste the code block below, the && \ makes sure all commands are executed.

sudo apt-get update  && \
sudo apt-get upgrade -y && \
sudo apt-get dist-upgrade -y &&\
sudo rpi-update -y

Install npm & Node

After these initial steps it’s time to install Node Package Manager (NPM) and Node. These are the main components used for controlling the GPIO ports on the Raspberry Pi.

echo "deb http://node-arm.herokuapp.com/ /" | sudo tee --append /etc/apt/sources.list && \
sudo apt-get update && \
sudo apt-get install -y --force-yes node libusb-1.0-0-dev && \
sudo npm install -g npm --unsafe-perm

Johnny Five installation

Installing Johnny five, a javascript robotics programming framework.

Notice the –unsafe-perm after each “npm install” command. I’ve added this because npm seems to have an issue with non root accounts. Not quite sure why but this works:).

git clone git://github.com/rwaldron/johnny-five.git && \
cd johnny-five && \
sudo npm install --unsafe-perm && \
sudo npm install serial port --unsafe-perm && \
wget http://node-arm.herokuapp.com/node_latest_armhf.deb && \
sudo dpkg -i node_latest_armhf.deb && \
cd .. && \
sudo npm install johnny-five --unsafe-perm

Install raspi-io

Rasp-Io is a set of modules for node and Johnny Five which we will need later on.

cd johnny-five && \
sudo npm install -g raspi-io --unsafe-perm

Don’t forget to reboot now:)

Testing

Copy the attached led.js over to /home/pi with for example Filezilla

Attach the led to GPIO9 and make sure to ground it properly

Run the javascript file:

sudo node led.js

You should see no errors and just a blinking led.

Octoblu Gateway Gateblu installation

echo "deb http://node-arm.herokuapp.com/ /" | sudo tee --append /etc/apt/sources.list && /
sudo npm install -g gateblu-forever --unsafe-perm && /
sudo curl -o /etc/init.d/gateblu-service https://raw.githubusercontent.com/octoblu/gateblu-forever/master/.installer/raspbian/init.d/gateblu-service && /
sudo chmod +x /etc/init.d/gateblu-service && /
sudo update-rc.d gateblu-service defaults && /
sudo service gateblu-service start

After the installation I noticed it was possible to register the Raspberry Pi as an Octoblu Gateway but after each reboot of the RPi the Gateblu stayed offline. After examining the gateblu.log it showed that it creates a new uuid after each service restart. The solution is to alter the meshblu.json in such a way that it will always use a single uuid.

The easiest way to do this is to look in the /home/pi/gateblu-service/gateblu.log and search for the uuid.

Mon, 24 Aug 2015 19:24:22 GMT gateblu:index ready { api: 'connect',
 status: 201,
 socketid: 'xxxxxxxxx',
 uuid: '2d2f031f-d9f0-4995-9d73-xxxxxxxxxxxx',

Copy the uuid

Open the meshblu.json file and insert the uuid we just copied. The token field is optional for security purposes.

{
"server":"meshblu.octoblu.com",
"port":80,
"uuid":"2d2f031f-d9f0-4995-9d73-xxxxxxxxxxxxx",
"token":"f1e3a4c8ea4ece0e9213aec914fbb40d98xxxxxx"
}

At this time you should be ready and the RPi should register itself to Octoblu nicely, you can check this by opening the RPi within the Things menu. It should say “Online”.

I will continue on this journey and hope to show you some really need stuff in the near future!

Bookmark the permalink.

About Barry Schiffer

Barry is an IT Architect with 15 years of IT experience. He has gained both a broad and deep knowledge in the sphere of IT. Throughout the years, Barry has developed into a specialist in the field of Microsoft Windows, Server Based Computing, desktop and server virtualisation.Barry is co-founder and member of the Board of the Dutch Citrix User Group.Barry is awarded with the Citrix Technology Professional award in 2015 and received the RES Software Valued Professional award in 2012.

2 Responses to How to Raspberry Pi, Johnny five and Octoblu

  1. Anh Le says:

    @Barry: Thank you for your post. Would you pls let me know how to use Gateblu to connect a bunch of sensors to Octoblu? Thanks in advance.

  2. Pingback: How to Raspberry Pi, Johnny five and Octoblu

Leave a Reply