Friday, September 22, 2023
Google search engine




What is a Motion Sensor and why we need it?

A motion sensor, or motion detector, is an electronic device that uses sensor(s) to detect nearby people or objects. Motion sensors are the newest and most sophisticated addition to any security system. When your home’s array of sensors detects movement – such as when you come in through the door carrying groceries – it’ll send off alerts for intruders without making too much noise by sounding alarms throughout your house!

Questions addressed in this blog
For using a Motion Sensor with Raspberry Pi Pico, what components do you require?
How to setup the hardware for connecting a motion sensor with Raspberry Pi Pico?
How to setup the software for connecting a motion sensor with Raspberry Pi Pico?
List of various Motion sensors that can be used?

If you are interested in building

Bill of materials:

  • A basic breadboard compatible with requirement and space available.
  • A motion sensor; usually PIR (Passive InfraRed) sensors are most commonly used for burglar alarms etc. But there are different types of motion sensors as you will get to know.
  • You will require about 6 male-to-female jumper cables
  • A Raspberry Pi Pico microcontroller
  • A LED light and a small resistor.

How to setup the hardware for connecting a motion sensor to Raspberry Pi Pico

  • First you have to place Raspberry Pi Pico in the breadboard in a way that it rests over the central channel. It is to be noted that the Micro USB port should be at the end of the breadboard.
  • Then put a resistor inline with the GND (ground pin) and the rail of the breadboard this resistor constricts the flow of current by converting it into heat energy.
  • After that you can add an LED to the breadboard and the GND rail.
  • Sensors usually have OUT, GND and VCC (in some cases VIN), so you should connect GPIO VCC to positive rail of the breadboard; GPIO GND to negative rail and GPIO OUT to any other blank rail
  • Connect the VCC to the pin right next to the resistor
  • You should connect GND pin of the Raspberry Pi Pico to the GND rail of the breadboard.
  • Then connect this circuit to your laptop using the micro USB lead mentioned in first step and open the IDE (Integrated Development Environment). 

(Usually the IDE used here is either Thonny for MicroPython or Circuit Python)

How to setup the software for connecting a motion sensor to Raspberry Pi Pico

  • Import PIN class from the machine library and then also import utime. These are libraries we can use to command our undertaking through the GPIOs
    The ‘machine’ module is utilized to manipulate on-chip hardware
from machine import Pin
import utime
  • You should create an object to create a relationship between the material GPIO pin and your software code. This object gives the command to GPIO pinto pull low; this is done to ensure that the GPIO pin is deactivated at the beginning of the undertaking.
    Here the LED is connected 25th pin of the chip
led = Pin(25, Pin.OUT)
  • Create a second (different) object to create a link between your software code and the OUT GPIO pin from the motion sensor
pirsensor = Pin(16, Pin.IN, Pin.PULL_UP)
  • Next step is to make sure the LED is switched off and that there is a gap of some few seconds. (Here 7 seconds)
  • You should use a do while loop (you can also use a ‘while loop’) to print the value of GPIO pin value used in real time by the motion sensor. This will tell you whether there is movement or not.
do while True:
  • Next you should form an if condition in the case of movement. You can choose what kind of condition you want to see in the LED in the event of movement like letting the light blink for say 3 seconds 
if pirsensor.value() == 0:
       print("LED On")
  • After that using else condition you should make a condition in the event of no movement. This signal should be significantly different than the case of movement or there will be chaos.
       print("Waiting for motion")
  • This if and else loop repeats and tests again. You can introduce some time lag after each cycle according to requirement.

Then save the program and run it.

An example of the software code is given below (it is a MicroPython code)

For the following we are connecting a PIR sensor on a Raspberry Pi Pico

from machine import Pin
import utime
led = Pin(25, Pin.OUT)
pirsensor = Pin(16, Pin.IN, Pin.PULL_UP)
while True:
   if pirsensor.value() == 0:
       print("LED On")
       print("Waiting for movement")

Types of motion sensors

This section covers  how do these different motion sensors detect motion? As well as what is the range of motion these sensors can detect?

Infrared Motion Sensors (IR sensors)

Features of IR sensors

  • It utilizes a chip and a transmitter to conclude whether the infrared rays through the transmitter is emitted from an object or a person.
  • IR sensors must be facing the direction of motion to register it.
  • It is usually installed outside of properties, buildings and establishments

List of IR Sensors

 Product nameDescription
Infrared Barrier Module; Obstacle Avoidance car obstacle avoidance Sensor
1. Module detects 2-30 cm range of area with a detection angle of 35°
2. You can relay a 5V almost instantly to the INPUT of microcontroller relay 
3. It can be used for a 3V to 5V DC power module, in simple terms this is the operating voltage.

Gikfun Obstacle avoidance IR Infrared Sensor Module Reflective Photoelectric Light Intensity DIY Kit
1. Module detects 2-30 cm range of area with a detection angle of 35°
2. You can relay a 5V almost instantly to the INPUT of microcontroller relay 
3. It can be used for a 3V to 5V DC power module, in simple terms this is the operating voltage.

(There are different brands but the product specifications are exactly the same)

Passive Infrared Motion Sensor (PIR Sensors)

Features of PIR Sensor

  • It usually consists of a camera that senses the IR radiations and are supposed to detect changes in Infrared waves rather than telling whether the rays come from a person or object
  • PIR sensors identify the variations in the  range of energy near it.
  • PIR sensors are generally not facing varied environmental conditions as they wont give correct readings. Thus they are usually preferred to be put indoors of establishments.
  • PIR don’t emit Infrared rays instead they detect infrared waves of surroundings.

List of PIR Sensors

 Product NameDescription
HC-SR501 PIR Infrared Sensor Human Body Infrared Motion Module
1. Operating voltage range 4.5V to 20V
2. Sensor Angle is less than 100°.
3. Block time is 2.5 seconds
4. Delay time is 5 to 18 seconds
5. Quincent current less than 50 uA
Stemedu HC-SR501 PIR Sensor Infrared IR Body Motion Module
1. The operating voltage ranges from 4.5V to 20V
2. Quincent current less than 50 uA
3. It output timing is 0.5 s to 200 s
4. Angle sensor is less than 100° cone angle lens size
5. Block time is 2.5 seconds of the sensor
AM312 Mini Human Sensor Module IR Pyroelectric Infrared PIR Motion Sensor Detector Modules
1. Working voltage 2.7V to 12V
Angle sensor is less than 100° cone angle lens size
2. Delay time is 2 seconds
3. Blocking time is 2 seconds
EKMB & EKMC Wide Field of View PIR Motion Sensors ( Industrial use)
1. Distance varies from 5mm to 7 m depends on different models
2. 1uA to 350uA operating supply current range. Has a lot of variations 
3. Maximum Supply Voltage from 3.4V to 7V, different models
4. Minimum Supply Voltage from -0.3V to 3V depending on different models.

Microwave Sensor 

Features of Microwave Sensor

  • Microwave sensors spawn an electromagnetic field between transmitter and receiver, creating an invisible volumetric detection zone. When any motion takes place in the detection zone, changes to the field are registered and necessary actions are then taken.
  • Easy to install
  • They provide high probability of detection
  • Low nuisance alarms.
  • They have resistance to rain, fog, wind, dust, falling snow and temperature extremes.

List of Microwave Sensors

 Product NameDescription
Sensinova Microwave Motion Sensor
1. Detection range of Sensinova is 360 degrees. 
2. It has a power source range pf 220-240 v/ac
3. It has 5.8 GHz CW radar. 
4. Rated load of the sensor is max.1200 W. 
5. Detection distance range of the system is adjustable between 1-8 m (radius).
6.Time delay is adjustable between 10 sec ± 3 sec to 12 min ± 1 min. 
7.Ambient light of the sensor adjustable between 3-2000 lux

INTREPID MicroWave 330– (Industrial)
1. It has a wide range of 457 meters
2. It has a software-controlled ecosystem
3. It has a built-in synchronizer to
prevent interference between sensors 
4. It operates at K-Band (24.125 GHz) frequency.

INTREPID™ Model 334– (Industrial)
1. It has a range of 183 meters
2. It has Low Power Consumption
3. It has the feature of Extended Burn-in And Temperature Testing

Tomographic Sensors

Features of Tomographic sensors

  • Tomographic sensors work by encompassing an area with nodes that correspond with each other using radio waves to create a mesh network. It banks on disturbances of the mesh network to detect movement within an area. Each network has its own processing unit (PU), which normally have closed contacts for comfortable integration with any standard panel.  
  •  Tomographic sensors have a very low false alarm percentage.
  • They do not rely on line of sight and thus their motion sensing cannot be obstructed by objects moving in vicinity of the nodes in the network.
  •  It provides a massive coverage of area and can go up to 5,000 square feet and they can be completely hidden from the sight.
  • It is used in to protect high value assets, used in chaotic environments

List of Tomographic Sensors

 Product NameDescription
Xandem TMD
1. The detection area is 50 metres square with respect to a 6-node Xandem solution and 500 metres square with respect to a 15-node solution. 
2. Supply voltage is 12V DC for nodes and processing units 
3. Current supply required is 34-50mA.
4. You can select from around 16  Xandem channels which range between 2.403GHz and 2.480HGz. Installers can vary these channels from their factory default settings as per the requirement of the user. 

Combined Types of Motion Sensor

Features of combined types of motion sensors

  • As the name suggests, this kind of sensor is formed by combining different motion sensors as named above.
  • This helps to tune out fake alarms, but a drawback is that the disturbance should be noticed by all sensors combined or else motion can go undetected.
  • For instance, a dual microwave or PIR sensor will begin on the passive infrared sensor setting, because that consumes energy to a lesser extent. When the passive infrared sensor is skipped or bypassed , the microwave division will switch on. Then if the remaining sensor is also skipped or bypassed , the alarm will generate sound indicating that it has detected some motion.

List of combined types of motion sensors

 Product NameDescription
Dual Tech Microwave & P.I.R. Motion Sensor
( By Honeywell )
1. It consists of Digital Dual Technology
2.Sensor as discussed is a combination of any of the above sensors
3. Infrared sensor used -Quad Passive Infra Red Sensor
4. It consists of a Microwave Sensor as well
Intelligent Pet Immunity (domestic pets don’t trigger the sensors)
5. Combined Sensing Technology to Eliminate False Motion Detection
6. Detection range is up to 12m
Detection angle 85°
7. Creep Zone View: Detection range starts from just 1 meter from the sensor
8. Additional features: Unique Temperature, Compensation Logic, 3 Level Sensitivity Control for P.I.R. function, 2 Level Sensitivity Control for Microwave function, Advanced Sealed Optics, Walk Test
Wall Mounted Inbuilt Tamper Switch
Honeywell DT8016AF5
1. PIR an Microwave combined
2. Range of detection is 16 – 21 metres
3. Walk test results are 30 seconds
4. Frequency in X-band region 10.587 GHz
5. Power requirement range 9-15V
6. Current consumption from 9 mA to 14 mA

Ultrasonic Sensor

Features of combined types of Ultrasonic sensors

These sensors have a transmitter which emits the ultrasonic sound to sense the movement and receiver to catch the sound after it hits the target and returns.

List of Ultrasonic Sensors

 Product NameDescription

image credit
1. Range of sensing is from 2 cm to 4 m
2. Its working frequency is 40Hz
3. The measuring angle is 15°
4. Its working voltage is 5V DC
image credit
1. The voltage range is 3V to 5.5V
2. The range can differ at lesser voltage 
3. Its working frequency is 40Hz
4. The measuring angle is 15°

For further more information on how to connect ultrasonic sensors to raspberry pi pico. Click here



Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments