Read the statement by Michael Teeuw here.
MMM-PIR-Sensor tuning
-
@jc21
1.
PRETTY_NAME=“Raspbian GNU/Linux 8 (jessie)”
NAME=“Raspbian GNU/Linux”
VERSION_ID=“8”
VERSION=“8 (jessie)”
ID=raspbian
ID_LIKE=debian{ module: 'MMM-PIR-Sensor', config: { sensorPIN: 3, powerSaving: true, } },
-
@open_book Very strange, it seems the module is trying to activate/deactive the monitor using the Relay, but you haven’t specified a relay to use.
I have noticed however, that
sensorPIN
of3
shouldn’t work. This variable is incorrectly named, it is not actually the pin number of the header, but the GPIO number instead. Refer to this Pi 3 image showing which “pins” correspond to “gpio” numbers. You should be using one of 4, 5, 6, 12, 13, 18, 22, 23, 24, 25, 26 or 27.For example, a
sensorPIN
of4
would require the PIR io cable plugged in to pin header 7. -
@jc21 hi again, thanks for your input so far.
I’ve had the sensorPIN at 22 previously. And tested it using the python script shared on a few other threads:
´´´python
from gpiozero import MotionSensor
import ospir= MotionSensor(22)
while True:
if pir.wait_for_motion(timeout=10*60):
print(“It lives”)
else:
os.system(“/opt/vc/bin/tvservice -0”)
´´´
The result spammed “It lives”. Which I understand to mean that the sensor is working… If I change the if to “os.system(”/opt/vc/bin/tvservice -p")" the screen shutsdown.The reason I changed it was based on the results of “gpio readall”. I currently have power in pin 1 (3.3v), ground in pin 6 and data in pin 15
gpio readall tells me that physical 15 = BCM 22 = GPIO 3 so I decided to try sensorPin: 3.
I’ve changed it back to 22 now, but the result is still the same.
Other possible vectors are:
I’m forcing HDMI output because I’m using a HDMI -> DVI converter and so it seemed like a safe choice.
With dev tools open I can see that USER_PRESENCE is not being logged anywhere in the console.
I followed this post and ran:
“Run npm rebuild --runtime=electron --target=1.3.4 --disturl=https://atom.io/download/atom-shell --abi=49”
in the MMM-PIR-Sensor folder, -
Sounds like you’re on top of that then.
Just fyi, the latest code for the original pir sensor module will rebuild the compiled dependencies for you as part of the
npm install
command in the module. There should be no reason to run npm rebuild manually unless you get those pesky “expected version xx but got xx” errors. -
@jc21 just for closure here I found the issue. After running the python script again I realised that the PIR was always HIGH even with the sensitivty dialled right down.
So I checked the leads going into the pi and found that, despite checking it many times, I’d mixed up GND and VCC :(
The lesson for any other idiots out there when testing is, run this Python script and make sure that the PIR stops broadcasting “Motion Detected!” when you cover it with something:
from gpiozero import MotionSensor import os pir= MotionSensor(22) //the gpio pin PIR OUT is connected to while True: if pir.motion_detected: print (“Motion Detected!”)
Code from this site
With some further adjustments for sensitivity it’s now working great!
-
Great stuff. People shouldn’t discount a faulty PIR either. The one I had on the shelf for ages wasn’t detecting quite right so I ordered another one and the difference in detection is huge. I’m not sure if these have a shelf life or what but yeah, that was my recent experience.
-
Hi all,
i have an issue with the PIR Sensor. I get alltime this error:
1|mm | at bindings (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/bindings/bindings.js:76:44)
1|mm | (node:1714) DeprecationWarning: sys is deprecated. Use util instead.
1|mm | WARNING! Could not load config file. Starting with default configuration. Error found: Error: Module version mismatch. Expected 50, got 49.
1|mm | App threw an error during load
1|mm | Error: Module version mismatch. Expected 50, got 49.
1|mm | at Error (native)
1|mm | at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
1|mm | at Object.Module._extensions…node (module.js:583:18)
1|mm | at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
1|mm | at Module.load (module.js:473:32)
1|mm | at tryModuleLoad (module.js:432:12)
1|mm | at Function.Module._load (module.js:424:3)
1|mm | at Module.require (module.js:483:17)
1|mm | at require (internal/module.js:20:19)
1|mm | at bindings (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/bindings/bindings.js:76:44)
1|mm | Error: Module version mismatch. Expected 50, got 49.
1|mm | at Error (native)
1|mm | at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
1|mm | at Object.Module._extensions…node (module.js:583:18)
1|mm | at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
1|mm | at Module.load (module.js:473:32)
1|mm | at tryModuleLoad (module.js:432:12)
1|mm | at Function.Module._load (module.js:424:3)
1|mm | at Module.require (module.js:483:17)
1|mm | at require (internal/module.js:20:19)
1|mm | at bindings (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/bindings/bindings.js:76:44)It’s equal if i have the original from @paviro or the modification.
Can anybody help me?
Regards Daniel
-
- please run
npm list
and find out your version number of electron - change into the MMM-PIR-Sensor folder
cd ~/MagicMirror/modules/MMM-PIR-Sensor
- run
npm rebuild --runtime=electron --target=ELECTRONVERSION --disturl=https://atom.io/download/atom-shell --abi=50
and replace ELECTRONVERSION with the version number you found in step 1
- please run
-
@yawns. Is it possible that my Version is 1.4.13?
-
Yes, that is possible. When I had to run this command last time I was using 1.4.0 …
Just give it a try. Worst case is you have to delete the MMM-PIR-Sensor folder and git clone it again.