Sensors

Motion Sensors

Motion sensors detect movement or changes in the position, velocity or acceleration of an object. They are widely used in security systems, automatic lighting, alarms, robotics, appliances, industrial equipment, automotive systems and electronic control systems.

What Is a Motion Sensor?

A motion sensor is an electronic device that detects movement or changes in the physical state of an object or its surroundings.

Different motion sensors detect motion using different physical principles. Some detect changes in infrared radiation, while others use microwaves, sound waves, acceleration or changes in orientation.

How Motion Sensors Work

The sensor detects a physical change and converts it into an electrical signal.

Physical movement
       │
       ▼
Motion Sensor
       │
       ▼
Electrical Signal
       │
       ▼
Signal Processing
       │
       ▼
Controller
       │
       ▼
Alarm / Light / Motor / Display

Main Types of Motion Sensors

Common motion-sensing technologies include:

  • PIR sensors
  • Microwave sensors
  • Ultrasonic sensors
  • Accelerometers
  • Gyroscopes
  • Magnetic motion sensors
  • Optical motion sensors

PIR Motion Sensor

PIR stands for Passive Infrared.

A PIR sensor detects changes in infrared radiation within its field of view. Warm objects such as people emit infrared radiation, so movement across the sensor's detection area can produce an electrical output.

PIR sensors are commonly used for human-motion detection.

How a PIR Sensor Works

Human moves
     │
     ▼
Infrared radiation changes
     │
     ▼
PIR sensing element
     │
     ▼
Signal processing
     │
     ▼
Digital output

The sensing element itself detects changes in infrared radiation. The electronics surrounding it amplify and process the signal.

PIR Sensor Fresnel Lens

Many PIR motion sensors use a Fresnel lens in front of the sensing element.

The lens divides the sensor's field of view into multiple zones. As a person moves between these zones, the infrared signal received by the sensor changes.

This helps the PIR circuit detect movement.

PIR Detection Zones

       PIR SENSOR
           │
       Fresnel Lens
           │
     \  |  |  |  /
      \ |  |  | /
       \|  |  |/
        Detection
          zones

      Person →

Movement through the different detection zones produces changes in the infrared signal.

HC-SR501 PIR Module

The HC-SR501 is a commonly encountered PIR motion-sensor module used in microcontroller projects.

Typical modules provide:

  • Power input
  • Ground
  • Digital output
  • Sensitivity adjustment
  • Time-delay adjustment
  • Trigger-mode selection

The exact specifications depend on the particular module.

PIR Sensor Output

A PIR module commonly provides a digital output.

 No motion → LOW Motion detected → HIGH 

The controller can monitor this signal and perform an action when motion is detected.

PIR Sensor Sensitivity

Many PIR modules provide a sensitivity adjustment.

Increasing sensitivity can increase the detection range, although the actual behavior depends on the sensor and environment.

Excessive sensitivity can also increase unwanted triggering.

PIR Sensor Time Delay

Many PIR modules include an adjustable delay that determines how long the output remains active after motion is detected.

This can be useful for automatic lighting and alarm applications.

Microwave Motion Sensors

Microwave motion sensors detect movement using electromagnetic waves.

They commonly operate using a transmitter and receiver arrangement and detect changes in the returned signal caused by moving objects.

Microwave sensors can detect motion through some non-metallic materials, depending on the sensor frequency and construction.

Doppler Motion Detection

Many microwave motion sensors use the Doppler effect.

When an object moves relative to the sensor, the frequency of the reflected signal changes.

 Microwave transmitter │ ▼ Object │ ▼ Reflected signal │ ▼ Receiver │ ▼ Motion detection 

PIR vs Microwave Motion Sensor

Feature PIR Microwave
Detection principle Infrared radiation change Electromagnetic wave reflection
Detects people Yes Yes
Detects through some materials Generally no Possible depending on material
Power consumption Generally low Varies
Common application Security and lighting Security and automatic doors

Ultrasonic Motion Sensors

Ultrasonic sensors use sound waves above the normal human hearing range to detect objects and movement.

The sensor transmits an ultrasonic pulse and measures the returning signal.

 Transmitter │ ▼ Ultrasonic wave │ ▼ Object │ ▼ Echo │ ▼ Receiver 

Ultrasonic Distance Measurement

An ultrasonic sensor can determine distance from the time taken for an ultrasonic pulse to travel to an object and return.

For a simple echo measurement, the distance is related to the measured round-trip time and the speed of sound.

This makes ultrasonic sensors useful for both distance measurement and motion detection.

Accelerometers

An accelerometer measures acceleration.

Acceleration can be used to determine changes in movement, vibration, tilt or orientation.

Modern MEMS accelerometers are extremely small and are commonly found in mobile phones, wearable devices, vehicles and embedded systems.

MEMS Accelerometer

MEMS stands for Micro-Electro-Mechanical Systems.

A MEMS accelerometer contains microscopic mechanical structures whose movement changes an electrical signal.

The electronics measure these changes and provide acceleration data.

Three-Axis Accelerometer

A three-axis accelerometer measures acceleration along three axes:

 Z │ │ │ └────── X / / Y 

The three measurements are commonly represented as X, Y and Z.

Gyroscope

A gyroscope measures angular velocity, or how quickly an object rotates.

It is different from an accelerometer, which measures linear acceleration.

Gyroscopes are widely used in:

  • Mobile phones
  • Drones
  • Robotics
  • Game controllers
  • Navigation systems
  • Stabilization systems

Accelerometer vs Gyroscope

Sensor Measures Typical Use
Accelerometer Linear acceleration Movement, tilt and vibration
Gyroscope Angular velocity Rotation and stabilization

IMU

An IMU, or Inertial Measurement Unit, combines motion sensors to measure movement and orientation.

A typical IMU may contain:

  • 3-axis accelerometer
  • 3-axis gyroscope
  • Magnetometer

Combining these sensors allows a system to estimate orientation and movement more effectively.

Motion Sensor with a Microcontroller

A microcontroller can process motion sensor signals and control another device.

 Motion Sensor │ ▼ Microcontroller │ ├── Alarm ├── Light ├── Motor ├── Display └── Network 

Motion Sensor with ESP32

The ESP32 can interface with many types of motion sensors.

Examples include:

  • PIR modules using digital GPIO
  • Accelerometers using I2C or SPI
  • Gyroscopes using I2C or SPI
  • IMUs using I2C or SPI
  • Ultrasonic modules using GPIO timing

The appropriate interface depends on the sensor module.

Motion Sensor Wiring

Before connecting a motion sensor, determine:

  • Supply voltage
  • Ground
  • Output type
  • Logic voltage
  • Communication interface
  • Current consumption

Some sensor modules operate from 5 V while their signal outputs may have different voltage requirements. Always check the module specifications before connecting it to a microcontroller.

PIR Sensor Wiring

A basic PIR module normally has:

 VCC GND OUT 

The OUT signal can be connected to a suitable digital input.

 PIR OUT │ ▼ ESP32 GPIO │ ▼ Software 

Motion Sensor Interrupts

A microcontroller can use an interrupt input to respond immediately when a motion sensor changes state.

 Motion detected │ ▼ Sensor output changes │ ▼ GPIO interrupt │ ▼ Microcontroller ``` 

This can be useful when the microcontroller normally spends most of its time in a low-power state.

Motion Detection Range

Detection range depends on the sensor technology and physical installation.

Important factors include:

  • Sensor type
  • Sensor sensitivity
  • Object size
  • Object speed
  • Sensor orientation
  • Environmental conditions
  • Obstructions

Motion Sensor False Triggers

False triggering can occur when the sensor responds to something other than the intended target.

Possible causes include:

  • Temperature changes
  • Direct sunlight
  • Moving curtains
  • Air movement
  • Electrical interference
  • Animals
  • Improper sensor placement

The causes depend strongly on the sensor technology.

PIR False Triggers

PIR sensors can be affected by environmental infrared changes.

Possible sources include:

  • Direct sunlight
  • Rapid temperature changes
  • Heating equipment
  • Air-conditioning outlets
  • Moving hot objects

Correct sensor placement can significantly reduce unwanted triggering.

Motion Sensor Placement

Sensor placement is important for reliable detection.

Consider:

  • Detection direction
  • Detection range
  • Mounting height
  • Obstructions
  • Heat sources
  • Direct sunlight
  • Moving objects

PIR Sensor Orientation

A PIR sensor generally detects movement most effectively when a person moves across its detection zones rather than directly toward the sensor.

The exact detection pattern depends on the sensor and lens.

Motion Sensor Sensitivity

Sensitivity determines how easily the sensor responds to movement.

Too little sensitivity may cause missed detections, while excessive sensitivity may increase false triggers.

The optimum setting depends on the application and environment.

Motion Sensor Delay

Some motion sensors provide an adjustable output delay.

The delay determines how long the output remains active after a detection event.

This is particularly useful for automatic lighting and alarm systems.

Motion Sensor Applications

  • Security alarms
  • Automatic lights
  • Automatic doors
  • Occupancy detection
  • Robotics
  • Industrial automation
  • Vehicle systems
  • Smart-home systems
  • Energy-saving systems
  • Motion-activated cameras
  • Gaming devices
  • Wearable electronics
  • IoT systems

Motion Sensors in Security Systems

Motion sensors are commonly used as one part of an electronic security system.

 Motion Sensor │ ▼ Security Controller │ ├── Alarm ├── Camera ├── Light └── Network Notification 

The controller can combine motion information with other sensors such as door contacts and cameras.

Motion Sensors for Automatic Lighting

A motion sensor can turn a light on when movement is detected.

 Motion │ ▼ Sensor │ ▼ Controller │ ▼ Relay / MOSFET │ ▼ Lamp 

A timer can turn the lamp off after a specified period without detected movement.

Motion Sensor Testing

Testing depends on the sensor type.

For a basic digital motion module:

  1. Check the supply voltage.
  2. Check ground.
  3. Measure the output with no motion.
  4. Move an object through the detection area.
  5. Observe the output.
  6. Check the output delay.
  7. Adjust sensitivity if available.

Testing a PIR Sensor

A multimeter can be used to observe the PIR module's output.

 No motion │ ▼ OUT = LOW Motion │ ▼ OUT = HIGH ``` 

The actual output polarity depends on the module design.

Testing an Accelerometer

An accelerometer can be tested by reading its X, Y and Z outputs while changing its orientation.

A digital accelerometer should normally produce different readings when the sensor is rotated or accelerated.

The exact values depend on the sensor and its measurement range.

Testing a Gyroscope

A gyroscope can be tested by reading its angular-velocity output while rotating the sensor.

When stationary, the measured angular velocity should generally be near zero apart from sensor offset and noise.

Motion Sensor Faults

Symptom Possible Cause
No motion detected Power, wiring, sensor or configuration problem
Constant motion signal Sensor fault, environmental interference or incorrect configuration
False triggers Noise, environmental changes or poor placement
Short detection range Low sensitivity, obstruction or sensor problem
Digital sensor not detected Power, wiring, address or communication problem
Unstable readings Noise, vibration, poor power or sensor calibration

Motion Sensor Does Not Work

Check the following:

  • Supply voltage
  • Ground connection
  • Output wiring
  • Logic level
  • Sensor configuration
  • Detection area
  • Software
  • Sensor damage

Motion Sensor Always Active

If a motion sensor remains active continuously, possible causes include:

  • Environmental interference
  • Incorrect sensor configuration
  • Excessive sensitivity
  • Incorrect mounting
  • Wiring problems
  • Faulty sensor

Motion Sensor Has Short Range

Check:

  • Sensor sensitivity
  • Lens condition
  • Sensor orientation
  • Obstructions
  • Supply voltage
  • Target size
  • Target movement direction

Motion Sensor Replacement

When replacing a motion sensor, check:

  • Sensor technology
  • Supply voltage
  • Output type
  • Detection range
  • Detection angle
  • Response time
  • Current consumption
  • Operating temperature
  • Physical dimensions
  • Mounting method

How to Select a Motion Sensor

  1. Determine what type of movement must be detected.
  2. Determine the required detection range.
  3. Determine the required detection angle.
  4. Choose the appropriate sensing technology.
  5. Check the supply voltage.
  6. Check the output interface.
  7. Check response time.
  8. Consider environmental conditions.
  9. Consider false-trigger sources.
  10. Check mounting requirements.
  11. Check software compatibility for digital sensors.

Choosing Between Motion Sensor Types

Sensor Detects Typical Application
PIR Changes in infrared radiation Human motion detection
Microwave Movement through reflected electromagnetic waves Security and automatic doors
Ultrasonic Changes in reflected sound waves Distance and object detection
Accelerometer Linear acceleration Movement and tilt
Gyroscope Angular velocity Rotation and stabilization
IMU Combined motion information Robotics and navigation

Advantages of Motion Sensors

  • Enable automatic detection of movement
  • Can reduce energy consumption
  • Useful for security systems
  • Available in many technologies
  • Can interface with microcontrollers
  • Suitable for both simple and advanced systems

Limitations of Motion Sensors

  • Different technologies have different detection limitations.
  • Environmental conditions can cause false triggers.
  • Sensor placement affects detection performance.
  • Some sensors require signal processing.
  • Accelerometers and gyroscopes require interpretation of motion data.
  • Large detection areas may require multiple sensors.

Common Motion-Sensor Design Mistakes

  • Using the wrong sensing technology
  • Ignoring the sensor detection pattern
  • Incorrect mounting position
  • Excessive sensitivity
  • Ignoring environmental interference
  • Incorrect supply voltage
  • Incorrect logic-level connection
  • Ignoring output timing
  • Failing to filter noisy sensor data
  • Using an unsuitable replacement sensor

Key Points

  • Motion sensors detect movement or changes in physical conditions.
  • PIR sensors detect changes in infrared radiation.
  • Microwave sensors can detect movement using reflected electromagnetic waves.
  • Ultrasonic sensors use reflected sound waves.
  • Accelerometers measure linear acceleration.
  • Gyroscopes measure angular velocity.
  • IMUs combine multiple motion sensors.
  • PIR sensors are widely used for human-motion detection.
  • Sensor placement strongly affects detection reliability.
  • False triggering can result from environmental interference.
  • Microcontrollers such as the ESP32 can interface with many motion-sensor technologies.
  • Always check voltage, output type, detection range and environmental requirements before selecting a sensor.

Continue Learning About Motion Sensors

The next pages can cover PIR sensors, microwave sensors, ultrasonic sensors, accelerometers, gyroscopes, IMUs, wiring, characteristics, applications, testing, troubleshooting, replacement and selection.