Arduino Intrusion Monitoring system

For this project, we’ll be covering a multi-sensor detection system that uses both Passive Infrared and Doppler X-band radar to produce a highly reliable means of intrusion monitoring.

This post has been organised into the following sections:

  1. Passive Infrared Motion sensing
  2. Doppler X-Band Radar sensing
  3. Combined sensing technologies

Passive Infrared (PIR) Motion Sensing

If you’ve had experience in building projects with an Arduino micro-controller or similar device, theres a good chance you’ve heard of a Passive Infrared (PIR) sensor. These devices detect the occurrence of motion within a given area using two ‘halved’ sensor units within each PIR module. Under no motion circumstances, each of the sensor units cancel one another out. Conversely, when there is motion, the output swings either high or low, since one sensor half detects a different amount of IR radiation to the other half.

Figure 1. A typical PIR sensing module.

Moving away from the nitty gritty details, the PIR sensor serves as a very cheap, low-power, long-lasting and simple to use component. It can be directly connected into the Arduino UNO (or any micro-controller) and a basic monitoring system can be made.

Figure 2. Simple schematic for PIR detection. Image taken from Adafruit (2015).

PIR basic software. The PIR sensor outputs a HIGH on its output (yellow line above) when a motion detection is made. This means digital pin 2 on the Arduino is also made HIGH with sensed motion.

With this in mind, we can build a simple program that checks the current state of digital pin 2, and updates a global boolean (true or false) variable accordingly. The program prints whether motion has started, or whether it has stopped, as shown below.

The major problem with a standalone PIR in an intrusion monitoring system is its tendency to give false detections. These nuisance readings are annoying , but don’t despair — they can be overcome. An effective solution is to adopt multiple sensing technologies into one intrusion monitoring system.

X-Band Radar Doppler Motion Sensing

For the second sensing technology we will consider an X-Band Radar module that uses the phenomenon known as the Doppler effect.

The Doppler effect is the apparent change in the frequency of a signal that arises due to relative motion between a source (emitter) and observer (receiver).

A series of low-cost, specialised sensor modules that detect motion using this principle is the HB100 X-Band Radar sensor. On their own, these sensors are unusable due to the large amounts of noise and very low output voltage (around the order of microvolts).

Figure 3. HB100 X-Band Radar motion sensor module.

Prior to processing by a micro-controller, a signal conditioning circuit must be used to both filter the required frequencies and amplify the signal to an appropriate level. After successful processing, you are left with a resultant signal with a frequency that corresponds to the measured Doppler frequency. Thus, the higher the Doppler frequency, the faster and more motion there is taking place in the targeted area.

You have two options for this part of the intrusion monitoring system:

  1. Built the required signal conditioning circuit. This is not too difficult and could be good experience if you’d like to brush up your electronics skills. Despite this, it may be time consuming and frustrating. I have supplied a working signal conditioning circuit to follow below.
  2. Purchase a Doppler sensing module with a breakout-board. These have built-in amplification and filtering circuits — a common choice is the Parallax X-Band Radar module. The modules are very robust and compact, which makes them effective for a reliable intrusion monitoring system. The downside is the higher cost — with some luck you can find one for approximately £25.

Option 1 — custom built signal conditioning circuit. For this, we must create a circuit that effectively filters and amplifies the output of the HB100 module so that it is useable by a micro-controller. The circuit aims to filter only signals below 100 Hz (more accurately below 75 Hz), since typical human motion generates a Doppler frequency less than this. Many fantastic circuits can be built for this module, but the most basic is one provided by a manufacturer of the HB100.

The referenced circuit is useable, but it will contain a significant amount of noise and false readings. To improve upon this, it is advised to use higher performance operational amplifiers with lower noise and rail-to-rail output. Many op-amps are suitable for this, such as the OPA2344 or similar models. An example of a basic, but improved conditioning circuit is given in Figure 4. This design used concepts explained by Limpkin in his blog on the HB100 many years back, so credit goes out for his hard work.

Figure 4. Basic Doppler HB100 module signal conditioning circuit. Many improvements can be made, including additional decoupling capacitors to reduce noise, and a late stage comparator to produce a clean square wave output.

This circuit is not perfect — it could be improved in many ways including extra decoupling capacitors for power-supply noise reduction and an additional comparator stage to clean up the partially noisy sinusoidal output. In addition, you could add a potentiometer to provide variable amplification and adjustment to allow easy calibration. Despite this, it will perform Doppler frequency measurements effectively for our intrusion monitoring system.

So you might be thinking this circuit looks ridiculously complicated, but don’t despair — its not that bad in reality. We can break the circuit down into several major stages: A non-inverting Active Band-pass filter, and an inverting active band-pass filter.

Figure 5. Non-inverting Active Band-pass filter.
Figure 6. Non-inverting Active Band-pass filter.

The HB100 output is of an appropriate level for detection by the Arduino after being amplified by 12200 (100 x 122). If you’ve worked with the HB100 and found that you still have a large amount of nuisance doppler frequency readings, consider implementing a late stage comparator to the output. This is optional and is shown in Figure 7.

Figure 7. A full HB100 signal conditioning circuit with late-stage comparator for square wave output.

The circuit can be built on a breadboard for initial testing, but for a more robust project I’d suggest at least making a prototype strip-board design so it doesn’t fall apart in use.

Figure 8. HB100 signal conditioning circuit — stripboard prototype.

Option 2— Pre-built Doppler module with conditioning circuit. If building a custom signal conditioning circuit is too exhaustive, or simply too daunting and off-putting — I don’t blame you — this option is much easier. Parallax do a very reliable and high performance sensor, even if it is a little on the expensive side. Alternatively, Limpkin has a solution, although I have not tested the performance of this against the Parallax. There may be more options out there worth exploring, but they all provide the Doppler frequency in a form suitable for direct connection into a micro-controller for further processing.

Figure 9. Prebuilt option — The Parallax HB100 Doppler sensor. It provides a very compact, high-performance and low nuisance output of the Doppler frequency due to moving objects in a given area.

It should be noted that microwave frequencies are small enough in frequency (8 GHz to 12 GHz) to pass through small walls and objects such as windows. The wavelength is large enough so as to not become scattered unless the object is especially dense or thick (like that of a cave or metal wall). Thus, we can strategically place our doppler sensors within protective structures, keeping the device safe from external exposure!

Doppler basic software. For this project, we will be using the FreqMeasure library to measure the output Doppler frequency from the X-Band Radar sensors. There are many alternative ways to do this, however this library provides an elegant and accurate solution for low frequency measurement (between 0.1 Hz to 1 kHz). The FreqMeasure library uses digital pin 8 for Arduino UNO, so you must ensure the Doppler frequency output is fed on this line if you have a UNO. If you are using a MEGA, you should use digital pin 49 instead.

A simple program I produced for processing an incoming Doppler frequency measurement is shown below. The threshold frequency for motion detection in this example was chosen as 5 Hz, since the sensor I used had very low noise. If you find you get a large number of nuisance readings, adjust the threshold accordingly — it is often a trial and error process for an effective setup.

Combined Sensing Technologies

Each of the PIR and Doppler sensing techniques are great for motion detection, but how can we be absolutely certain when we have real motion? By combining both sensors together!

The Doppler sensing code stays relatively the same for the combined program. The only difference is that it has been separated out into its own distinct function for Doppler frequency measurement. This ensures our code is kept modular and stays future-proof for further modifications.

In conjunction with the Doppler sensing function, there are separate functions for analysing both sensor types, printing motion status, and delaying without using the built-in Arduino delay() command. Program delays that use the delay() command are bad practice, since this renders the Arduino completely useless for the duration of the delay. Instead we can make use of millis() to wait for a predefined time, whilst simultaneously performing other important tasks — in this case Doppler motion sensing, as seen in the senseAndDelay function. This ensures our Doppler motion sensor is being continually checked, without the explicit need for interrupts.

The PIR sensing code in this final program is very different. We make use of an interrupt service routine (ISR), which ensures we always detect an input HIGH given from the PIR sensor. When the PIR sensor detects a movement, digital pin 2 of the Arduino becomes HIGH, which causes our program to run the function ‘pirMotionTriggered’. This function sets the boolean global flag IRMotionStarted to True, which is then detected by our program during the pirMotionUpdate function.

Future updates and to-follow

I hope you enjoyed following along with this small project, and perhaps it instilled you with an interest for using combined sensor technologies for a future project. This build was part of a large system of networked sensing nodes that detect motion and intrusions, and subsequently communicate the detected state to a central command-unit via secure radio communications.

A future post will follow providing a step-by-step guide to implementing this network of secure radio communications using Arduino microcontrollers and a central Raspberry Pi! It will be based upon the concepts of the simple sensing node created throughout this post.