LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to detect with a bash script if a raspberry pi motion was detected with a movement detection sensor? (https://www.linuxquestions.org/questions/programming-9/how-to-detect-with-a-bash-script-if-a-raspberry-pi-motion-was-detected-with-a-movement-detection-sensor-4175694570/)

floppy_stuttgart 05-01-2021 10:42 AM

how to detect with a bash script if a raspberry pi motion was detected with a movement detection sensor?
 
Hello,
I have a raspberry PI with camera for motion detection. All fine so far: it send mails with photo and store a video when motion is detected (a bash command line in the motion configuration file make this).

When the sun is hiding/appearing, my camera detect motion too. The idea now is to use another sensor in parallel for detecting any physical movement and filter that sunlight (or nights the headlamps from cars around the house).
I could use this sensor http://raspberry.tips/raspberrypi-tu...ry-pi-auslesen in parallel to the camera motion detection.

Now the question is: 1. how to set an environment variable in a python script or 2. how to ask the status of an GPIO via a bash command?

1.
a) inside the python script. how?
b) check it outside the script. how?
for example in the python script sensor_high=1 (how to define this as global bash variable?)
for example outside the python script .. && $sensor_high==1 && etc. ?

2.
Or perhaps the variable is not necessary to be set as global environment variable because the bash could ask directly the GPIO pins was high the last minute probably with a separate script as cron job like

cron script
while 1
if GPIO.input(7)==1 then
$High = 1
wait 60

bash command in motion.conf
..(GPIO.input(7)==1 || $High==1) && etc.

Any advices are welcome (I am still searching in parallel).

business_kid 05-01-2021 12:01 PM

If you're at motion detection, do not overlook 2 sensors from house alarms which might simplify your task
  1. There is a thing called an inertia sensor. Imagine two vertical metal plates (a, b) with a hole drilled through them both, and a bar lying there joining them electrically. If you tap it, the bar lifts, and the sensor goes off. Modern ones are piezo-electric, but the function is the same.
  2. As the Pi gets hot, it is a source of infra-red heat. There is a device called a Passive Infra Red (PIR) detector which checks for the movement of infra red heat from one area to another, and triggers if it finds it.

Both of these are pretty cheap and adjustable for sensitivity. You can also rig your own, but we won't go there.


All times are GMT -5. The time now is 12:25 PM.