Skip to content

Instantly share code, notes, and snippets.

@stonehippo
Last active October 6, 2021 13:52
Show Gist options
  • Save stonehippo/5896381 to your computer and use it in GitHub Desktop.
Save stonehippo/5896381 to your computer and use it in GitHub Desktop.
Setting up a Raspberry Pi as a dashboard server with Dashing

Setting up a Raspberry Pi as a dashboard server with Dashing

Why the heck did I do this?

I wanted to set up one of my Raspberry Pi's as a data dashboard, pushing sensor data to a web interface that's easy to digest. I decided to use Shopify's Dashing framework. Dashing is based on Sinatra, and is pretty lightweight.

Dashing does require Ruby 1.9.3 to run. In addition, it makes use of the execjs gem, which needs to have a working Javascript interpreter available. Originally, I tried to get therubyracer working, but decided to switch over to Node.js when I ran into roadblocks compiling V8.

One warning: The RPi is a very slow system compared with modern multi-core x86-style systems. It's pretty robust, but compiling all this complex software taxes the system quite a bit. Expect that it's going to take at least half a day to get everything going.

Setting everything up

Assuming that you're running Raspbian with a more-or-less out-of-the-box config, these steps will get working Ruby and Node setups, then install Dashing and build a sample project.

First, let's get the basic dependencies out of the way:

$ sudo apt-get update
$ sudo apt-get install git-core git build-essential libssl-dev zlib1g-dev

After this is done, don't forget to config your GIT, or some of the patches below will fail.

Time to install node (based on this gist)

$ git clone https://github.com/joyent/node.git
$ cd node

Use an older version of Node.js. It's possible that newer versions, including 0.10.x, will work, but this is what I did:

$ git checkout v0.8.8 -b v0.8.8
$ curl https://github.com/joyent/node/commit/25c2940a08453ec206268f5e86cc520b06194d88.patch | git am
$ curl https://github.com/joyent/node/commit/1d52968d1dbd04053356d62dc0804bcc68deed8a.patch | git am
$ curl https://github.com/joyent/node/commit/f8fd9aca8bd01fa7226e1abe75a5bcf903f287ab.patch | git am
$ curl https://github.com/joyent/node/commit/7142b260c6c299fc9697e6554620be47a6f622a9.patch | git am
$ ./configure
$ make

Buidling Node.js is slow on the RPi. Now is a good time to do something else. Come back when it's done and do the next steps to actaully install node.

note: it's possible to get newer node.js versions as pre-built binaries now. See http://joshondesign.com/2013/10/23/noderpi for details. note redux: you can also get node.js for the RPi with this: https://github.com/nathanjohnson320/node_arm.

$ sudo make install

And now Ruby and the gems we want:

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile 
$ echo 'eval "$(rbenv init -)"' >> ~/.profile
$ exec $SHELL -l # make rbenv available immediately
$ rbenv install 1.9.3-p448

Building Ruby 1.9.3 takes a while; go play a game of Monoply or something…

$ rbenv global 1.9.3-p448 # set up the new Ruby to be available everywhere
$ echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc # Turn off installation of Ruby docs to speed up gem installs
$ gem install bundler dashing 
$ rbenv rehash # make the new commands installed with the gems available

Lastly, let's get a Dashing project running:

$ cd ~
$ dashing new test_dashboard_project
$ cd test_dashboard_project
$ dashing start

OK, that should be it. You should now be able to see the sample Dashing dashboard at http://[your Raspberry Pi's IP address or hostname]:3030/sample.

@UdoK
Copy link

UdoK commented Sep 2, 2014

How did you get your sensor data read? What widget have you used?
I want to use dashing for showing status information of my HomeAutomation devices but also if possible for control of switching devices.

@ruben1
Copy link

ruben1 commented Dec 14, 2014

I had the error --> dashing: command not found

I used rbenv rehash and now it works. Thanks @stonehippo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment