Skip to content

Motion Detection

JSAnyone edited this page Dec 15, 2021 · 4 revisions

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: AM312 Front AM312 Back

It can be directly connected to 3.3V, GND and a free GPIO of the Raspberry Pi: Connecting to 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.
  • 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
Clone this wiki locally