Published on

Nesting box camera

Authors
  • avatar
    Name
    Carsten Noetzel
    Twitter

Preface

The nesting box was originally put into operation with a Raspberry Pi Model B Revision 2.0 (700 MHz, 512 MB). Since the recordings were a bit jerky and not the best quality, I decided to buy new hardware for the nesting box. At the same time, I also documented the facility.

Now I am using a Raspberry Pi 3 Model B V1.2 (1200 MHz, 1GB) with the Kuman 5MP NightVision camera. The Raspberry Pi camera module can be put into operation as follows.

Steps

Activation of the camera interface

First the camera interface on the Raspberry Pi should be switched on. This could be done by opening the configuration interface using sudo raspi-config and activating it under 5. Interface OptionsP1 Camera.

raspi-config

If not already done the camera can now be connected to the Pi using the FFC connection cable. A first test can then be carried out to determine whether the camera has been connected correctly and is working.

 raspistill -o test.jpg

The command should take a picture and place it in the current folder.

Load camera driver

Motion requires a device that works with the V4L / Video4Linux driver. Therefore module bcm2835-v4l2 has to be loaded. To do this automatically on system start-up two entries are added to the file /etc/modules-load.d/modules.conf.

# camera with v4l2 driver
v4l2_common
bcm2835-v4l2

After reboot the command ls -l /dev/video* should list the video device /dev/video0.

video-devices

Install Motion

Nex step is installing Motion.

sudo apt-get install motion
Note

If during installation the message Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/p/postgresql-11/libpq5_11.3-1_armhf.deb appears an apt update should be carried out (see link).

sudo apt update --allow-releaseinfo-change
sudo apt-get upgrade

The parameter allows the update command to continue downloading data from a repository which changed its information of the release contained in the repository indicating e.g a new major release.

Configuration of motion

Motion is controlled via a configuration file that can be found under /etc/motion/motion.conf. In the following, I will briefly discuss the most important changes that I have made to my configuration. The complete documentation for the configuration can be found here.

ParameterWertFunktion
daemononMotion can be started as daemon.
width1024Image width in pixels
height768Image height in pixels
threshold50000Number of pixels that have to change to be recognized as movement. I have chosen a relatively large value here because the monitored area is very small.
minimum_motion_frames5Number of consecutive frames that must contain motion before motion detection is triggered.
output_picturescenterImages should be saved when movement is detected, namely when the movement is as close as possible to the center of the image.
quality100Quality of the JPEG / WEBP compression.
text_right%d.%m.%Y\n%TThe date in DMY format should be displayed at the bottom right.
text_leftNistkastenThe text "Nesting Box" appears at the bottom left.
target_dir/home/xxx/MonitorFolder under which the images are to be stored.
stream_localhostoffEnable access the to live stream from other computers.
stream_maxrate30Maximum refresh rate of the live stream.

After changes to the configuration Motion is restarted by sudo service motion restart.

If the standard port 8081 has been retained, the live stream can then be accessed with a browser via the IP or the host name of the Pi, e.g. http://hostname-of-the-pi:8081/.

Starting Motion daemon

Since the first option stipulated that Motion can be started as daemon we have to ensure that this happens every time the system is started. Therefore the file /etc/default/motion is adapted and the value is set to yes.

# set to 'yes' to enable the motion daemon
start_motion_daemon=yes

Finshed

That's it! The camera should now record everything and store pictures in the configured folder if motion has been detected.