
\documentclass[11pt]{article}
%Gummi|065|=)
\usepackage{graphicx}
\usepackage{caption}
\title{\textbf{ZMHW Modector}}
\author{Steak Electronics}
\date{}
\begin{document}

\maketitle

\tableofcontents

\section{Overview}
Making and deploying a Motion Sensor for Zoneminder CCTV software installations. These sensors use ZMTrigger.pl (wiki.zoneminder.com/ZMTrigger) to activate an alarm on a camera for a period of time. The advantage of hardware motion sensors over the software detection of Zoneminder, is that the hardware motion sensors avoid some of the problems inherent in software detection, such as false positives from day-to-night, bugs, missed detections, and others.

I've tried different motion sensors. Let's start with the Infrared Laser Diode.
\section{Parts List}
\begin{itemize}
\item Arduino Uno (official recommended)(DIP recommended)
\item ENC28J60 ethernet module
\item Passive PoE adaptors for IP Cameras
\item Series 1A fuse
\item Sick WS15-D1130 Infrared Laser Diode Motion Sensor
\item General Purpose Diode (I used 1N4818 diode) (may also use transistor, per data sheet for Sick)
\item Jumper Wires
\item Copper Wire (22-26 gauge)
\item Enclosure
\item Ethernet Wire
\item (optional) Low Profile one and two gang wall outlet 
\item (optional) Blank cover plate, for one and two wall gang wall outlet
\item (optional) Electrical tape (I prefer halfway decent electrical tape)
\item (optional) piezo speaker
\item (optional) extras of everything, in case anything fails
\end{itemize}
Later on we will try a different sensor. The HFS-DC06H. This sensor is a combination of an HB100 radio, with a decoding board that will read the signal and output a logic high or low. You may also want to try PIR sensors.
\subsection{Other Sensors}
\begin{itemize}
\item HFS-DC06H
\item PIR Sensor
\item Any other Laser Diode Sensor you like
  \item Reflective tape 
\end{itemize}
%\includegraphics[scale=0.8]{../pics/resistances.png}
%\captionof{figure}{Application Note resistance table}
\section{Work Log}
\subsection{Sick Motion Sensor}
The first tests were with the Sick diode sensor and receiver. This device is good for a doorway, where the door must be opened in order for people to pass. Putting it in the way of the door ensures that it will activate. It has a distance of at a max 15 feet or 3 meters. It is a laser type tripwire, which means it can be avoided, if someone knows where it is. 

Device was assembled and using the ZMHW Modector source code. This is simply an Arduino sketch with UIPEthernet (to use the ENC28J60) (make sure CS is pin 10 on Uno). For more details see source code. Explaining the details is out of the spec of this doc. Simply put, the ENC28J60 is connected, the Sick sensor black wire is connected to Analog input 1, and a speaker is connected. 

\includegraphics[scale=0.4]{../pics/DSCN0207.JPG}
\captionof{figure}{Testing the Sick IR Diode Tripwire }

Figure 1 shows two things, first off a diode connected in series with the output of the Sick sensor, and also the orange LED on the top of the sensor. The orange led will be green when there is no connection between the diodes and orange when the Diodes (or LEDs) are lined up correctly. When someone moves across the field of their vision, the orange LED will change to green.\footnote{This will later become important when installing the IR diode and receiver, as they must be lined up correctly.}
\subsection{Diode on Output of Sick Sensor instead of Transistor (Hack)}
Some IR diode / receiver pairs output a high or low. Some, like the Sick sensor, output a high or low (depending on whether you connect to white or black wire), however they are meant to be connected to a transistor, and thus if you connect it directly to a micro expecting it to go high or low, it will not. Being lazy, and seeking a quick solution, I put a 1N4819 in series with the output of the Sick sensor.
TODO: pictures showing waveforms
\footnote{This is possibly an issue of output impedance, but I will admit, at the time, I didn't bother to check.}

Using the black wire, it will be normally low and go high when motion is detected (the white wire is the opposite). If you connect to a micro it will fail to go high (why?). If you put a diode on the end in series, it will turn the normally low to a noisy normally low, and sometimes it will go between 2.5-5 volts in spikes. This allows us to use the ADC to read the Sick sensor, and avoid the use of adding a transistor in. The transistor would allow for a digitalRead to be used, but we have plenty of Analog inputs to use, so let's use one of those.

It's important to line up the emitter and receiver. If they are not lined up precisely, they will not get a sync, and the motion detection will fail. Thankfully, the diode outputs more of a cone, and less of a straight line, so some buffer is there. When the lights are dark, it is possible to see the red IR emitted if the distance is not too much.

\subsection{Broken ENC28J60 Module}
During my testing, I suddenly was unable to get an IP address. I checked the testsuite sketches, which didn't work, then began tearing down my setup, testing another Arduino and ENC module. It turned out, the ENC28J60 module failed on me. Make sure to buy backups.


\subsection{Installation Log in Pictures}
Here is an overview of what installing this in the wall might look like.








\end{document}

