Motion Detector PIR Sensor

PIR motion sensor
PIR Motion Sensor


Circuit, Wiring | Power Supply | PCB | Pictures


Source code

Project Specifications

  • PIC:PIC18F25K20
  • PIR Sensor:Sure DC-SS502

Circuit detect human movement in a space.
this project use PIC18F25K20 microcontroller to detect if the sensor change state and it will emit a sound from the speaker or piezo, the MCU also detect the voltage of the battery in the startup, the algorithm it´s very simple use an interrupt on change to detect the change on the PIR sensor.

PIR Sensor PIR sensor

Circuit Diagram

Electronic Circuit Diagram - Motion Detector

motion sensor electronic schematic

Power Supply

Power Supply Circuit Diagram - Motion Detector

VDD output is 3,3V, in this circuit 9V battery is connected to a IC L317T but input voltage can be 8 to 24V DC.
Calculate VDD value: VDD = 1,25 * (R2/R1+1)
Power On - when circuit start, a delay come to MCU generate a unknowed state, to avoid circuit malfunction, R6 and C1 make a RC delay filter, calculate delay with: τ = R * C

Power supply motion sensor electronic schematic

Motion Detector PCB


Qt. References Value
2 R1, R3 380Ω
1 R2 240Ω
2 R4, R5 46Ω
1 R6 22KΩ
3 R7-R9 1KΩ
1 C1 1µF
2 C2, C3 15pF
1 U1 LM317T
1 U2 PIC18F25K20
1 Q1 BC338
1 D1 1N4001
1 BAT1 9V
1 LED1 Green
1 LED2 Blue
1 SPEAKER Speaker/Piezo
1 X1 16MHz

PCB layout


PCB layout


PCB layout

Source code files - Motion Sensor

PIR Sensor Source (HEX)

Project Pictures

motion detector project picture


Circuit have a 8Ω speaker but piezo can be used, transistor BC338 (Q1) is used because sound have low level and should be able to ear from a different division, with BC338 transistor β = 35. Transistor Ic can be calculate with this equation:
Vcc - (Rb * Ib) - Vbe = 0


Author: Hélio Pereira