Automate and monitor the physical systems in your home

Starting Up

To start up the Virtual Wiring software, you can open a terminal session (or use your existing one), and then cd back to your vw_application_<xxxxxxxx> directory. If you just ran bundle install, typing cd .. will put you in the right place. Next, type:


Open your Pi's browser and navigate to http://localhost:4567. You should see the Virtual Wiring Device Explorer web page (Figure 6).

Figure 6: Virtual Wiring is running.

Virtual Wiring runs in a browser. You can run it from your Pi's Midori browser, or you can run it from another computer's browser. Midori on a Pi runs slowly, so we recommend running Virtual Wiring from a browser on a faster machine – a PC or a Mac.

To access Virtual Wiring from another computer, your computer and your Pi need to be on the same network. If you know (and your other computer knows) your Pi's network name, you can run Virtual Wiring from your computer's browser using your Pi's <network name> and port 4567 (e.g., http://<raspberrypi>:4567). If your Pi's network name is not known, you can use your Pi's IP address instead. If your Pi is not on a network or you have no other computer, you'll need to use Midori.

Your initial Device Explorer screen looks pretty empty. At the top of the screen you have links to the Home, Scripts, Wires, and Console pages. Here's what they do:

  • The Home selector is the page you are on now, the Device Explorer page. Device Explorer displays all the devices in the system. Initially, you have no devices, which is why the screen looks a little empty.
  • The Scripts selector brings you to the Scripts page, where you can build and run scripts that create devices and systems.
  • The Wiring selector brings you to a page that lets you wire devices together.
  • The Console selector brings you to a terminal screen, from which you can create, run, and debug scripts.

A block diagram should be your guide to building your home automation system. This project has too many blocks to cover, so we will just look at how to add an Arduino, a programmable logic device, and a state machine.

Adding Devices

The Arduinos are responsible for bringing all the digital input and output signals into the home automation system. If you look at a system block diagram (Figure 3), the bottom of each page indicates which Arduino is doing the I/O. On the left and right sides of the page, above the signals, are names like "D2" and "D3." These are the Arduino pins assigned to those signals.

In this example, I'll show you how to recreate Ruggeduino 1 and its signals. To begin, navigate to the Scripts page and click on the View Filter button at the top. If you select Arduino from the drop-down menu, you see just the Arduino scripts (Figure 7).

Figure 7: Arduino scripts in the Virtual Wiring Scripts dialog box.

To add an Arduino, click on the Run Action of the Arduino script. The script presents a dialog box, and the dialog box lists the parameters the script needs (Figure 8). In the screenshot, I've filled in the fields for Arduino 1. The port_location field is the name the Pi gave the Arduino's USB port when it was plugged in to the Pi; the value is host and Arduino dependent. Knowing port_location allows the system to control the Arduino. You can find more information about the Arduino on the Catalina Computing website.

Figure 8: The Arduino Parameters dialog box.

After adding the Arduino, you need to define its digital inputs and outputs. To define digital inputs, run the Arduino DigitalInputs script. Table 1 shows the DigitalInputs script parameters used for Arduino_1.

Table 1

DigitalInputs Parameters








"house_preset1_not, house_preset2_not, alarm_leak, alarm_temp, alarm_event, alarm_sys_trouble"





The debounce parameter filters out signals that oscillate rapidly (usually noise), and the pullup parameter enables the Arduino's weak pull-up resistors.

When connecting to sensed inputs, debouncing is generally a good idea. An Arduino's output pins are added similarly using the Arduino DigitalOutputs script. Table 2 shows the DigitalOutputs script parameters for Arduino_1.

Table 2

DigitalOutputs Parameters






"well_pump_enable, house_water_valve_closed, kitchen_circulator_enable, basement_circulator_enable, master_bath_circulator_enable, guest_bath_circulator_enable, radon_fan_enable"



Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Digital – Analog – Mechanical

    As innovative companies consistently push the envelope of progress, antiquated hardware nearly two years old falls by the wayside. We take an old iPad, an Arduino Mega, and various other materials to create an in-dash climate control app.

  • Automated plant watering with Arduino

    House plants are fairly self-sufficient, but they do need certain care from people to survive. With a few Arduino sensors and a little programming, you can take the guesswork out of watering your plants.

  • Connecting a weather station to your Arduino

    After losing one weather station to tropical winds, the author reboots and designs a PCB that connects to an Arduino and monitors weather instruments.

  • A new way of no-solder prototyping

    The Grove system's standardized connector and multitude of devices allow quick and easy project prototyping with your favorite small-board computers.

  • Making your projects more reliable

    A watchdog timer is a great way of improving reliability for little cost in small, inexpensive computers such as the Raspberry Pi and Arduino.