Raspberry Pi Wildlife camera

Currently I am using 20000 mAh power bank which provides enough power to run Pi and capture wildlife videos for about 18 hours in this cold weather(this was while I was filming foxes). The last time I set my camera to film mice it only lasted 8 hours but that was down to constant activity. Camera was activated almost every 2 minutes.

The infra red light is powered for separate 9v battery.

 

Parts needed for the project:

  1. Raspberry Pi with SD card
  2. IR torch or IR LEDs and battery to power them
  3. Motion detector sensor
  4. Relay
  5. USB Low Power Bluetooth 4 stick
  6. IR Camera module for Raspberry Pi
  7. USB Power Bank

And now how to connect it all up:

NightCam_pinout2Once Raspberry Pi  is on first thing we will need to do is enable camera.

en_camera en_camera1reboot

After the reboot get the Pi software up to date

Next we need to install the Bluetooth software which will allow for the android phone to be connected to the Pi in the field.

This step can be missed if WIFI dongle is used. Some additional configuration will be needed like setting up Raspberry Pi as an access point. Since WIFI is more “power hungry” I decided to go Bluetooth.

So for Bluetooth software we will use ecodroidlink

Now we need to configure networking side.

Now file should be changed to following (gw 192.168.1.254 value should be changed to your local network default gateway value):

The next command will make sure software starts every time Pi starts.

To make sure that autorun is correct.

The config should look like this:

Now we need to set up DHCP
To do that we will need to install DHCP server.

The dhcp should be served on the br0 interface. To set that we need to edit following file.

At the bottom of the file INTERFACE value need to be set to bridge interface.

To set the address pool.

Add following config to the bottom of the file.

Reboot

Once the Pi is up and running again we should be able to connect android phone over Bluetooth
to the Pi and using any ssh app connect to the console on 10.0.0.1

 

Now the easy bit – setting up camera script
Installing all the python packages we need for work with camera.

Lets create folder called motion. I would suggest to create under /home/pi/ path

Now create the actual script file. And again I suggest that all file names and folder paths are left the same.

Lets paste the script in the file.

Now lets save and exit the file and make it executable.

To execute the file.

At this point if everything is connected correctly once the motion is detected there should
be relay click and camera will start recording and once the is no movement for certain period
of time there should another relay click and camera stops recording. The video files are saved
in the motion folder.

The problem with current setup is that once session is disconnected the script stops as well. To get around this problem we need to install application called “screen”

 

First we need to open screen app.

Then to execute script.

Once script is running press “Ctrl-a” “d” keys. This key combination will detach from the screen session and leave the script running

So so far project worked fine but I found that it is hard to frame the camera correctly so this next script will take a picture which can later be downloaded over SCP protocol. Script need to be cerated in the motion directory.

And insert following script in the file.

Lets make the script executable.

Now by running Serverauditor app to execute the script and AndFTP app to download image over scp protocol on my android phone we can see what camera is pointing at. This wasn’t the quickest method so I wrote the application for android. The application also syncs time and date on the android device with Raspberry Pi as well as executes the video capture script. One thing I was worried about was once the connection between Pi and android is disconnected that script will stop but that wasn’t the case. Since I don’t have any Java programming experience it is not the most stable app but it does the job. You can download the source code here or just download ready app here

 

Update!

I was getting very noticeable delay when connecting to Raspberry Pi and i found out that it was down to reverse DNS lookup. To disable this function
UseDNS no need to be added at the end of the /etc/ssh/sshd_config file:

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *