Motion Detection Monitoring System Components

Created:  
Updated:   29Aug2024   05:40:28   UTC 2024-08-29T05:40:28Z
Rating:   (0 reviewsThis article has not been rated yet)

The purpose of a motion detection monitoring system discussed here is to record the presence or absence of people, animals, or vehicles on your property. This also includes monitoring the state of an opening, such as doors, windows, gates, refrigerators, freezers, cupboards, cabinets, drawers, and pet enclosures.

The basic components of a motion detection monitoring system consists of a motion sensor, microcontroller (MCUMicrocontroller Unit), wireless transceiver (RFRadio Frequency or WiFi), and a computer. An additional option would be to include a sensor status indicator (e.g., LEDLight Emitting Diodes, LCDLiquid Crystal Display, or other visual display) near the sensor to visually indicate if the sensor is operational (powered) and the microcontroller program is responding to any changes in the sensor state.

Motion Detection Monitoring System Design

When the motion sensor has a detection it creates a voltage change on the microcontroller input that interrupts its embedded software, which responds by sending a wireless signal over WiFi (LANLocal Area Network) or RFRadio Frequency to a gateway computer to record the data.

Having motion detection events recorded on a computer allows the data to be displayed on a dashboard in real-time, along with the capability of setting up an alert notification either on the computer or sending a notification remotely by phone texts and/or email.

This overview of motion detection monitoring system components covers motion sensors, microcontrollers, transceivers, communication, and computer hardware and software.

Switch Sensors

A simple type of sensor to detect the open/closed state of a door or window is a magnetic contact switch shown in the figure below.

Magnetic Contact Switch

The magnet is usually mounted on the door (or moving part) and the switch on the door frame (stationary) as shown in the figure below.

Door Monitoring with a Magnetic Contact Switch

A magnetic contact switch consists of a reed switch and magnet in separate enclosures (ABSAcrylonitrile Butadiene Styrene thermoplastic polymer plastic or metal) and is available in three different configurations: Normally Closed (NCNormally Closed (NC) switch configuration. In its normal default state, the switch allows current to flow through the circuit. When activated, the switch opens, breaking the circuit and interrupting current flow.), Normally Open (NONormally Open (NO) switch configuration. In its normal default state, the switch prevents current from flowing through the circuit (open circuit). When activated, the switch closes, allowing current to flow through the circuit.), and both Normally Closed or Open (NCNormally Closed (NC) switch configuration. In its normal default state, the switch allows current to flow through the circuit. When activated, the switch opens, breaking the circuit and interrupting current flow./NONormally Open (NO) switch configuration. In its normal default state, the switch prevents current from flowing through the circuit (open circuit). When activated, the switch closes, allowing current to flow through the circuit.). Each configuration is described below with a figure illustrating inside the enclosure of both the switch and magnet.

Normally Closed (NC)

An NCNormally Closed (NC) switch configuration. In its normal default state, the switch allows current to flow through the circuit. When activated, the switch opens, breaking the circuit and interrupting current flow. magnetic contact switch is normally closed without the magnet and conducts electricity (i.e., the door opening and removing the magnet would close the switch and allow the current to flow) and the switch opens when the magnet is near it, not allowing current to flow. The benefit of this configuration is its not consuming power while the door is closed. One drawback is it may be difficult to determine if or when the sensor becomes accidentally disconnected until the door is opened without a detection.

Magnetic Contact Switch Normally Closed (NC) with Magnet Removed
Magnetic Contact Switch Normally Closed (NC) with Magnet Near

Normally Open (NO)

An NONormally Open (NO) switch configuration. In its normal default state, the switch prevents current from flowing through the circuit (open circuit). When activated, the switch closes, allowing current to flow through the circuit. magnetic contact switch is normally open without the magnet and cannot conduct electricity (i.e., the door opening and removing the magnet would open the switch, not allowing current to flow) and the switch closes when the magnet is near it to allow current to flow. This is illustrated in the figure below. The benefit of this configuration is you can determine if or when the sensor is accidentally disconnected when the door is closed and showing the wrong state. One drawback is it will be constantly consuming power while the door is closed.

Magnetic Contact Switch Normally Open (NO) with Magnet Removed
Magnetic Contact Switch Normally Open (NO) with Magnet Near

Normally Closed or Normally Open (NC/NO)

NC/NONormally Closed or Normally Open (NC/NO) switch configuration. These switches have both NC and NO options where you can choose which configuration you want for your application. magnetic contact switches have both NC and NO options with three terminals: NC, NO, and COMCommon Ground where COM is the common ground. This has the advantage of letting you choose which configuration you want for your application.

Magnetic Contact Switch Normally Closed or Open(NC/NO) with Magnet Removed
Magnetic Contact Switch Normally Closed or Open(NC/NO) with Magnet Near

Unfortunately, there is a common misunderstanding among vendors selling these switches that think the "normal" position is with a magnet next to the reed switch, probably because the normal position of a door/window is usually closed, and you sometimes see the NC or NO backwards in the title of the product. Before purchasing, it is recommended that you check for any clarification in the product description, product reviews, or Q&A comments.

Purchasing options for NC, NO, and NC/NO magnetic contact switches are given below.



Proximity Motion Sensors

PIR Motion Sensors

Passive Infrared (PIRPassive Infrared) sensors are able to detect motion from a thermally radiating body, such as a human or animal, within the proximity of the sensor. They are often used in outdoor lighting, security systems, home automation, and other proximity-sensing applications.

PIR modules typically have a plastic Fresnel lens that focuses the IR radiation from a moving thermal body onto a pyroelectric sensor which generates a small signal that gets amplified and thresholded to produce a digital output signal.

Several common PIR modules are provided below, followed by comparison table of their specs. More details on how these modules work can be found in the article PIR Sensors.




Comparison of PIR Motion Sensors
Model AM312 HC-SR501 HC-SR505 MH-SR602 SparkFun
OpenPIR
Operating Voltage 2.7V-12V DC 4.5V-20V DC 4.5V-20V DC 3.3V-15V DC 3V-5.75V DC
Output Voltage
(High/Low)
5V / 0V 3.3V / 0V 3.3V / 0V 3.3V / 0V (3V - 5.75V) / 0V
or
Analog
Quiescent Current < 20μA < 50μA < 60μA < 20μA < 80μA
Sensing Angle ≤ 100° < 120° < 100° < 120° < 100°
Sensing Range 3m - 5m 3m - 7m 3m 5m 2m - 5m
(adjustable)
Delay Time 2s 5s - 18s
(adjustable)
8s ± 30% 2.5s 0.4s - 7.5s
(adjustable)
Blocking Time 2s 2.5s 2.5s 2s N/A
Trigger Mode Repeatable Repeatable /
Non-Repeatable
Repeatable Repeatable Repeatable /
Non-Repeatable
Operating
Temperature
-20°C to +60°C -20°C to +80°C -20°C to +80°C -20°C to +80°C -20°C to +80°C

Microwave Motion Sensors

Microwave motion sensors are a type of active sensor that operates by sending out a microwave signal and determining any small differences in the reflected waves as a result of movement in the area. The microwaves reflect off of different surfaces and are mixed with the transmitted signal to arrive at a frequency difference that is extracted by a low pass RC filter, then amplified, and finally threshold detected to give a digital output.

One of the main benefits of microwave sensors is they are not influenced by temperature, humidity, noise, air flow, dust, light, etc. They can also penetrate non-metallic walls.

A few common microwave sensor modules are provided below, followed by comparison table of their specs. These modules have their own signal conditioning, amplification, and thresholding circuitry built into the module, whereas HB100 and CDM324 are just the sensors where you have to provide your own external circuitry. More details on the modules below can be found in the article Microwave Motion Sensors.




Comparison of Microwave Motion Sensor Modules
Model RCWL-0516 CQRobot
SKU: CQRSENWB01
DFRobot
SEN0192
Operating Voltage 4V - 28V DC 3.3V / 5V ± 0.25V DC 5V ± 0.25V DC
Output Voltage
(High/Low)
3.3V / 0V 3.3V / 0V
5V / 0V
5V / 0V
Working Current 2.8mA (typical);
3mA (max)
37mA (typical);
60mA (max)
37mA (typical);
60mA (max)
Sensing Angle 360° Horizontal: 72°
Vertical: 36°
Horizontal: 72°
Vertical: 36°
Sensing Range 3m - 5m 2m - 16m 2m - 16m
Frequency ~ 3.2GHz 10.525GHz X-band 10.525GHz X-band
Operating
Temperature
-20°C to +80°C -20°C to +55°C -20°C to +55°C

Infrared Beam Sensors

A way of detecting when something crosses a threshold is using an IR beam, which works by emitting an IRInfrared beam of light to a receiver, where detection occurs when an object blocks the beam.

IR Beam Transmitter and Receiver Diagram

The IR beam is invisible to the naked eye. The human visible spectrum consists of wavelengths ranging from approximately 400nm to 700nm, but IR beams have wavelengths outside of this range that are typically around 900nm.

IR beams have a higher reliability of detection than other means of of motion detection, such as PIR and Microwave, but at the expense of a very narrow FOVField Of View: it only covers the line of sight of the beam, whereas PIR and Microwave sensors cover a much broader region.

However, a single IR beam can be triggered by leaves, birds, or insects getting in the path of the beam. These kind of false-alarms are mitigated by including additional IR beams that all have to be triggered together for detection. Also, ambient IR background radiation from sunlight or artificial heat sources can interfere with the receiver unless filtered, shielded, or pulsating the beam at a specific frequency to differentiate the signal from the background radiation.

Different kinds of IR Beam Sensor Products include IR emitters and receivers, through-beam, retroreflective-beam, and dual-beam.

MCU & Transceiver

The digital output signals from the motion detection sensors discussed here all have very low data rates, so you don't need a high end microcontroller for processing detection data. A low speed microcontroller with a few I/OInput/Output ports and small size will do the job, such as any of the options listed below.



A transmitter and receiver (or both combined in a transceiver) is needed for wireless communication. Many microcontroller boards have a WiFi transceiver integrated into the board, which would be the simplest setup.



Alternatively, you could connect an external WiFi module to the serial port of the microcontroller to establish a WiFi connection.



Another option is to use an RFRadio Frequency transceiver module to transmit data to the computer. Using RF modules would require more hardware compared to WiFi, since most computers already have WiFi, but RF modules generally have greater range, less power consumption, and are less prone to interference and/or traffic over your WiFi network.

You would need at least two RF modules, a transmitter connected to the microcontroller at the sensor and a receiver connected to the computer. RF modules transfer data to a computer over a UARTUniversal Asynchronous Receiver-Transmitter or SPISerial Peripheral Interface interface, which most SBCSingle Board Computers have, but if the computer does not have this interface then a conversion to USB with a microcontroller or USB Serial Adapter can be used.



Communication

When designing a monitoring system where a motion sensor with a microcontroller communicates with a computer or other device, some requirements need to be established on what data content will be exchanged and when that data is sent. Some considerations on data exchange are the following:

  1. Data Transmission and communication failures
  2. Periodic health status
  3. Disabling/Enabling sensors

Data Transmission

Motion detection events should be transmitted immediately when they occur so you can be alerted in real-time. If the communication fails, the event data can be stored in the microcontroller memory temporarily while it continues trying to send the message until it is received. When the communication is successful, the record in the microcontroller memory can be cleared.

Sensor Health Status

If your sensor or microcontroller stopped running for some reason, you would have no way of knowing without some kind of periodic operational health status check. If the sensor and microcontroller is powered from a battery or has a backup battery, then the battery level should also be checked periodically.

How often the health status should be sent depends on your sensor and microcontroller power consumption requirements: more frequent status checks will consumes more power. You can setup the microcontroller to send the status over regular intervals like a beacon or you can ping the microcontroller from the computer or other device.

One advantage of the beacon approach it can provide a status over smaller time intervals (e.g., every second) if power consumption is not an issue. The advantage of pinging the microcontroller status from the computer is when and who to ping can easily be adjustable in the computer program for all your sensors, which avoids sensor transmission collisions when you have multiple sensors sending their status at the same time.

Disabling/Enabling Sensors

There are circumstances where you would want to temporarily disable sensors from the computer or remotely, such as when making adjustments to the system or sensor, heavy traffic through the motion sensor, or weather conditions such as a storm that would trigger a lot of false alarms.

The embedded software in the microcontroller can be setup to accept a wireless command that would turn off sensor detection until another command is received to turn it back on.

Computer

The computer gateway receives data from all the motion detection sensors from a WiFi or RF receiver, reads in the data with a software interface, records the data, and can display the results on a monitor with some kind of dashboard.

If you don't have a computer available, it's worth mentioning that some WiFi microcontrollers, such as the ESP32 and the RPi Pico W, can also have a web server on them to create a web page displaying sensor results to your devices (phone, computer, tablet) over your network. Storing data on the microcontroller is limited, but you could store more data on an external SD card with a module or a USB flash drive with a USB host board.

Hardware

The computer hardware constantly monitors for any transmissions of motion detection and records the data. This means that the computer needs to be on 24/7. A desktop computer will work if left on all the time, but are often used heavily on a daily basis which may be an issue sharing resources and updating the operating system constantly would interrupt your monitoring system.

Single Board Computers (SBCSingle Board Computers) are relatively inexpensive compared to desktop or laptop computers, have a small form factor, can be left on all the time, don't require as many updates, and are typically not used for daily activities as much as a desktop computer. SBCs also consume a lot less power than a desktop computer and can last much longer on battery backup in the event of a power outage.



Software

The computer software can be designed to continuously read in the transmitted motion sensor data, record the data, and display the results. The software can also be programmed to control the behavior of the sensors, such as changing the sampling rate, turning it off/on, or setting specific time intervals to make measurements.

I/O Interface

RF Interface

For RF modules the receiver is usually connected serially to the computer. This can be done directly through a UARTUniversal Asynchronous Receiver-Transmitter or SPISerial Peripheral Interface interface on the GPIOGeneral Purpose Input Output of a SBC or through USB with a microcontroller or USB Serial Adapter. To collect data from the UART/SPI/USB port on the computer you can use the Python PySerial software interface. The functionality of this interface is described in more detail in the article Python PySerial I/O.

WiFi Interface

For WiFi communication, the software interface could be a TCP socket connection or a client-server configuration with the use of a standard protocol, such as HTTPHypertext Transfer Protocol, WebSocketWebSocket is a communication protocol, providing simultaneous two-way communication channels over a single Transmission Control Protocol (TCP) connection. WebSockets are typically run from a web browser connected to an application server that allows messages to be passed back and forth while keeping the connection open., or MQTTMQ Telemetry Transport (MQTT) is a lightweight publish-subscribe messaging protocol for small sensors and mobile devices, optimized for high-latency or unreliable networks. Historically, the "MQ" in "MQTT" came from the IBM MQ (then 'MQSeries') product line, where it stands for "Message Queue". However, the protocol provides publish-and-subscribe messaging (no queues, in spite of the name).. Since motion detection consist of short messages that have a low bandwidth, MQTT is a good choice for handling a lot of overhead.

Graphical Interface

Software on the computer can be used for controlling and monitoring data with a desktop application GUIGraphical User Interface or web server developed by the language of your choice (Python, C++, Java, etc.). In Python, there are many desktop GUI frameworks you can use like TKinter, wxPython, PyQT, PySide 2, Kivy, PySimpleGUI, and PyGUI. All of these frameworks are cross-platform that work in Windows, macOS, and Linux. TKinter is a built-in module in Python and the easiest to get up and running and learn, has a small footprint, and is a good choice for small applications.

Another option for data monitoring is using a web page as the GUI from a server that can be ran locally or by a hosting service over the internet. The advantage of using a web page as the front end of a monitoring system is that it can be accessed remotely either by hosting it yourself using port forwarding on your local network or from a hosting service. Python has web frameworks such as Flask, FastAPI, or Django. Flask is the easiest to get setup and running (you can get set up with just a few lines of code).

A simple example of displaying data from a door monitor in the form of a table is given in the figure below.

  • The first column is the door name based on the type of door or location. The text for each door name is a clickable link to open a page of the historical records for the door selected as shown in the next figure.
  • The second and third columns are the date and time when the door last changed its state (closed to open or open to closed).
  • The fourth column is the current state of the door (open/closed/offline). The offline state occurs if the door sensor is not sending data as expected (either due to a problem or intentionally disconnected).
Door Data Display

When a door name link is selected, this brings up a new page with a table that shows the history of door state changes. For example, if the front door link were selected, a table of its historical data with the most recent at the top would be shown as in the figure below.

Front Door Historical Records

This is just a simple two layer table example of displaying the data for a switch sensor, but many other ways of visualizing the data can be implemented.

Alert Notifications

When you are away from your computer, the server back-end can include the capability of automatically sending alert notifications by email and/or text messages that you can see on your phone when any motion detections occur. This additional feature of your monitoring system can be setup to allow you to turn the alert notifications on/off when needed.

In Python you can automatically send emails using the built-in smtplib module and the ssl module can provide TLSTransport Layer Security encryption. If you are using a Python web framework (Flask, FastAPI, or Django), there are extensions for these frameworks that can send the email for you. For example, Flask has the extension Flask-Mail to automatically send emails.

Text messages can be sent using services such as Twilio or Textbelt, but they can also be sent for free through your email server with SMSShort Message Service Gateways using the same routines used for sending emails.

Conclusion

Implementing a motion detection system gives you the capability of automatically detecting the presence of people, animals, or vehicles on your property. The hardware in this system includes sensors, microcontrollers, transceivers, and a computer.

Different sensors are used depending on the requirements of the application (range, FOVField Of View, power consumption, etc.). Magnetic contact switch sensors are useful for monitoring an opening, such as a door or window. PIR and microwave motion sensors are useful for monitoring activity in a broad region. IR beam sensors are used to detect when something crosses a threshold. These different sensors can also be used together and complement each other.

Data transmission between the sensors and computer can be wireless. Short range applications under 300ft can use WiFi, whereas RF modules have a longer range. The content of data communication between the sensors and computer may also include periodic health checks and control over the operation of the sensors.

Computer software with a desktop application GUIGraphical User Interface or web framework is used for recording and displaying data as well as controlling sensor operation. Web frameworks have the advantage of using existing web technologies (HTMLHyperText Markup Language, CSSCascading Style Sheets, JSJavaScript, etc.) for layout, styling, and dynamic content of web pages, which can also be accessed remotely either by hosting it yourself using port forwarding on your local network or from a hosting service.

Related Content

Article Rating

Sign in to rate this article

Sign In


(0) Comments

Sign in to leave a comment

Sign In