Skip to content

Installing Infinitude on Raspberry PI (Raspbian)

jftaylorMn edited this page Feb 2, 2023 · 11 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 libchi-perl libmojolicious-perl libdatetime-perl libxml-simple-perl libmoo-perl libjson-maybexs-perl libjson-perl libhash-asobject-perl libdata-parsebinary-perl libdigest-crc-perl libcache-perl libtest-longstring-perl libio-pty-perl
cpanm -S 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:/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.

Ensure dependencies are all installed

cd ~/infinitude
cpanm -S --installdeps .

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

Once you've run infinitude you'll find a file in the infinitude 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" 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". If you do not plan to use the Pi UART, you should change "serial_tty":"/dev/ttyUSB0"to"serial_tty":""`. See the notes below on using the Pi UART.

nano ./infinitude/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.

Over time, Infinitude can write a large number of entries to logs which consumes memory and could eventually result in a lot of swapping (contributing to SD card failure). You can observe the memory usage using the top command and entering shift-M to sequence the listed processes by top memory use. It might be good to check this periodically after install. Infinitude will show up as a perl process. Without providing specific recommendations here, consider limiting journalctl on the pi. That can be done by size, relative date, or setting it to volatile. (Log entries can be found in /var/log/daemon.log)

Starting Infinitude at boot-up.

Once you've run Infinitude and are happy with your settings, we can create a new systemd service file which will start Infinitude at boot.

To create the new systemd service, use the following command to open up the command line editor so we can create the codes for the service. The systemd services are located in /etc/systemd/system/

sudo nano /etc/systemd/system/infinitude.service

This will open up a blank editor named infinitude.service Add the following code:

[Unit]
Description=Infinitude HVAC control
After=network-online.target

[Service]
Type=simple
WorkingDirectory=/your/infinitude/path
ExecStart=/your/infinitude/path/infinitude daemon -l http://:80
Restart=always
RestartSec=17

[Install]
WantedBy=multi-user.target

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 is started up binding to all available network interfaces on port 80. You can change port 80 to the port of your choice

Due to a problem with Raspbian reporting the network-online before the network interface is actually up: The restart portion of the code will give systemd another chance at starting Infinitude. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=868650

Then run the following to enable the infinitude service

sudo systemctl enable infinitude

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

You can see if infinitude is running with the following command:

ps -ef | grep 'infinitude'

The 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.

Using the UART

In order to use the UART, you'll need some hardware to convert the UART TTL serial signals to RS-485. The pi485 repository has published some hardware designs to fill this need.

The following instructions will help you get your raspberry pi and infinitude configured for the UART.

  1. Disable the serial console over the UART.
    • Run raspi-config as the root user.
    • Select option 7 (Advanced Options)
    • Select A8 (Serial).
    • When asked if you'd like a login shell accessible over serial, respond with 'No'.
  2. Enable the UART at boot.
    • As root, edit the /boot/config.txt file, setting enable_uart=1.
    • Example command: sudo nano /boot/config.txt
  3. Install wiringpi to control the pi485 power state with a GPIO.
    • sudo apt-get install wiringpi
  4. Edit /etc/rc.local to set the TTY for infinitude, turn on the pi485, and start infinitude.
    • sudo nano /etc/rc.local
    • My script contains the following...

Set the tty baud rate for the carrier 38400 HVAC system and other options

stty < /dev/ttyAMA0 38400 -echo -opost -isig -icanon min 1

Enable the pi485 by setting GPIO 18 (wiringpi pin #1) as an output, and 'high'.

/usr/bin/gpio write 1 1 /usr/bin/gpio mode 1 out

start up infinitude

printf " Starting infinitude\n" cd /home/hvac/infinitude nohup /home/hvac/infinitude/infinitude daemon -l http://*:80 > /dev/null 2>&1 < /dev/null & ```

If something goes awry and you need to reset the pi485, you can execute gpio write 1 0; sleep 3; gpio write 1 1 and it will toggle the power.