Dobrica Pavlinušić's random unstructured stuff
PIR: Revision 10
pir-pinout.jpg

BISS001 module

BISS001 - Micro Power PIR Motion Detector IC

  • Input voltage: 3-5 V
  • Hi: 0.7*Vdd = 0.7 * 5 V = 3.5 V
  • Lo: 0.3*Vdd = 0.3 * 5 V = 1.5 V

HC-SR501 module

Technical data of the HC-SR501 Motion and Sensor Modules:

Input voltage: 4.5 V - 20 V
Digital output when motion is detected: 3.3 V (high)
Digital output with no movement on the HC-SR501: 0 V (low)
Working temperature in the environment: -15 � C to 70 � C
Delay Time 0.5 to 200 seconds
Angle of coverage: 100 �
Reach 5m - 7m
Size of the HC-SR501 motion:

Sensor Lens diameter: 23mm
Length: 24.03mm
Width: 32.34mm
Height (with lens): 24.66mm
Center screw hole spacing: 28 mm
Screw hole diameter: 2mm (M2)

Collect pir data using Linux gpio and send it to mqtt

both pots are all the way to the left (if jumper is on the left toword edge of board) to make minimal timeout

pir.sh

gpio-utils

gpio-utils exists on Raspberry Pi

#!/bin/sh -e

led=/sys/devices/platform/rpi_control_board/leds/d1/brightness

# pir sensor connceted to 5V, GPIO12, GND
sudo stdbuf -oL -eL gpio-event-mon -n gpiochip0 -o 12 -r -f | while read gpio event time dir edge ; do
	case $dir in
		rising)
			echo -n "^"
			echo 1 > $led
			;;
		falling)
			echo -n "_"
			echo 0 > $led
			;;
		*)
			echo -n "?"
			;;
	esac
done

gpiod

alternative version using gpiod package available on sunxi

#!/bin/sh -e

led=/sys/class/leds/orangepi:red:status/brightness

# pir sensor connceted to 5V, PA6, GND
sudo stdbuf -oL -eL gpiomon 0 6 | while read event dir edge time ; do
	echo "# $dir"
	case $dir in
		RISING)
			echo -n "^"
			echo 1 > $led
			;;
		FALLING)
			echo -n "_"
			echo 0 > $led
			;;
		*)
			echo -n "?"
			;;
	esac
done