Read the statement by Michael Teeuw here.
Motion Detector
-
@Jhonte , post your config file.
-
@phoenixrising said in Motion Detector:
@Jhonte , post your config file.
/* Magic Mirror Config Sample * * By Michael Teeuw http://michaelteeuw.nl * MIT Licensed. */ var config = { port: 8080, ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: 'en', timeFormat: 24, units: 'metric', modules: [ { module: 'motiondetector' } ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== 'undefined') {module.exports = config;} -
@Jhonte , see oscarkindberg example. You are missing the config portion to your module config file. Ill dig mine up later when I have a chance.
-
@phoenixrising That is only an override for the defaults? Or am I missing something here. Working the same way with or without the config part.
-
Hey All,
I’ve followed all the instructions in this topic, and I’ve finally got it to work (RPi 3 + PS EYE camera) everything works well for a while, and then HDMI out stays inactive, moreover, the PS EYE Left LED (the blue one) shuts off, normal operation, both LEDs are ON, so there is definitely an issue with Raspbian itself, is there anyone which resolved this since the previous post ?
My config : https://pastebin.com/j7cKDBy3
-
Hi @alexyak !
Thanks for the module, it looks awesome!
I was trying to use it, at some point I could make it run, I mean, I can set the timeout and the monitor “wakes up” when the pi camera detects any movement.
But when the timeout reachs the limit time, the monitor get off, but after a few seconds it appears a message that says “not signal, cable disconect”.
Is there any way to avoid that alert?Kind regards
-
Never monitors turn off by themselve as soon as there is no signal or after a few minutes without signal. Mine was a old that did not turn on/off automatically.
I used wiringpi to activate a relais that turns the current of the monitor on and off. -
@danielis
Sorry I can’t get your point as English is not my first language.
What I’m saying is that when the camera does not detect any movement, and the timeout setted is out, the monitor does not show the mirror, but after a few seconds appears something like this:

-
OK
But if there is a movement detected - is then the mirror shown?Why do you expect to see the mirror after the timeout?
The mirror must be on if there is a movement. And if there is no movement and the timeout is over, then is the mirror off.
That is what you want and what this module is doing.I think your problem is that as soon as the mirror is off, your monitor should turn off - right?
-
@danielis said in Motion Detector:
ur problem is that as soon as the mirror is off, your monito
Yes sir, that is my problem, the module seems to be working fine, but it is a bit annoying to see the alert when the mirror is off
-
Yes, that was what I tried to say in my first post yesterday.
I had the same problem.
Old monitors do not turn off by themselve if there is no signal. Newer monitor do turn off, and all is fine.My solution was tu use a relais to turn on/off the current of the monitor. Therefore I used a pin of the GPIOs to control the relais.
For controlling this GPIO pin I used the wiringpi library
I had to add some lines in the node_helper.js - please look at the lines with: exec("gpio -g …
pi@magicmirror:~/MagicMirror/modules/motiondetector $ more node_helper.js'use strict'; /* Magic Mirror * Module: MMM-PIR-Sensor * * By Paul-Vincent Roll http://paulvincentroll.com * MIT Licensed. */ const NodeHelper = require('node_helper'); const exec = require('child_process').exec; var moment = require('moment'); module.exports = NodeHelper.create( { start: function () { //this.started = false; exec("gpio -g write 4 1", null); console.log('motiondetector started ...'); console.log('monitor relais on'); }, activateMonitor: function () { exec("gpio -g write 4 1", null); console.log(moment().format() + ' monitor relais on'); //this.started = false; }, deactivateMonitor: function () { exec("gpio -g write 4 0", null); console.log(moment().format() + ' monitor relais off'); //this.started = false; }, socketNotificationReceived: function (notification) { //const self = this; if (notification === 'MOTION_DETECTED') { //const self = this; //this.started = true; this.activateMonitor(); } if (notification === 'DEACTIVATE_MONITOR') { //const self = this; //this.started = true; this.deactivateMonitor(); } } } ); -
@danielis Hi! I’ve tried, but still can’t get it. So I was thinking, instead of putting of the monitor, is it possible to show a black image for example?
So when it detects movement, the MM appears, and when not, a black photo is shown.
Is it possible? -
@pepemujica
There is a module called HideAll (or something similar) which simply hides all modules and leaves a black background. Maybe you want to try it -
Could someone please write up a working instruction for the motion detector with the rasperry pi camera? Not the pir sensor, need to make use of the camera somehow. :)
-
@alexyak Does this module switch off the pi, i’m only asking since i have Alexa running in the background which requires 3 terminals to be open all the time? If the pi goes into ‘standby’ or goes off i have to re-enter the information into the 3 terminals consecutively to get it up and running again. Thanks
Mick -
@Kimzer I wrote up a method using a version of Motion for the RasPi. It’s under the tutorials section of the forum. It’s a non-module solution, so there’s some weirdness involved. But I did get it to work with a Raspicam.
@mickyas - This module doesn’t switch off the pi, it just switches off the output to the monitor.
-
@bhepler Yup that’s what I did too.
-
I’m trying to use this model on my Raspberry Pi Zero W with the Raspberry Cam. I run
MM in serveronly mode, using the Midori-browser. This setup itself works fine and also the camera is able to make picturesraspistill -o testpicture.jpgHowever, if I try to add the ‘motiondetector’ module to the config I just get an empty (black, but not switched of) screen after reboot. This is even the case for a very small config.js :
var config = { port: 8080, ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], language: "en", timeFormat: 24, units: "metric", modules: [ { module: "clock", position: "top_left" }, { module: 'motiondetector', config: { timeout: 5*60*1000 } }, ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") {module.exports = config;}Things I did:
cd ~/MagicMirror/modules git clone https://github.com/alexyak/motiondetectorAdded line
bcm2835-v4l2to/etc/modulesandhdmi_blanking=1to/boot/config.txtIf I omit the motiondetecotor entry in the config.js it loads fine and I can see the loaded modules. If I execute
/opt/vc/bin/tvservice -othe screen goes off (completely black). I I afterwards run
/opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 7the background light of the screen goes on, however the modules that were there previously don’t show up again ( I waited for several minutes).
If I run/opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 2the modules become visible again. Therefore I changed the line in
~/MagicMirror/modules/motiondetector/node_helper.jsaccordingly. However then I got still an empty screen and in the log:
Jul 16 18:59:23 me startMagicMirror.sh[480]: ** Message: console message: [native code] @0: Starting module: motiondetector Jul 16 18:59:23 me startMagicMirror.sh[480]: ** Message: console message: http://localhost:8080/modules/motiondetector//motiondetector.js @39: TypeError: Attempted to assign to readonly property. Jul 16 18:59:24 me startMagicMirror.sh[480]: monitor :state 0x12000a [HDMI DMT (82) RGB full 16:9], 1920x1080 @ 60.00Hz, progressive Jul 16 18:59:24 me startMagicMirror.sh[480]: ** Message: console message: http://localhost:8080/js/main.js @134: TypeError: null is not an object (evaluating 'moduleWrapper.getElementsByClassName')To me as a beginner it looks like a permission problem. However even making the motiondetector folder and all files therein rw for everybody it didn’t work.
I hope that somebody who has knowledge about JS can comment on this issue. Many thanks in advance.
-
@Hawking try to change line 39 to:
cameraPreview.style.visibility = "hidden"; -
Thanks for the quick help. I also found the line in motiondetector.js a bit strange (why the semicolon within the parenthesis…) but as I don’t know JS or details about the code, I couldn’t judge.
I still have the same effect (blank screen) but the new error message is
Jul 17 23:16:55 me startMagicMirror.sh[445]: ** Message: console message: [native code] @0: Starting module: motiondetector Jul 17 23:16:55 me startMagicMirror.sh[445]: ** Message: console message: http://localhost:8080/modules/motiondetector//diff-cam-engine.js @81: TypeError: undefined is not an object (evaluating '(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia).call')Maybe all these things give empty? As a workaround I surrounded the function by
function requestWebcam() { var self = this; method = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia); if ( !! method ) { .... } }Now at least the other modules load successfully.
However, the modules don’t get deactivated after some minutes :-/ I assume that one of these navigator methods is needed for the motiondetector to work? If I look at https://developer.mozilla.org/en/docs/Web/API/Navigator/getUserMedia they seem anyway outdated? How would the user grand permission in a headless setup? Does somebody know if they are supported by the Midori browser?
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