New Raspberry Pi Webcam Project

In my last post, I talked about using the Raspberry Pi as a DIY remote webcam, in the style of Dropcam. After I published the post, I got an interesting email from someone who is embarking on a large project around using the Raspberry Pi as a webcam platform.

It sounds like he wants to create his own Raspberry Pi distro which would automatically launch and stream webcam video. He also wants to do servo remote control for pan/tilt enabled cams, and other neat stuff like that.

If you’re interested in the same kinds of things, why not check out his Source Forge and see if you can help him out? A lightly edited version of the email is below:

Dear Thomas, PrivateEyePi,

At, I read that you are currently swapped to use the raspberry pi now as your home automation server, and the use of a webcam herein is something you’re also probably looking into (see

I was wondering whether perhaps you (and/or privateeyepi) are interested in helping me with a script (available at ) which currently attempts to set up the raspberry pi as a fileserver and as a videofeed server, automatically (without user input) -the videofeed server is accessible via internet, whereas the file server is intended only for the LAN-. I don’t know whether it works all ready, mainly because I don’t have a raspberry pi, and also lack the programing knowledge to get it 100% done.

Unlike privateeyepi’s writings, the videofeed server uses mjpg streamer, not motion, so might all ready provide better footage.It might even allow remote control of the video camera (hopefully even from a different computer, perhaps even from the internet, rather than directly from the raspberry pi). The servo motors used would need to be of a specific brand (so not brand-nonspecific) but that would be a minor issue.

I was thinking if you guys prefer, I could also split up the scripts again (to seperate the webcam and file server functionaility), and we could perhaps introduce other features, to increase the home automation tasks it can handle. It could ie be expanded with an automatic setup script for electricity use tracking (see ), and perhaps the automatic setup of a webserver. (ie by installing XAMPP – – or lighttpd -see – That way, all houses equipped with the system automatically also get a blog or website to post things on.

Thomas [ed: Yes, we are both named Thomas]

Home Security Camera With Raspberry Pi and a Webcam

Lately, I’ve been thinking about ways to beef up my home security using Raspberry Pi. The Raspberry Pi is a pretty capable, dirt cheap little board, and it can connect to all kinds of sensors and systems. I’ve been working on adding a Raspberry Pi camera module, but for those who don’t want to shell out another $30, there’s an even simpler solution.

The Raspberry Pi has full USB support, and runs a fully featured Linux operating system. The Raspberry Pi OS includes support for Video for Linux (V4L), which can interface with webcams. Everyone has a webcam sitting around in their closet. You know, from the 90s? Why not combine a Raspberry Pi and a webcam together to make a super cheap home security camera (ala Dropcam), but for a fraction of the price?

To try this out, I went to my own closet. Sure enough, I found a webcam; in this case, an old Ipevo document camera. Ipevo cameras are nice, because they come with a stand which allows you to reposition them however you like, and they have pretty decent optics, making for a pretty clear picture.

Connecting the Ipevo to the Raspberry Pi was simple as can be. You just plug it into the USB port.

Raspberry Pi.jpgRaspberry Pi.jpg

But how do you go about actually taking pictures? I like Python, so I wanted to find a Pythonic solution. It turns out that the easiest one is to use Pygame. Pygame is usually used to design simple games, but it’s great for this surveillance application too, since it has webcam support and comes pre-loaded on most Raspberry Pi boards.

I Googled around a bit, and in just a couple minutes, I was able to hack together some Python code which connects to the webcam, takes a picture each second for 10 secconds, and saves them to the disk.
cam =[0], (1280,720))
print "Camera Started"
i = 0
while i < 10:
    img = cam.get_image()
    print "Image captured"
    import pygame.image
    print "Image package imported", "webcam_photos/photo%s.jpg" % i)
    print "Image saved"
    i += 1

Here’s an example picture. In this case, I caught my dog in the act of…walking away from the camera.

The scandal!The scandal!

The scandal!

The neat thing about this is that I can connect the camera to my Raspberry Pi home automation server, and since the server is wireless, I could place the camera anywhere in my house. Instant diy surveillance cam.

My next step is to set up the camera for remote access. I’ll probably add in some simple Python code to upload the images to a web server, so I can access them from elsewhere. I’d also like to add in motion detection, and ultimately facial recognition, so my home automation system can know when someone familiar shows up at the door. More on these projects soon.

Raspberry Pi As a Home Automation Server

Legacy Content: This content was published a long time ago. The information may no longer be accurate.

In the Hardware section of the site, I talk about using an old Powerspec PC as my home automation server. An outdated PC works fine as a server in some cases, but really, running a little spaceheater-ish P4 around the clock? That’s so 2006. It would be kind of silly to blog all about power efficient lightbulbs and realtime energy monitoring while having a 10 year old PC buring 400 watts all the time. And who wants to run all their home automation stuff on Windows, anyway?

Over the last year, I’ve moved almost all my home automation code and programs over to a new platform: the Raspberry Pi. The PI makes a ton of sense as an HA server. It’s tiny, cheap, extremely power efficient, and can run a full Linux operating system with a graphical interface. You can tie it into low-level sensors (sort of), but at the same time, it can run Python scripts faster than the old Powerspec.

Here’s a little video introducing my Raspberry Pi home automation server:

Another great thing about the Raspberry Pi is that you can easily get it onto wifi. Just add an external adapter like the cheapo ones from Rosewill and you’re set. You can put your server anywhere in the house–in a cabinet, under your desk, in the garage, etc. Here’s my wifi setup:

So once you have your Raspberry Pi home automation server set up (and perhaps embedded in a project), how do you actually communicate it or upload new code? You can be fancy and get it to run an FTP server, but I find it’s often easier just to use Putty to send stuff over SSH:

So what does my server actually do? Well for starters, it uses CHRON to run my Bidgely scraping script once per minute, pulling in my realtime electrical usage. It also scrapes data from the endpoints of a ton of other APIs. You can even have it control things like Phillips Hue over your home network, using Python. I’ll share more on how I’m using my Pi in future posts.