Raspberry Pi PoE CCTV - Part

Raspberry Pi PoE CCTV

Raspberry Pi PoE CCTVI'm planning to catch even more bad guys with my latest CCTV project...

Back in September 2014 I shared a post about how my father and I created a reasonably primitive Raspberry Pi CCTV system. It was a great little project however it was restricted by some physical limitations.

Firstly there was the WiFi issue, where we had to install the camera near the router to ensure a half-decent video stream connection. Then there were power issues, with the Pi needing to be a reasonable distance to a plug socket. Lastly there was waterproofing – I still haven’t found a decent waterproof CCTV-style casing made for the Pi (closest thing is Naturebytes) so we had to mount the camera indoors.

However since we installed this initial system I think I’ve found a nifty way of getting around each of these issues, using a Raspberry Pi PoE HAT and a generic CCTV housing.

Time to upgrade my Pi CCTV system…

PoE – What Is It?

Let’s talk about PoE first. PoE stands for Power over Ethernet. If you’ve ever been anywhere the rear of your home router you will have seen cables like this:

Ethernet cables

Ethernet cables – with their annoyingly fragile and constantly broken clips

These are Ethernet cables, sometimes just referred to as Cat5 or Cat6 cables. Traditionally these only carry data – your internet connection. These days you’ll plug them in to your TV and Digital Box as well as your PC.

Power over Ethernet is exactly what it says – power being sent over your Ethernet cable. The really cool and ultimately useful part is that your cable can continue sending data as well. Data and power running via a single cable removes the need for plug sockets and power supplies at the target device end.

What’s The Point?

Well let’s take my previous CCTV project for example. Problem 1 was that we couldn’t go far from our router or we would lose the WiFi internet connection rendering the camera useless. You could solve that by running an Ethernet cable, but that sends us quickly to problem 2 – we still need to be near a plug socket.

Raspberry Pi CCTV

My previous indoor Raspberry Pi CCTV camera – fun, but not even close to perfect.

If we use a PoE solution, we can run a single Ethernet cable to our Pi camera up to 100 metres away (yes 100!) and provide both power and an internet connection. Great for keeping an eye on garages, gardens and anything else in an awkward place away from routers and power points.

Yes we still have the waterproofing issue, but we can knock up a homemade solution for that until some bright spark comes up with a new case.

PoE – How Does It Work

That’s a good question – I’m just finding out myself after receiving a Raspberry Pi PoE Switch HAT from PiSupply owner Aaron Shaw. He offered to send me his funded Kickstarter HAT to have a play with, and although I didn’t totally understand the ins and outs of PoE, I figured it was a good way to learn.

I had a rough awareness of PoE, but I didn’t really understand quite how you get power in to the same cable without blowing up your router or starting an impressive fire.

Turns out there are two parts to the setup – an ‘injector’ at the router end (to ‘inject’ power to the cable), and a ‘switch’ at the other end near the device to split the power and internet back out again. The PoE HAT that PiSupply came up with does the ‘switch’ part for the Raspberry Pi.

Making sense? Let’s take a look at the separate components…

The Injector

Sounds like an overweight wrestler from 1994 doesn’t it?

No this isn’t a man in spandex, it’s a subtle little box that lives close to your router (and a plug socket). Similar to routers, there is a large market of these things on offer. I’m using the TP-Link TL-POE150S also sent from PiSupply.

Note: The switch HAT needs one of these. If you buy the HAT and don’t have some form of injector, it’s going to be pretty useless to you.

TP-Link PoE Injector

My PoE injector. Two inputs, one output. Simple.

This part of the setup is really simple. At one end you plug in an Ethernet cable from your router and the provided power supply. At the other end you fit another Ethernet cable, which will carry both the power and data (internet) that you plugged in to the other side. Easy.

Of course you will need a plug socket for the power supply in to the injector, but you’re very likely to have one near your router anyway.

The Switch

So you now have an ‘injected’ Ethernet cable packed with lots of lovely data and electricity. This cable can be up to roughly 100 metres as I mentioned earlier (with this specific injector), running to whatever device you like.

However, you now need to split that out again to have separate power and internet for your device, and this is exactly what the PoE Switch HAT does:

PiSupply PoE Switch Injected

An example of how the injector is wired into the switch. I will use this short cable to run from the switch to the Pi in my CCTV casing.

Rather than having separate splitter boxes to mess around with, Aaron’s team came up with this HAT that does all the splitting for you in a neat package.

I’m not quite sure what would happen if you just plugged the cable straight in to the Pi without this HAT – I’ll guess lots of magic blue smoke and a disappointed Average Man! (I’m VERY tempted to try this!)

The PoE Switch HAT

I thought it would be good to take a closer look at the Raspberry Pi PoE HAT that the guys at PiSupply have come up with.

I’ve added a few shots below of the HAT I was sent. Initial impressions were good, the board and components look well made from what I can see:

PoE Switch HAT Contents

Unboxed: The contents of my PoE Switch HAT.

Everything feels solid with no rattles or iffy solder joints, and text on the board is clearly labelled. There is a switch included on the HAT for turning the Pi on/off – you don’t need to remove the board at all, just hold this down for a couple of seconds:

Raspberry Pi PoE Switch HAT

The colourful Switch HAT attached to my Raspberry Pi.

With the HAT mounting holes and stacking header, you’re free to use all of the GPIO pins as you usually would, or add another HAT on top. You may need to add another header in the middle of any additional stacked HATs as the Ethernet ports naturally take up a lot of room:

TrafficHAT on PoE HAT

I used the RyanTeck TrafficHAT here to show how stacking additional HATs might require a stacking GPIO spacer in between

My only negative comment on the hardware side would be the HAT mounting spacers/screws.

Half of mine seemed to get stuck and cross thread. I ended up cutting them off and quickly throwing them away. The HAT will work fine without them, and you can always buy some decent metal versions for a few pounds. No big deal.

Wiring Up

Putting everything together for a test run is as simple as I mentioned above: Internet and power into the injector > Ethernet from injector to the PoE HAT > Ethernet from the HAT to the Pi . Done!

Here’s a little mini setup to show you how I tested it:

Pi PoE Dry Run

My dry run setup: Notice the small supplied Ethernet cable between the HAT and Pi.

It really is as simple as that.

Code

None. That was easy! This HAT is purely hardware, you don’t need any special configuration or settings for this one.

Firing Up

I wasn’t really sure if everything would work straight away as I’m not used to HATs that just do their thing out of the box. Usually there’s some soldering, code or setup required.

I made a fresh SD card with Raspbian, connected the Switch HAT and fired up the Pi by pressing the little button on the HAT for a couple of seconds.

Within a couple of minutes my Pi was showing on my network. Super simple.

Raspberry Pi PoE CCTV – Next Steps

Rome wasn’t built in a day (some would say it’s still not finished…) so I’m going to split this project over two or three blogs.

I have the basic PoE electronics sorted for the Pi now, so next steps will be to add a camera module, set up the software and hack some kind of case for it all. I also need to look at how to add IR LEDs somewhere in my casing.

Here are some of my thoughts for my next steps:

NoIR Camera Module

I’m going to bite the bullet and finally buy a NoIR camera module. I must have at least three of the normal types, but as this project will be used night and day I need to buy the one type that I don’t have.

PiNoIR Camera Module

The NoIR Camera Module is easily recognisable by the black PCB (Image courtesy of Alex Eames from RasPi.TV)

Weatherproof Housing

I found this on Amazon which I think will be the perfect way to get my Pi outside in the rain:

CCTV Casing for Raspberry Pi

Whilst it’ll need some hacking to make it work, this casing is almost perfect for this project.

This has to be my bargain find of the year – a CCTV style housing, with a working LED PCB and wall fixings…for less than £6!

The housing comes with 30 working LEDs that run from 2x AA batteries. Whilst I need IR LEDs for my project (for night vision), it’s cool that this comes with this PCB board for the price.

I’m going to attempt to copy the board’s shape and design my own IR version with Designspark PCB. I’m hoping to hook this up to the 5V line on the Pi, depending on calculations and how many LEDs I think I can get away with.

CCTV-LIGHT-GIF

The supplied PCB won’t be used, but it’s an inspiration and template for my own IR LED version that I’m going to make.

In terms of fitting, I hadn’t done much homework on whether the Pi would live comfortably inside. I opened up the housing, took out the LED PCB and tried the Pi for size:

Raspberry pi CCTV Casing Fit

The Raspberry Pi fits inside my CCTV casing with ease.

It fits very well indeed! A few seconds later I remembered that I want to use the PoE Switch HAT inside as well, so I tried again with the HAT on top of my Pi:

PoE-HAT-inside-CCTV-case

It was a little more snug with the Raspberry Pi PoE HAT inside, but it’ll do the job.

That fits well too! It’s a little snug but I don’t think it’ll generate enough heat to worry too much about. The top block is the battery compartment which I won’t need, so that may get cut away for more room.

Now that I know the Pi fits inside with the HAT on top, I can start working out how I’m going to mount the PCB/Camera Module.

Software – MotionEyeOS

I’ll be using the excellent MotionEyeOS again (previously called MotionPie), just like in my last CCTV project. It has been updated with some great new features – more on this next time.

Summary & Part 2

This is my kind of project – more hardware, less code!

I’ve only just started but it’s been mostly successful so far – I have my the Raspberry Pi PoE side set up and ready, and I now have a list of things to do next:

  • Buy a NoIR Camera Module and set up MotionEyeOS
  • Make a custom/copy PCB for the IR LEDs and possibly an indication light
  • Work out how to mount the camera module at the front of the CCTV housing (perhaps within the PCB?)
  • Figure out how to get an Ethernet cable into the CCTV housing and remain waterproof (using glands maybe?)
  • Decide what to do with all the bad guys I’m going to catch with it (death by cheap laser?)

Continue reading here: Using Cron with RaspBMC

Was this article helpful?

0 0