Skip to content

Installing Infinitude on Raspberry PI (Raspbian)

Bryan Varner edited this page Dec 31, 2016 · 12 revisions

This guide covers basic installation of Infinitude and it's dependencies on a Raspbian linux system.

For the purposes of this guide the following assumptions are made:

  • You have a Raspbian image setup, configured, and running on a raspberry pi.
  • You are logging in as a non-root user, with sudo access. (for example, the default 'pi' user)

Install Dependencies

From a command line, execute the following:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install cpanminus libmojolicious-perl libdatetime-perl libxml-simple-perl libmoo-perl libjson-maybexs-perl libhash-asobject-perl libdata-parsebinary-perl libdigest-crc-perl libcache-perl libtest-longstring-perl libio-pty-perl
cpanm -S WWW::Wunderground::API IO::Termios

The first line, sudo apt-get update && sudo apt-get upgrade makes sure you've got the latest packages installed. The second line pulls in all the upstream dependencies you'll need to run Infinitude.

Installing Infinitude

Clone (download) the Infinitude code

The easiest way to do this is to pull down the master branch of the git repository into your user's home directory. The following commands will get things going:

sudo apt-get install git
cd ~
git clone https://github.com/nebulous/infinitude.git
chmod +x ./infinitude/infinitude

The first line makes sure you have the 'git' source code management tool installed. The second line downloads the infinitude code from this github repository. The third line makes the infinitude script executable.

Initial start / test run

Starting Infinitude for the first time functions as a smoke-test to make sure we have all the dependencies, and will create the configuration file you'll need to edit to add a Weather Underground API key or to change your serial device.

To run infinitude:

cd ~/infinitude
./infinitude daemon -m production

To stop the process and return to a command line, type ctrl-c.

By default, Infinitude will start up and listen on port 3000 of all your network interfaces. If you'd like to change the port (or ip interface) Infinitude listens on, use the -l command line argument like so:

./infinitude daemon -m production -l http://192.168.1.232:80

This would start infinitude bound to the 192.168.1.232 interface, on port 80.

If you want to bind to 'all' the available network interfaces, use a *.

./infinitude daemon -m production -l http://*:80

Changing settings (tty, wunderground API key)

Once you've run infinitude you'll find a file in the infinitude/state directory, named infinitude.json. If you're not familiar with JSON, don't fret. It's just a text file. You can open it up with a text editor and set the "serial_tty" and "wunderground_key" to something other than the defaults.

If you plan to use the Raspberry Pi UART, you'll need to change the "serial_tty":"/dev/ttyUSB0" portion to "serial_tty":"/dev/ttyAMA0". See the notes below on using the Pi UART.

nano ./infinitude/state/infinitude.json

Then, edit your file, when done, press ctrl-x, answer y when you're asked if you want to save, and press enter to accept the current file name.

To test things out, you can just start up Infinitude again and make sure things work as expected.

Starting Infinitude at boot-up.

Once you've run infinitude and are happy with your settings, we can add a few commands to the /etc/rc.local script which runs any time the pi enters a new user run-level (which it does when it boots).

Edit the /etc/rc.local with the following command

sudo nano /etc/rc.local

Add the following immediately before the exit 0 line of the file. Adjust the path to your /infinitude directory as necessary (if it's not in your 'pi' users home directory).

## -- Begin additions for Infinitude
# start up infinitude
printf " Starting infinitude\n"
originalwd=$(pwd) || true

cd /home/hvac/infinitude
nohup /home/hvac/infinitude/infinitude daemon -l http://*:80 > /dev/null 2>&1 < /dev/null &

if [ "$originalwd" ]; then
  cd "$originalwd"
fi
## -- End Additions for Infinitude

exit 0

Again, to exit the nano editor, press ctrl-x, type Y to save, and enter to accept the existing file name.

In the example above, Infinitude exists in an 'hvac' user home directory, and is started up binding to all available network interfaces on port 80. In this example, the nohup command is used to fully detach the process from the rc.local script, and suppressing all output from appearing on the console or in logs, and to detach the input stream to avoid process hangs.

The next time your pi starts up, infinitude should run automatically.

You can test the script without rebooting with the following commands:

sudo systemctl daemon-reload
sudo service rc.local restart
ps -ef | grep 'infinitude'

The last command should list out any processes with 'infinitude' in the command line.

An example of the last command output (if things succeed) would look like this.

hvac@hvacpi:~ $ ps -ef | grep 'infinitude'
root      1101     1 79 00:02 ?        00:00:01 perl /home/hvac/infinitude/infinitude daemon -l http://*:80
hvac      1107   919  0 00:02 pts/0    00:00:00 grep --color=auto infinitude

The next time your Pi boots, infinitude should be running.