Raspberry Pi Rabbit Hutch-cam

This post describes how to setup a Raspberry Pi with a Pi camera board and a (wireless) internet connection as a webcam serving a latest image (updated every 15 seconds) and a short timelapse containing the most recent hour of images in a 20 second movie (updated once per hour). The website has basic password protection. I’ve set it up to monitor a rabbit hutch, but obviously there are other potential applications. There isn’t anything very novel here – this post serves mainly to document my setup in case I ever need to set it up again, which seems likely, as we’ve just ordered a Pi Noir camera for additional night-time monitoring…


My kids got a rabbit this summer. It lives in a hutch in the back garden, placed so that we can see into the hutch easily from the kitchen window. So, the kids can easily check on the rabbit when in the kitchen, but not when they are in the lounge watching TV, and certainly not when they are out-and-about. So my Xmas Pi project was to set up Joey-cam (the rabbit is called "Joey", because kid-reasons), so that the kids can check on the rabbit from their smartphones wherever they are….

However, the hutch has closed (opaque) compartments, so in addition to a live image, the kids also wanted to be able to look at a timelapse of recent images, to be able to quickly and easily check for any sign of movement in the last hour.

The final requirement was that Joey-cam should be accessible from anywhere over the internet, but to have some very basic password protection, so that it wouldn’t be completely public.


I’m assuming a Pi (doesn’t really matter which), with a Pi camera board attached, a clean Raspbian install, and some kind of internet connection. Mine has wifi (via a small USB wifi dongle), which is very convenient given its location. It also needs to have an SSH server enabled, so that you can log into it from another machine. I’m assuming that the reader understands how to do all this already. This post is about the camera and web server setup.

Set up

All of the code associated with this post is available from this github repo.

First log in to the Pi from another machine (eg. ssh pi@ip-address, replacing ip-address appropriately) and then download this repo with:

wget https://github.com/darrenjw/blog/archive/master.zip
unzip master.zip
cd blog-master/pi-cam/

Run the camera setup with:


The script finishes by running raspi-config. If you already have the camera enabled, just exit. If not, enable it, but don’t yet reboot – you will need to reboot soon anyway. But if you haven’t set a sensible hostname yet, it’s probably worth doing that, too.

The camera scripts can be enabled by running:

crontab -e

and add the following lines to the end of the file:

@reboot /home/pi/blog-master/pi-cam/camera-script.sh 2>&1
20 * * * * /home/pi/blog-master/pi-cam/hourly.sh 2>&1

Save and exit and check with crontab -l.

Next set up the web-site by running:


Reboot with sudo reboot and log back in again after 30 seconds. Check that photos start to appear every 15 seconds or so:

ls -l ~/timelapse/

Assuming so, try pointing a web-browser at your Pi (http://ip-address/ – replace ip-address appropriately). You should get a basic page containing the latest image, and the page should update every 20 seconds. There will also be a link to the “latest movie”, but it won’t work straight away – wait a couple of hours before trying that.

If you aren’t going to open up your Pi to the world, then you should be done.

Adding password protection

If you are intending to open up your cam to the internet, it’s probably worth adding some basic password protection. The very basic protection I describe here is probably OK for something as mundane as a rabbit hutch, but if you are monitoring anything more sensitive, then you should google how to lock down your site properly.

You can find more detailed instructions here, but the tl;dr is to

sudo nano /etc/lighttpd/lighttpd.conf

and paste the following at the end of the file:

server.modules += ( "mod_auth" )

auth.debug = 2
auth.backend = "plain"
auth.backend.plain.userfile = "/home/pi/lighttpdpwd"

auth.require = ( "/" =>
"method" => "basic",
"realm" => "Hutch-cam",
"require" => "user=joey"

Replace the required username (here, “joey”), with something appropriate, and create the file /home/pi/lighttpdpwd containing a single line in the form username:password. Then restart the server with

/etc/init.d/lighttpd restart

Test it out and find diagnostic information in /var/log/lighttpd/.

Opening up

You need to open up ports on your router to allow access to the Pi from outside your home network. This is router-specific, so you may want to just google for instructions for your router. Note that I have another public-facing web server on my home network, so I map port 81 on my router to port 80 on the Pi to have a public facing webcam on port 81 of my home network address (http://my.home.address:81, where my.home.address is replaced appropriately).


You will almost certainly want to customise the very basic web page in /var/www/index.html appropriately for your application. You can also tweak various things in camera-script.sh and hourly.sh, particularly settings such as resolutions, qualities, frame-rates, etc.

Setting up a Minecraft server on a Raspberry Pi

I’ve recently set up a Minecraft server on a Raspberry Pi. There’s lots of information on line describing how to do this, but I still had some problems, in part due to a lot of information on-line being out-of-date, in part due to the fact that running a Minecraft server is right on the limit of what a Pi is capable of, and in part due to the fact that I don’t really know much about Minecraft…

Just to be clear, this is about running a Minecraft SERVER, not the game client. The game client doesn’t work well on the Pi, as it doesn’t have enough memory. There is a special game client for the Pi, the Minecraft Raspberry Pi Edition, which is free, and programmable, but is creative mode only, and has no monsters. That is not what this post is about. You can run a server on the Pi (for free) which you can use from a standard game client (which is not free). That is what this post is about.

Useful on-line information I found useful includes the Gamepedia tutorial, this Forum thread, and this how-to-geek article. It is worth having a quick read through these before continuing.

It is important to understand that there are lots of different Minecraft servers out there, most of which are Java based, but not all. There are potential advantages to not using the standard vanilla Mojang reference server, as some servers are lighter weight, and hence could potentially run better on the Pi. However, lots of servers “out there” are not compatible with the latest (1.7.x) versions of the game client, so it’s probably best to get the vanilla server up and running first, before exploring other possibilities. Note that I’m assuming a Revision 2 Model B Pi with 512MB RAM. I don’t imagine that you will have a good experience with 256MB RAM. You should use raspi-config to allocate as little RAM as possible to the GPU, and you should overclock the Pi as much as you dare.

The Mojang server is a Java server, so you need a fast JVM installed on the Pi. The OpenJDK JVM is too slow – you need the Oracle JVM. Lot’s of info on the web refers to Oracle’s developer preview of Java 8, but that isn’t necessary now, as Oracle’s Java 7 is now a standard part of Raspbian. So just install that:

sudo apt-get update
sudo apt-get install oracle-java7-jdk

Use java -version to make sure it has worked. Then just pull the server jar, stick it into an appropriately named directory, and run the server from that directory with a command like:

java -Xms256M -Xmx384M -jar minecraft_server.1.7.2.jar nogui

The first time you run this it will take an age (possibly up to half an hour). Subsequent starts will be much quicker (15 seconds). Once it is up and running, try connecting to the address/name of the Pi from the machine you usually use for running the Minecraft game client. If the connection fails due to a protocol error, this usually means that the server is too old to cope with the latest version of the game client, so you need to find a new server. If it fails due to a timeout, then it means that your Pi isn’t running fast enough. Tweak settings. Overclock more, etc. There are various settings in the “server-properties” file that you can tweak to improve the speed at which the server runs. Disabling “nether” and dropping the view distance down (to, say, 5) seem to be particularly effective. Again, you can find out more about this by googling around. My current server-properties looks like this:

#Minecraft server properties
#Sat Nov 30 14:23:39 UTC 2013
motd=Pi server

If you’ve never set up a server before and are having trouble, it may be easier to set things up on another machine and then copy things across to the Pi when you get it working. I actually got mine up and running on a fast Ubuntu laptop first, which saved a lot of time.

I’m still running the Mojang server. It’s generally fine, but gives lots of warnings about “Not keeping up”, and riding horses doesn’t really work very well. If anyone has suggestions for another server that will work as a swap-in replacement and run better on the Pi, please do leave a comment. I’d be interested in something that runs a bit faster, and copes better with riding horses, smashing blocks, etc. But my kids will not be pleased if they have to re-build their world…