Wildlife Camera

Take 1

I created a simple ‘weatherproofish’ Raspberry Pi camera setup, which I detail below:

I bought the following hardware:

With the LED IR light, I placed some duct tape over the LDR on it, so that it remains always on.

I used ZyXEL PLA5205 600 Mbps Powerline Gigabit Ethernet Adapter to attach to the Pis ethernet interface. This provides a fast network which can connect far away from my Wifi AP (my Wifi AP has a powerline adapter connected to its ports).

When streaming to youtube for a while, with the 2m cable I noticed image corruption occurring after a number of hours. However I also noticed the sunny connector had become slightly loose. I have now glued the sunny connector and am using a 1m cable now, when I streamed over night it worked well, after making a script which detects problems with the stream to youtube going down.

‘sudo vcdbg log msg’ gave the following when image corruption occurred:

3480690.655: vcos_abort: Halting
3482637.188: mmal: fail_destroy: Timed out waiting to destroy ril.camera

I stream to youtube using the following command (which was found on https://www.youtube.com/watch?v=S3zNBGfPFxI – I also followed his guide for installing ffmpeg).

raspivid -o - -t 0 -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le 
-f s16le -ac 2 -i /dev/zero -f h264 -r 30 -i - -vcodec copy -acodec aac -ab 128k    
-g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/...

Originally I used a bitrate of 1000000 (1Mbps) which I have been told is far too low! And could have been the cause of some of my videocore issues.

If you get message like the following in the videocore logs:

2582211.411: mmal: mmal_port_send_buffer: ril.video_encode:in:0(OPQV): send failed: EINVAL
2582211.446: mmal: mmal_port_connected_output_cb: ril.camera:out:1(OPQV) could not send buffer on port ril.video_encode:in:0(OPQV) (EINVAL)
2668226.995: mmal: mmal_port_send_buffer: ril.video_encode:in:0(OPQV): send failed: EINVAL

It could simply be due to the stream to youtube dropping due to flaky Internet, like mine!

I created a bash script, which is run as root, based on this command, which checks for the stream dropping and starts the stream again if necessary:

function stream {
	sudo -u pi raspivid -v -o - -t 0 -fps 30 -b 1000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -r 30 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/  outp &

vcdbg log msg 2> vidcore

OLD="$(cat vidcore  | grep "ril.video_encode:in:0(OPQV): send failed: EINVAL" | tail -n1 | awk -F':' '{ print $1 }')"

while [[ 1 ]]

	sleep 20
	vcdbg log msg 2> vidcore
	grep "ril.video_encode:in:0(OPQV): send failed: EINVAL" vidcore > /dev/null

	if [ $RES -eq 0 ]; then

		TIMEERR=$(cat vidcore  | grep "ril.video_encode:in:0(OPQV): send failed: EINVAL" | tail -n1 | awk -F':' '{ print $1 }')

		if [ "$TIMEERR" != "$OLD" ]; then
			echo "Net died, waiting 60 secs"
			pkill -9 ffmpeg
			sleep 60
			rm outp
			echo "starting stream again"


You can see all the hardware in the weatherproof box below:

The raspberry pi camera fits well in the waterproof housing, I managed to thread the camera cable between the two hinges of the waterproof casing 🙂

Oh dear, oh dear:

I believe using a flex cable outside is now a bad idea, likely due to moisture getting into the cable:

mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM) 
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1) 
mmal: Failed to create camera component 
mmal: main: Failed to create camera component 
mmal: Camera is not detected. Please check carefully the camera module is installed correctly

Take 2

I created a new version of the camera using an IP68 case and a Pi Zero:

With the Pi Zero, I found it was necessary to add the following to the Pi’s config.txt (see the raspberry pi forum for more information on this issue):


In this version, the Pi connects to a wireless access point, instead of using an ethernet over powerline device.

Take 3

Eventually I created another version of the camera using an IP68 case and a Pi4, for increased reliability and performance.

With these IP68 cases, I found it was useful to rub silicone grease along the rubber ‘washer’ to help the seal. Also it’s important not to overtighten the screws of the case.

See the following video for how to wire the IP68 connector, I found before snapping the connector together (which can’t seem to be undone), that you should push the plug and socket parts together, then snap it together.

To fit the 2 pin power connector to the case, I first drilled a hole using a 14mm drill bit, and used a file to smooth the edges, so the connector would fit.

Snapshots from footage


I created some simple code using the PiCamera library, to record any motion to the SD card. It also lets me view a live stream from the camera.


Leave Comment

Error Please check your entries!