Motion Detection - avanc/photOS GitHub Wiki
To safe energy it might be a good solution to only activate the display if movement is detected. This can be done by using cheap PIR sensors.
Hardware
I have positive experiences with AM312 based sensors:
It can be directly connected to 3.3V, GND and a free GPIO of the Raspberry Pi:
Instead, a simple button can also be connected between 3.3V and GND (please read remarks on Pull-Up-Resistor in next section).
Configuration
Motion detection can be configured on the device by editing /data/photoframe/conf/motion_detector.conf on your device:
> ssh root@photos-xxxxxxxx
> vi /data/photoframe/conf/motion_detector.conf
The mandatory configuration parameters are as follows:
GPIO=24
- The GPIO where the sensor/button is connected
COMMAND_ON=vcgencmd display_power 1
- The command executed, if motion is detected. Here: turning display on
COMMAND_OFF=vcgencmd display_power 0
- The command executed, if no motion is detected after an additional delay. Here: turning display off
Additional parameters (default values are shown):
INTERNAL_RESISTOR=off
- Set internal Pull-Up resistor
on
, if sensor or button is floating.
- Set internal Pull-Up resistor
DELAY=10
- Delay after how many seconds without movement the display is deactivated.
After setting/changing the configuration, the service has to be restarted:
> /etc/init.d/S81motiondetector restart
Debugging
For debugging, stop the service and start the daemon by hand to get debug messages:
> ssh root@photos-xxxxxxxx
> /etc/init.d/S81motiondetector stop
> /usr/bin/motion_detector.py