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.

@LeeTurley
Copy link

Got it to work on my Raspberry Pi, just got to figure how to configure it now. Just one correction for you

$ rbenv global 1.9.2-p448 # set up the new Ruby to be available everywhere

It needs to read 1.9.3-p448

Thanks

@emulatrix
Copy link

I followed the instructions but get to the step

$ dashing new test_dashboard_project

displays the error -bash: dashing: command not found

@sujaymansingh
Copy link

Presumably it should be

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

I.e. build-essential rather than build essential?

@mrmanc
Copy link

mrmanc commented Nov 2, 2013

I got here by searching for command not found, as I had the same symptom as @emulatrix, and referring to the executable directly did not work as I could not create a project (got error Could not find "project" in any of your source paths. Your current source paths are: /Users/mark/templates). However, I'm on an OSX Mac, not an rPI. I found that rbenv was not configured correctly, as I'd missed some of the instructions. After fixing that, uninstalling and reinstalling the dashing gem, and doing an rbenv rehash it all worked fine.

@stonehippo
Copy link
Author

Thanks for catching those typos, @sujaymansingh and @LeeTurley. I've fixed both of those.

@stonehippo
Copy link
Author

@emulatrix, where you able to get the dashing command to work for you? You might want to make sure that you've run rbenv rehash, as @mrmanc suggested.

@MattLud
Copy link

MattLud commented Jan 10, 2014

Needed to follow memory and swap directions on http://blog.pedrocarrico.net/post/29478085586/compiling-and-installing-ruby-on-the-raspberry-pi-using to get it to install ruby. Enabling turbo mode seemed cut down on build time too.

@stonehippo
Copy link
Author

@Seakip18 I was able to make the above work on a 256MB RPi Model B with the 192/64 split and the default swap and tmpfs settings. I also hadn't enabled any of the overclocking settings, though it would definitely have sped things up. It's possible that the speed of the SD card used with your Pi could have some effect.

Of course, YMMV.

@NicoJuicy
Copy link

Don't know much about linux, but added the following line to
~/.bashrc instead of ~/.profile (and did it manually)
PATH="$HOME/.rbenv/bin:$PATH

@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