MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Motion Detection with RaspiCam, Non-Module version

    Scheduled Pinned Locked Moved Tutorials
    47 Posts 13 Posters 51.4k Views 17 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      dam4 @jasonarends
      last edited by dam4

      @jasonarends
      My motion.conf is located in my home directory. I looked for /etc/motion and I don’t have a directory called motion in /etc. So I made one and put motion.conf in there. My screen still doesn’t shut off. I did look over my motion.conf file and all my settings were exactly like yours. I did follow all the steps at the beginning of this post. I can also type in vcgencmd display_power 0 and it turns off the monitor and vcgencmd display_power 1 turns it back on. This is really getting frustrating. Thank you for your help.

      I also copied your updated_motion.conf.sh and double checked it and they match with the exception yours has a .sh at the end where mine does not. Is it supposed to have the .sh on the end of the file name or did it get added due to it being uploaded?

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jasonarends @dam4
        last edited by

        @dam4
        Does your camera work outside of motion? Can you do

        raspistill -o cam.jpg
        

        and get a picture?

        If so, try launching motion with:

        /usr/local/bin/motion -c /etc/motion/motion.conf
        

        just to be sure that it’s reading the correct file, and then if you can watch the output and paste it here (or pastebin if it’s large) it might help us troubleshoot.

        Here’s what the first part of mine looks like with some of the config stuff cut out:

        [27690520:motion] [NTC] [ALL] motion_startup: Motion 4.0.1+gitb103dc0 Started
        [27690520:motion] [NTC] [ALL] motion_startup: Logging to syslog
        [27690520:motion] [NTC] [ALL] motion_startup: Using log type (ALL) log level (INF)
        [27690520:motion] [INF] [ALL] conf_output_parms: Writing configuration parameters from all files (1):
        [27690520:motion] [INF] [ALL] Thread 0 - Config file: /etc/motion/motion.conf
        ---snip---
        [0:motion] [NTC] [ALL] main: Camera ID: 0 is from /etc/motion/motion.conf
        [0:motion] [NTC] [ALL] main: Camera ID: 0 Camera Name: (null) Device: /dev/video0
        [0:motion] [NTC] [ALL] main: Waiting for threads to finish, pid: 30877
        [1:ml1] [NTC] [ALL] motion_init: Camera 0 started: motion detection Enabled
        [1:ml1] [NTC] [VID] vid_start: Opening MMAL cam
        [1:ml1] [NTC] [VID] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 640 x 480 at 4 fps
        [1:ml1] [NTC] [VID] create_camera_component: MMAL camera component created
        [1:ml1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
        [1:ml1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 2 items
        [1:ml1] [INF] [ALL] mlp_detection: Lightswitch detected
        [1:ml1] [INF] [EVT] event_new_video: Source FPS 4
        [1:ml1] [NTC] [ALL] motion_detected: Motion detected - starting event 1
        
        
        D 1 Reply Last reply Reply Quote 0
        • D Offline
          dam4 @jasonarends
          last edited by dam4

          @jasonarends
          I did get a picture when I typed that in so I know my camera is working.

          Here is the link to my config stuff.

          config stuff

          it sits there and my screen never blanked out, but I did notice that when I moved the block in front of the camera it did do something and when I put it back it did shut off the monitor.

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            jasonarends @dam4
            last edited by

            @dam4 sounds like it might be working - especially based on these lines:

            [1:ml1] [NTC] [ALL] motion_detected: Motion detected - starting event 1
            display_power=1
            ...
            [1:ml1] [NTC] [ALL] mlp_actions: End of event 1
            display_power=0
            

            I found a couple other config options and I think I was able to disable all the “event_newfile: File of type 2 saved to: /run/shm/lastsnap.jpg” stuff. I wonder if that’s what was causing memory leaks for @bhepler I set the pre_capture and post_capture to 0

            You might need to play with some of the settings for threshold and event_gap to get it to behave like you want but it sounds like you’re almost there. I set mine up in pm2 like mentioned earlier in the thread and it’s been working fine for the last day for me.

            D 2 Replies Last reply Reply Quote 1
            • D Offline
              dam4 @jasonarends
              last edited by

              @jasonarends
              How would I set it up in pm2? I’d like to try it.

              1 Reply Last reply Reply Quote 0
              • D Offline
                dam4 @jasonarends
                last edited by yawns

                @jasonarends
                I feel I am so close I followed the instructions exactly and I have motion started in pm2. it still doesn’t work. As I checked the motion-error-2.log I am seeing the following;

                Error: Cannot find module '/home/pi/motion'
                    at Function.Module._resolveFilename (module.js:469:15)
                    at Function.Module._load (module.js:417:25)
                    at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:73:21)
                    at Module._compile (module.js:570:32)
                    at Object.Module._extensions..js (module.js:579:10)
                    at Module.load (module.js:487:32)
                    at tryModuleLoad (module.js:446:12)
                    at Function.Module._load (module.js:438:3)
                    at Module.runMain (module.js:604:10)
                    at run (bootstrap_node.js:383:7)
                

                This is displayed over and over. I have checked for the directory /home/pi/motion and it is there. What am I missing?

                bheplerB 2 Replies Last reply Reply Quote 0
                • bheplerB Offline
                  bhepler Module Developer @dam4
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • bheplerB Offline
                    bhepler Module Developer @dam4
                    last edited by

                    @dam4 Hmm. It sounds like a permissions issue. IIRC, you installed motion with sudo. It’s possible that the pm2 process doesn’t have rights to the motion folder.

                    If you enter ls -ah /home/pi/motion, what does that return?

                    D 2 Replies Last reply Reply Quote 0
                    • D Offline
                      dam4 @bhepler
                      last edited by

                      @bhepler
                      This is what I get when I type that in.
                      pi@raspberrypi:~ $ ls -ah /home/pi/motion
                      . CONTRIBUTING.md mask1.png netcam_ftp.h rotate.o
                      … COPYING md5.c netcam_ftp.o stream.c
                      aclocal.m4 copyright md5.h netcam.h stream.h
                      alg.c CREDITS md5.o netcam_http.c stream.o
                      alg.h .depend mmalcam.c netcam_http.h test_builds.sh
                      alg.o draw.c mmalcam.h netcam_http.o track.c
                      autom4te.cache draw.o mmalcam.o netcam_jpeg.c track.h
                      camera1-dist.conf event.c mmx.h netcam_jpeg.o track.o
                      camera1-dist.conf.in event.h motion netcam.o .travis.yml
                      camera2-dist.conf event.o motion.1 netcam_rtsp.c version.sh
                      camera2-dist.conf.in FAQ motion.c netcam_rtsp.h video_bktr.c
                      camera3-dist.conf ffmpeg.c motion-dist.conf netcam_rtsp.o video_bktr.h
                      camera3-dist.conf.in ffmpeg.h motion-dist.conf.in netcam_wget.c video_bktr.o
                      camera4-dist.conf ffmpeg.o motion_guide.html netcam_wget.h video_common.c
                      camera4-dist.conf.in .git motion.h netcam_wget.o video_common.h
                      CHANGELOG .gitignore motion.init-Debian normal.jpg video_common.o
                      CODE_STANDARD INSTALL motion.init-Debian.in outputmotion1.jpg video_loopback.c
                      conf.c ISSUE_TEMPLATE.md motion.init-FreeBSD.sh outputnormal1.jpg video_loopback.h
                      conf.h jpegutils.c motion.init-FreeBSD.sh.in picture.c video_loopback.o
                      config.h jpegutils.h motion.o picture.h video_v4l2.c
                      config.h.in jpegutils.o motion.service picture.o video_v4l2.h
                      config.log logger.c motion.service.in pwc-ioctl.h video_v4l2.o
                      config.status logger.h motion.spec raspicam webhttpd.c
                      configure logger.o motion.spec.in README.md webhttpd.h
                      configure.ac Makefile netcam.c rotate.c webhttpd.o
                      conf.o Makefile.in netcam_ftp.c rotate.h
                      pi@raspberrypi:~ $

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        dam4 @bhepler
                        last edited by

                        @bhepler The motion works only when MagicMirror isn’t running. I have it starting with pm2. When MagicMirror is running the motion doesn’t work. Any suggestions?

                        bheplerB 1 Reply Last reply Reply Quote 0
                        • bheplerB Offline
                          bhepler Module Developer @dam4
                          last edited by

                          @dam4 What the hell… ls is the “list” command. It should only show you the listing for the file, including dates and permissions. But it’s… executing.

                          Just to be sure: pm2 shows two separate processes when you type pm2 status, correct?

                          D 1 Reply Last reply Reply Quote 0
                          • D Offline
                            dam4 @bhepler
                            last edited by

                            @bhepler I copied and pasted exactly what you wrote for the command to make sure I didn’t mistype something.
                            Yes there are two processes running when I type pm2 status. One is MagicMirror and the other is motion.

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              trividar
                              last edited by

                              Does anyone get it to work on stretch? I tried it but without success.

                              F 1 Reply Last reply Reply Quote 0
                              • A Offline
                                AnduriI
                                last edited by

                                Hey there,

                                I have this running for quite some time and it works in general. But after some hours it gets really slow and unresponsiv. A motion need a few seconds before it is detected. I already have enabled a daily reboot, but still these few hours are enough. I also tried only restarting motion via pm2, but this leads to problems. I checked it with pm2 monit and got this:

                                motion > [0] [NTC] [ALL] main: Waiting for threads to finish, pid: 13536 
                                motion > [1] [NTC] [ALL] motion_init: Thread 1 started , motion detection Enabled
                                motion > [1] [ALR] [VID] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 640 x 480 at 4 fps
                                motion > [1] [ALR] [VID] mmalcam_start: MMAL Camera using video capture
                                motion > [0] [ERR] [ALL] main: Thread 1 - Watchdog timeout, trying to do a graceful restart
                                motion > [0] [ERR] [ALL] main: Thread 1 - Watchdog timeout, did NOT restart graceful,killing it! 
                                motion > [0] [NTC] [STR] stream_stop: Closing motion-stream listen socket & active motion-stream sockets 
                                motion > [0] [NTC] [STR] stream_stop: Closed motion-stream listen socket & active motion-stream sockets
                                motion > [0] [INF] [ALL] motion_cleanup: Calling vid_close() from motion_cleanup 
                                motion > [0] [INF] [VID] vid_close: calling video source cleanup 
                                motion > [0] [ALR] [VID] MMAL Camera cleanup 
                                motion > /home/pi/motion.sh: Zeile 2: 13536 Speicherzugriffsfehler  (Speicherabzug geschrieben) ./motion -c motion.conf
                                PM2 > App [motion] with id [0] and pid [13532], exited with code [139] via signal [SIGINT] 
                                PM2 > Starting execution sequence in -fork mode- for app name:motion id:0
                                PM2 > App name:motion id:0 online
                                motion > [0] [NTC] [ALL] conf_load: Processing thread 0 - config file motion.conf
                                motion > [0] [NTC] [ALL] motion_startup: Motion mmaltest Started 
                                motion > [0] [NTC] [ALL] motion_startup: Logging to syslog 
                                motion > [0] [NTC] [ALL] motion_startup: Using log type (ALL) log level (INF)
                                motion > [0] [NTC] [ENC] ffmpeg_init: ffmpeg LIBAVCODEC_BUILD 3670272 LIBAVFORMAT_BUILD 3670272
                                motion > [0] [NTC] [ALL] main: Thread 1 is from motion.conf
                                motion > [0] [NTC] [ALL] main: Thread 1 is device: /dev/video0 input -1
                                motion > [0] [NTC] [ALL] main: Stream port 8081
                                motion > [0] [NTC] [ALL] main: Waiting for threads to finish, pid: 13583 
                                motion > [1] [NTC] [ALL] motion_init: Thread 1 started , motion detection Enabled
                                motion > [1] [ALR] [VID] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 640 x 480 at 4 fps
                                motion > [1] [ALR] [VID] mmalcam_start: MMAL Camera using video capture
                                

                                Can anyone suggest how to correctly restart motion?

                                1 Reply Last reply Reply Quote 0
                                • F Offline
                                  Freebond @trividar
                                  last edited by

                                  @trividar I’m trying to install it right now. You posted 2 months ago. Did you get it running?

                                  1 Reply Last reply Reply Quote 0

                                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                  With your input, this post could be even better 💗

                                  Register Login
                                  • 1
                                  • 2
                                  • 3
                                  • 3 / 3
                                  • First post
                                    Last post
                                  Enjoying MagicMirror? Please consider a donation!
                                  MagicMirror created by Michael Teeuw.
                                  Forum managed by Sam, technical setup by Karsten.
                                  This forum is using NodeBB as its core | Contributors
                                  Contact | Privacy Policy