Skip to content

Z-Uno Z-Wave projector, the first prototype

The hardware

First, here is the projector I used (very common model in my country):

Now, let’s go to the guts: integration with the existing electronic.

I proceeded to a disassembly of the projector to reverse engineer the circuit and decide where to hook the Z-Uno module I/O.

Inside the projector, there are two PCBs. One hosts the mains relay and the PSU that delivers 24V to the other board that implements the detection circuit (on the top right in the pictures below).

   

   

This leads to the following diagram that details only the part after the motion detection which we are interested in, e.g. the relay control and day / night detection:

Finally, the connections that have to be done between the projector and the Z-Wave part are:

  • Two power leads to provide 24V to the projector. This is because I decided to replace the existing supply using a capacitor in series with mains which doesn’t provide insulation from mains and would also not be able to supply the Z-Uno properly.
  • Three leads to carry the PIR, the day / night detection signals and the relay control.

Below is a picture of connections once finished and the PCBs mounted back into the original case.

   

The next step was to build a prototype with a solder less breadboard and all other components assembled on a plywood board to provide a robust test system.

On the above picture, we can see:

  • The projector electronic part.
  • The temporary 24V Power Supply.
  • And on the solder less breadboard, the Z-Uno just beside the 24 to 3.3 V DC/DC Converter. The LM 324 is not yet present at that time).

The final diagram of electronic part on the Z-Uno side is below:

First experiments

First troubles encountered was with the electronic. There is currently a bug in the Z-Uno firmware that prevent inputs to be in High Impedance mode when set in “INPUT” mode, the pull up resistor is always active. Therefore, the “digitalRead” did not return correct values given the resistors I used in series to connect to the projector (which I wanted to be as high as possible in order to not disturb existing design).

After a post in the z-wave.me forum (https://forum.z-wave.me/viewtopic.php?f=3427&t=23881), I realized that I will have to cope with that problem, at list in short to midterm.

I decided the to use an LM 324 Operational Amplifier to adapt impedance. By the way, this Op Amp also amplifies the photo diode signal that is used for luminosity sensing (see diagram).

Now, considering the software side, it has not been straightforward to catch all the API subtleties (the overall logic and the macros provided to manage Z-Wave channels). After many tries and program changes, implying a lot of Z-Wave inclusions / exclusions, plus a new post in the forum to get some clarification (https://forum.z-wave.me/viewtopic.php?f=3427&t=23913), the first prototype worked!

What a relief, and very encouraging to continue…

Bellow, we can see an example where we can see in DomoticZ a motion detection occurring during the day: Z05 is the day/light condition (here it’s day, so active), Z03 is the unconditional PIR Sensor (activated) and Z04 is the night time detection (therefore inactive).

The Z02 Switch allow to control the lamp.

Now, lets look at the Z-Wave associations management in DomoticZ:

We can see the “outbound” associations from Z-Uno with group 2 (unconditional PIR) and 3 (night time PIR), and the TZ66 Switch that can control the Z-Uno using its group 2.

Details on some software problem not particularly related to Z-Uno

Although the code is not really complex, there is a few trickier points:

Luminisity detection

This detection reuses the existing photo diode sensor. We measure a voltage with the Z-Uno ADC, however this diode is rather a current generator feeding a NPN transistor base, so voltage variation is quite low, and I also noticed a lot of fluctuations.

In order to have a good measurement reliability, I decided to use a sliding average over 32 samples (with one sample per second). In addition, a 10 % dead band is used in the threshold test to avoid multiple on/off detection when luminosity is slightly changing at sunset for instance.

Timing management

As the whole program is mono task, and even more, must relinquish control to other Z-Wave tasks, we cannot use active wait loop. Instead, small state machines are used to manage various sub tasks and timing (paced at seconds and minutes intervals). But nothing really complex!

Functions added after the first prototype

After this first successful achievement, I wanted to add a Z-Wave parameter to set an additional delay to the motion signal issued by the projector to tune the Z-Wave command duration.

If this parameter (pirOverTime in the code) is set to zero, then the Z-Wave command associated to motion detection (both unconditional and night time) follow temporally speaking the projector signal.

If a non-zero value is given, then the Z-Wave off command sent at the end of the motion detection are delayed by that delay.

However, at that time, the Z-Uno firmware doesn’t allow to implement Z-Wave parameters (https://forum.z-wave.me/viewtopic.php?f=3427&t=23635).

Therefore, the above parameter is currently hardcoded, waiting for this function availability in the firmware.

And finally, the code

For the first release, all the code is written into a single .ino file. Here it is:

 

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *