-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: external trigger recording #842
Comments
I like this too. When using infra red illumination for night motion detection a big problem is the insects are attracted to IR lights causing so many false alerts outdoors IR motion detection is useless. Using PIR as a second trigger eliminates false alerts from insects... But just PIR can also cause false alerts from natural movement of leaves, wind etc. Combining both.... PIR + Motion = Recording with no false alerts :-) |
+1 this. I want use Piface2 board for trigger from PIR. |
A quick glance at motion source code suggests that USR1 signal is supposed to trigger a movie recording, and ALRM signal supposed to record a timelapsed image. I did a quick test by send both signals to motion, but didn't seem to make any difference. |
I remember testing that stuff with signals and it sometimes crashed and sometimes didn't work at all. I don't recall it ever working :) Anyways this was for motion 3.x. I hoped things have changed with 4.x. |
I hacked motion and got external trigger to work. Motion has Patch file attached if anyone wants to use it, just remove the txt file extension. |
+1 on this request, I have 5 Pi Zero W with PIR's ready for testing. |
Do all PIRs output the same signal e.g. output pulse low when there is motion? The pulse duration is not the same as the detected motion duration? |
They Pulse high, The two popular and inexpensive models which I have used are linked below. I currently have the SR505's wired to GPIO15 on the Pi Zero's The behaviour is simple enough, The output pin is pulled low when there is no motion and goes high (3.3v) when motion is detected. On the SR505's this is hard wired to ~8s although there are variants that have different but fixed times. If it continues to see motion it seems to stay high, although it may be going low momentarily and then re-triggering. The SR501 has a trim pot that allows for adjustment of the pulse duration (0.3-600s). But this model is quite big. It seems the simplest would be to start the motion event when the pin goes high and pole it once a second after that, and continue that motion event until it's low for >1s. This would accommodate either of these PIR sensors as well as dry contacts on doors quite well. Another use case I want to use this for is the output from a car alarm, this way installations in cars don't need to process all the motion on the street, but when the shock sensor senses something, then it can record. HC-SR505 Mini-Body Sensor Switch HC-SR501 Adjust IR Pyroelectric Infrared PIR Motion |
I'm not familiar with motioneye code, but after a quick glance at the code, I would do something like this:
import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
PIR_PIN = 15
GPIO.setup(PIR_PIN, GPIO.IN)
def poll_pir():
# to be called once per second
if not GPIO.input(PIR_PIN):
motion_pid = motionctl._get_pid()
if motion_pid is not None:
os.kill(motion_pid, signal.SIGUSR2)
def pir_motion_detected(PIR_PIN):
motion_pid = motionctl._get_pid()
if motion_pid is not None:
os.kill(motion_pid, signal.SIGUSR1)
GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=pir_motion_detected)
@ccrisan can definitely tell us where's an appropriate place to add PIR handler code. |
This can indeed be added somewhere in |
@ccrisan After having a greater understanding of motion software, I have to agree with you that it's better done via the HTTP API. There are 2 scenarios an external trigger can be used.
Both scenarios can be useful as pointed out by various users here. OR scenario can be done by hitting AND scenario can be done by hitting |
Yeap, both scenarios are valid and useful, each for its own use case. The best way to go about it is to implement the HTTP requests in some functions in motionctl.py and expose them (1) via a meyectl command and (2) via web handlers to motionEye's UI. The former is probably the most useful for users that want to control motion themselves. |
@ccrisan Yes, your 2nd option would be really nice. I don't see a need for meyectl. If someone wants more complicated trigger control, they can hit motionEye's HTTP interface directly from their program. |
Completely new to GIT/motioneyeos, very keen to understand the architecture and coding of the system. However, I have not even managed to locate the Python and C source code. Where to start? |
@William1Lam Front-end code is motioneye. |
Thank you very much for the info.
From: jasaw [mailto:notifications@github.com]
Sent: 03 July 2017 00:56
To: ccrisan/motioneyeos
Cc: William1Lam; Mention
Subject: Re: [ccrisan/motioneyeos] Request: external trigger recording (#842)
@William1Lam <https://github.com/william1lam> Front-end code is motioneye <https://github.com/ccrisan/motioneye> .
Motion code here <https://github.com/Motion-Project/motion> .
Motioneyeos repo is the build system to compile all the required programs and libraries into disk images for various platforms. Motioneyeos repo does not contain the program source code.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#842 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AcdUHyOMQ0yXhj6rw7iDE9UiE2D7R_S6ks5sKC3-gaJpZM4MkTYW> .Image removed by sender.
|
Hi! Any updates on this and the web handlers? |
On implementing such a feature, it would be perfect, if notification (mail, etc..) can be set up for each trigger type. I want to integrate motioneyeos into a doorbell, having it save a picture on motion, but only notifying if doorbell button is pushed. |
I'm also looking forward to have kind of feature on MotionEye OS. |
+1 and thank you for labeling it as 'feature request'. Look foward to seeing that web handler in motioneye I am more inclined to the |
I would like to trigger a snapshot via http-request (and then download the still-image to display it in my Home-Automation-System (FHEM)). Is there a way to do this? |
@jorgekramer use the Snapshot URL (which includes the required authorization signature as well). |
Tanks, it works. Is there also a way to trigger a snapshot in motioneye (e.g. if PIR in the Home-Automation-System detects motion) - and then send this image to a ftp-server? |
I have mine set to zero for motion sensitivaty and it detects everything but i want mine to be used at night only, the camera is raspberry pi noir v2 ir camera, also 36 x ir 940nm leds that all turn on, gives perfect night vision in zero light for around 30feet, detects nothing at night but sees everything, the settings are all good, need a pir motion sensor to be added but how, i see lots of interest has been shown for the past year or two but no one has added this yet, why? simple arduino/raspberry pi pir sensors are advertised everywhere and very cheap. |
@stefi01 If you want your PIR sensor to trigger motion detection and start recording, do this:
|
@jasaw ok thanks for explaining, sounds easy enougth, i use my camera for night vision to see what is roaming around, i live up in mountains in california so i never know what to expect but the camera alone does not detect at all using the ir and 36 940nm leds plus another 36 on an add on board, motion setting set to zero and 2 frames to detect so i am hoping the pir works better, if i get stuck i will ask again and show what i have done but if it works then i could post those results too as it may help others i wish i found this software sooner before i started experimenting with others that dont even come close to this awsome software :) thank you for sharring |
Open the local browser on the Pi, and check http://localhost:7999 and |
I am building a Pi3B+ right now, latest Raspbian and updates and instructions from Wiki, with the changes I listed above. |
On the raspberry localhost:7999 works! |
What does command |
pi@raspberrypi:~ $ ip a |
OK, interesting it can't find itself via IP. |
yes I can ping from raspberry. I can ping from pc pc also... in the same raspberry runs a local BLYNK server and I didn't have similar problems |
what port(s) does BLYNK use? |
honestly I don't know... If I change the webcontrol_port from 7999 to another? for example 7888? |
I missed a setting: # the TCP port that motion HTTP control interface listens on Sorry, lack of caffeine. |
restart motioneye or reboot... |
Built a clean new Desktop image of RaspberryPiOS (2021/05/07 start) with all patches and updates. |
I tried to change the port to 7888 also but nothing: path to the configuration directory (must be writable by motionEye)conf_path /etc/motioneye path to the directory where pid files go (must be writable by motionEye)run_path /var/run path to the directory where log files go (must be writable by motionEye)log_path /var/log default output path for media files (must be writable by motionEye)media_path /var/lib/motioneye the log level (use quiet, error, warning, info or debug)log_level info the IP address to listen on(0.0.0.0 for all interfaces, 127.0.0.1 for localhost)listen 0.0.0.0 the TCP port to listen onport 8765 path to the motion binary to use (automatically detected if commented)#motion_binary /usr/bin/motion whether motion HTTP control interface listens onlocalhost or on all interfacesmotion_control_localhost false the TCP port that motion HTTP control interface listens onmotion_control_port 7888 interval in seconds at which motionEye checks if motion is runningmotion_check_interval 10 whether to restart the motion daemon when an error occurs while communicating with itmotion_restart_on_errors false interval in seconds at which motionEye checks the SMB mountsmount_check_interval 300 interval in seconds at which the janitor is calledto remove old pictures and moviescleanup_interval 43200 timeout in seconds to wait for response from a remote motionEye serverremote_request_timeout 10 timeout in seconds to wait for mjpg data from the motion daemonmjpg_client_timeout 10 timeout in seconds after which an idle mjpg client is removed(set to 0 to disable)mjpg_client_idle_timeout 10 enable SMB shares (requires motionEye to run as root)smb_shares false the directory where the SMB mount points will be createdsmb_mount_root /media path to the wpa_supplicant.conf file(enable this to configure wifi settings from the UI)#wpa_supplicant_conf /etc/wpa_supplicant.conf path to the localtime file(enable this to configure the system time zone from the UI)#local_time_file /etc/localtime enables shutdown and rebooting after changing system settings(such as wifi settings or time zone)enable_reboot false timeout in seconds to use when talking to the SMTP serversmtp_timeout 60 timeout in seconds to wait for media files listlist_media_timeout 120 timeout in seconds to wait for media files list, when sending emailslist_media_timeout_email 10 timeout in seconds to wait for zip file creationzip_timeout 500 timeout in seconds to wait for timelapse creationtimelapse_timeout 500 enable adding and removing cameras from UIadd_remove_cameras true enables HTTP basic authentication scheme (in addition to, not instead of the signature mechanism)http_basic_auth false overrides the hostname (useful if motionEye runs behind a reverse proxy)server_name motionEyewebcontrol_port 7888 I don't know why there is this formatting.... |
I don't know. Works on my Production motionEye hub, and several test machines ( motionEye on other OSs, and RaspberryPiOS on various hardware. If not, my suggestion would be to start clean on a different USB or SDCard (save this setup) As to the freaky text formatting, MarkUp (here in Github) thinks '#' as the first character on a line designates BOLD |
here you are: |
Yours:
|
I'm scared about this... |
Don't use your current SDCard or USB stick. Use a new (different) one. Keep the current one to switch back to. |
many thanks for your support and patience. I'll schedule this new installation soon... |
I checked the configuration and I missed a part.... (motion.conf). So it was only necessary: edit /etc/motioneye/motioneye.conf and /etc/motioneye/motion.conf: Many thanks again! |
Hi, i try run script about motion control by PIR connected to the Raspberry Pi Zero W (the same effect on two diffrent Pi and SD Card): motion.conf: motioneye.conf: motion.log many thanks |
In motioneye.conf: |
the same effect, any other idea? |
@tonicxx what do you get when you run the command: This line: |
i get: Pi Zero W restarting after i add line "motion_control_port 7999" to motioneye.conf, if i remove them Pi Zero W working correctly, i try use 4 diffrent SD card with new installation and the same effect, any idea? |
What do you get if you open a browser and go to |
i see: |
Motion is watching the port correctly. |
Hello,
Would it be possible to add a feature where a camera will record when prompted by an external trigger on a GPIO of the Pi, such as a PIR sensor.
Thanks Ben.
The text was updated successfully, but these errors were encountered: