Add action buttons to motionEye for controlling pan-tilt brackets

motionEye is a great piece of software for controlling network cameras with a Raspberry Pi. With motionEye you can watch live video stream, detect motion, record images and videos.

Starting with version 0.30, motionEye can be configured to overlay buttons on top of a camera frame. These buttons will then execute custom commands when clicked. Thus, it is possible control to control a pan-tilt bracket or to toggle IR light for a PiNoir camera.

Here I mounted a PiCam onto a cheap (0.40 €) pan-tilt bracket with two SG90 servos from Aliexpress.

For motioneye, the following actions can be defined:

  • lock
  • unlock
  • light_on
  • light_off
  • alarm_on
  • alarm_off
  • up
  • right
  • down
  • left
  • zoom_in
  • zoom_out
  • preset1 to preset9

motionEye will look inside its configuration folder for executable files named [action]_[cameraid], where action is one of the available actions (listed above) and cameraid is the id of the camera on top of which the action button will be displayed.

For example, on a setup using the default configuration, the presence of the executable file /etc/motioneye/unlock_1 tells motionEye to show an unlock button on top of camera number one. The file will be executed upon pressing the button. Buttons will have distinctive icons that correspond to the name of the action.

For controlling the pan-tilt bracket, I defined four actions (up/down, left/right) and placed these Pythhon scripts into the /etc/motioneye directory.

Both servos are connected to an Adafruit 16 channel 12 bit servo driver, which is wired to the SDA/SCL of a Raspberry Pi. The driver requires installation of the Adafruit PCA9685 Python library.

git clone https://github.com/adafruit/Adafruit_Python_PCA9685.git
cd Adafruit_Python_PCA9685
sudo python setup.py install

The current position of the servos is stored in two files (vert_pos, horz_pos), both containing a single integer value.

Since servos tend to make a buzzing noise, even when idle, I connected the EO (enable output) pin to GPIO18, in order to power them off, while they are not in use.

Python scripts and installation instructions are available on my github repo.

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments