Automate and monitor the physical systems in your home
System Enclosures
System partitioning became clear early on. To minimize the wiring task, we needed two system enclosures. The first enclosure had Pi1 and Pi2 and Ruggeduinos 1-3 connected to about 40 I/Os. The second enclosure had Pi3 and Ruggeduino 4 connected to about 10 I/Os. Each enclosure had one bank of low-voltage relays and its own uninterruptible power supply (Figure 4).
To mount the Pis, we bought three Pi cases, drilled four holes through the bottom of each case, and secured two DIN clips. The tops of the Pi cases were left off, and the Aussie boards had their own DIN clips.
To provide a visual clue about the status of the system, we added a PiGlow board [8] to each of the Pis. The PiGlow board has a number of brightly colored LEDs and plugs in to the Pi's main connector (Figure 5). The PiGlow comes with Python software, and the cpu.py
program brightens and dims the PiGlow LEDs according to CPU usage. Together, PiGlow and cpu.py
give a pretty good indication as to whether the Pi is wedged (i.e., "stuck") or not at a glance. PiGlows make the system look cooler, too.
Virtual Wiring
The Virtual Wiring software runs on Rasp Pis, Linux PCs, Macs, and many other Unix-based hosts. It runs its own web server, and all access to the application takes place in a browser. When developing, it's best to use a host with a more powerful CPU – a Linux PC or a Mac – because they are more responsive. If you don't have a Linux PC or Mac or you need to run the software on a Pi, that's OK, but try to do it remotely. The Pi browsers are a bit sluggish, whereas PC and Mac browsers are not. We did all the development on a Mac and later moved the system to Pis; however, the system still runs on a PC or a Mac browser.
The Virtual Wiring software is written in the popular Ruby programming language. Many systems have a version of Ruby pre-installed (Macs do, as do Raspberry Pis running the latest Raspbian), but the installations are sometimes missing Ruby libraries required by Virtual Wiring. Here, I'll describe how to do a complete Ruby installation on a Raspberry Pi and how to install Virtual Wiring. Installation on a Linux PC will be the same or very nearly the same. Details on how to install the software on a Mac are on the Catalina Computing website.
In this example, we install the software on a Pi running Raspbian release 3.10.25, the latest release at the time. We have run the Virtual Wiring software on a number of earlier Raspbian releases, so these instructions should work for some older versions of Raspbian as well. Virtual Wiring will likely run on other Pi Linux distros (Pidora, Arch, Puppy), but we haven't tried them yet.
The first thing to do is download and install the latest Ruby on the Raspberry Pi and install the missing files needed for building Ruby packages (gems). To get started, open a terminal session and type:
sudo apt-get update sudo apt-get install ruby ruby-dev sudo gem install bundler
The first line brings your system's package directory up to date. The second line updates Ruby to the latest version and adds all the necessary files for building gems. The last line installs Bundler, a Ruby program that downloads Ruby packages (gems) and manages gem dependencies. Virtual Wiring needs Bundler.
If you haven't already, you need to download the Virtual Wiring software [2]. Before you can download the software, you should read the license agreement and, if you agree, click I agree.
The Virtual Wiring software is available free of charge for a non-commercial single-user system. Click on the Download button for the most recent version of the software. If you are using a Pi as your host and the Midori browser, when it asks whether you want to save the file, click Save and not Save As, because I've found that the Save As button fails to download the software, whereas Save works fine. The software will be downloaded into your home directory (usually this is /home/pi
). The download will be called vw_application_<xxxxxxxx>.zip
, where <xxxxxxxx>
is an eight-digit date. Move the ZIP file to the directory in which you want to keep it and unzip it. Change your directory to the newly unzipped vw_application_<xxxxxxxx>/vw_app_server
directory and install the needed gems using Bundler:
cd vw_application_<xxxxxxxx>/vw_app_server bundle install
Your Pi will churn on this for a while as it downloads and installs Ruby gems. The bundle
command should succeed with no errors. Your Virtual Wiring software installation is complete.
Buy this article as PDF
(incl. VAT)