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:
./run_vw_application.rb
Open your Pi's browser and navigate to http://localhost:4567. You should see the Virtual Wiring Device Explorer web page (Figure 6).
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).
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.
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
Parameter | Value |
---|---|
arduino_id |
"Arduino_1" |
debounce |
true |
names |
"house_preset1_not, house_preset2_not, alarm_leak, alarm_temp, alarm_event, alarm_sys_trouble" |
pins |
""2,3,4,5,6,7" |
pullup |
true |
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
Parameter | Value |
---|---|
arduino_id |
"Arduino_1" |
names |
"well_pump_enable, house_water_valve_closed, kitchen_circulator_enable, basement_circulator_enable, master_bath_circulator_enable, guest_bath_circulator_enable, radon_fan_enable" |
pins |
"8,9,10,11,12,13,A0" |
Buy this article as PDF
(incl. VAT)