LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-01-2021, 10:42 AM   #1
floppy_stuttgart
Member
 
Registered: Nov 2010
Location: EU mainland
Distribution: Debian like
Posts: 908
Blog Entries: 4

Rep: Reputation: 86
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).
 
Old 05-01-2021, 12:01 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, RPi OS, Mint & Android
Posts: 12,858

Rep: Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Build a motion detection system with a Raspberry Pi LXer Syndicated Linux News 0 11-24-2020 09:12 AM
LXer: How to Build a Raspberry Pi Motion Sensor LXer Syndicated Linux News 0 05-15-2020 02:27 PM
[SOLVED] motion script now runs motion without sudo sdowney717 Linux - Newbie 9 07-07-2017 06:11 PM
LXer: Raspberry Pi motion detection LXer Syndicated Linux News 0 08-21-2014 12:51 PM
Why and What is the best" Motion" or "ZoneMinder" for motion detection? MODYSAMA Linux - Newbie 3 07-06-2011 07:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration