Home Automation

I chose Z-Wave as the basis for my home automation system because it is power-efficient and well-supported. I chose the Homeseer Zee S2 as my Z-Wave controller because it was power-efficient, inexpensive and has an open architecture. I would have been better off getting the next more power Homeseer model, but I didn't know then how far I would go with this.

So far I have used entirely off-the-shelf Z-Wave modules, though I have used a couple in unorthodox ways. But I have just purchased the Z-Uno development system-on-a-chip and a hat full of SparkFun components. I have a vermicompost, and have trouble keeping the moisture level up. As far as I can tell, there are no Z-Wave soil moisture sensors. So off I go!

Project Goals

Overall: monitor the temperature and soil moisture of my vermicompost. Cool the room if the temperature gets too high. Add water if the soil gets too dry.
Z-Wave module requirements

  • Temperature sensor (required)
  • Soil moisture sensor (required)
  • AC power relay to control room fan (optional)
  • Soil motion sensor (optional)
  • DC power to control watering (optional)

This is a lot to pack into a single Z-Wave module, but it looks like the Z-Uno can do it!

Bill of Materials

Early draft. All prices USD.
Description Part Number Quantity Price
Z-Uno 1 $70
SparkFun Beefcake Relay Control Kit (Ver. 2.0) KIT-13815 1 $7.95
660 ohm resistor 1 pennies
Breadboard - Translucent Self-Adhesive (Clear) PRT-09567 1 $4.95
Piezo Vibration Sensor - Large SEN-09196 2 $5.90
SparkFun Soil Moisture Sensor SEN-13322 2 $9.90
SparkFun Humidity and Temperature Sensor Breakout - Si7021 SEN-13763 1 $6.95
Silicone Conformal Coating
20 AWG solid wire as required salvaged
15 A circuit breaker 1 $1.00 (yard sale)
14 AWG stranded wire, white salvage as required
16-12 AWG ring terminals 5
250 VAC 15 A SPDT toggle switch 1 $1.00 (yard sale)


Early breadboard layout. I had to substitute several components. Feel free to teach me something.

Play by Play

Quick Start

The Z-Uno just came in, as did the parts from SparkFun. The Z-Uno fit nicely into the breadboard. I followed the quick-start instructions that came folded in with the Z-Uno. Everything went perfectly through step 9. I even did the inclusion about 20 feet and three walls away from my Homeseer Zee S2 controller. It worked perfectly the first try.

I did have an issue with the second set of instructions, under "To start writing your own sketches…". Step 3, "Update your Z-Uno board to the latest version, using «Tool > Burn Bootloader». It left out three steps (and it's "Tools" not "Tool"). Before burning, you must select the programmer using «Tools > Programmer > Z-Uno Programmer» and select the correct serial port using «Tools > Port». And set the radio frequency for my country using «Tools > Frequency». This last step was most troublesome, as not of the on-line documentation mentioned it.

Got the SparkFun Moisture Sensors working. I had hoped to drive them in both forward and reverse voltage to ward off corrosion, but the sensor wasn't having any of that. Simplifies my circuit, at least. When driven with a Z-Uno digital IO pin, I get 0 for air, 78 for hard tap water, and between 60 and 80 for soil of varying moisture levels. Both sensors read water at 77-78, but the drier soil read lower with the second sensor than the first. Could have been random noise, though. I have enough resolution to make it useful, so I won't go any deeper with calibration.

The spring terminals are next to useless. The pins aren't long enough to secure them to the breadboard. Designed for PCB, apparently.

On to the piezo vibration sensor. The hope is to monitor the amount of activity in a tray. When it drops the near zero, I know the worms have moved on and that tray can be harvested. My assumption was that the ADC would read 0 when there was no voltage generated and read higher proportionate to the generated voltage. Then the highest value I read would correspond to the peak movement during the sensing period. First surprise was that the ADC seems to source voltage and must be pulled down to set the value. I started out with a 1 megaohm resistor in parallel with the sensor. This put me over 2.5 V. I played around with resistor values until the voltage settled at about 1.5 V, giving me nice values in the middle of the range. That turned out to be 330 kiloohms. And of course the piezo is an AC device, so it bounces the voltage up and down when provoked. I set my ADC resolution to 8 bits, or 0 to 255. Experimentation shows that with no activity the value ranges between 123 and 133. With mild provocation the voltage will go +/- 0.1 volts, giving a range around 115 to 140. Over a certain threshold, the voltage bottoms out to 0. Not sure why, and I hope I not hurting the Z-Uno. So in my code I sample over a one-second period, note the highest and lowest readings, and return the difference as the sensor value. 12 and under means no activity (just noise). I may glue some levers or even a grate pattern to the sensor to make it easier for the worms to deflect it.

For a bigger challenge, the next step is to integrate the SparkFun humidity and temperature sensor. Being new to the Arduino IDE, I was surprised when I couldn't just include the .h file provided by the vendor. Following a chain of references starting with the #include reference documentation for Arduino, I took a chance to see if the sensor's header file had been included as a library package in the IDE—and it had! Unfortunately it would not compile for the Z-Uno board. By elimination I determined that the Sensor class structure needed at least one data type defined in it, and all it had were function calls. I added a dummy variable and all was well. Probably that's a compiler (pre-processor?) bug I need to post on GitHub. Once I got it that working, I had no trouble using the Sensor class to talk to the sensor.

The Beefcake relay is designed to be controlled by a 5 V digital I/O signal. According to the schematic, the "relay on" signal is 2.6 V, 5 mA. Since I'm using 3.3V logic, I could probably get away with no changes, but it's a little close. Using Ohm's law, V=IR I get 5 V = 5 mA * 1000 Ohms, which tells me that this is how they sized their resistor. To get the same current with my 3.3 V signal, I solve 3.3 V = 5 mA * x. x = 660 Ohms. So I substitute a 660-Ohm resistor for the 1K-Ohm resistor feeding the transistor. The other resistor is fed from the 5 V power line, so I leave it alone. And it worked. My LED is not coming on, though. Bad solder joint, or maybe I installed it backward. Not worried about it.

Now that I'm playing with dangerous voltage, it was time to find an enclosure. I scrounged and found an aluminum inverter housing. It's ridiculously large for a Z-Wave module, but it already had some of the AC wiring I need and it gives me lots of room to work.

The relay is for controlling a fan to circulate air in the room where the vermicompost is. That also happens to be the laundry room. My wife, who does the laundry, pointed out she would like to have manual control of that fan as well. I happened to have just picked up a good double throw switch. I would have preferred that is was double pole as well, but it wasn't, so I ran just the "hot" leg through it. I wired it to a NEMA 5-15R receptacle so that in the upper position it bypasses the relay and in the lower position it routes through the relay. While I was there I connected the Z-Uno power supply to the lower position, too, giving me a way to turn the Z-Uno on and off.

The inverter actually had three NEMA outlets. One of the spares I wired to be always hot, and the other I moved inside the enclosure to use as an outlet for the Z-Uno power supply.

Everything is working great on the hardware side. Unfortunately, the Z-Uno isn't playing nice with the Homeseer. Things work a little better with inclusion is done in non-secure mode, but it still a mess.

The Z-Uno stops responding after about 24 hours. Haven't had time to figure out what up.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License