Building a WiFi-connected streaming camera and video recorder using Raspberry Pi 3

This post explains how to build a WiFi-connected video recorder and streaming camera using Raspberry Pi 3.

I wanted to install a survellance camera to watch the front yard over Internet, and to record video. Unfortunately good-quality connected cameras are expensive, and the image quality is not so good. For example, most are unable to record 1080p, and the camera optics quality itself is not good. The ones with decent quality output have a stiff price tag, and most are cloud-based in some way (configuration or output), which means the company might start charging monthly fees for it, or even shut down the whole product at anytime.

The solution is to use the Raspberry Pi 3. One of its accessories is a camera, which is actually a very good camera with good optics, great resolution and viewangle. It has hardware MP4 encoder, and is capable of recording video with 1080p resolution. And the Raspberry Pi 3 has a built-in WiFi, which allows installing a camera without the Ethernet connection. While using WiFi for the security devices is not very reliable (as it could be easily jammed), the camera records video into the internal storage. So jamming is not much a security concern if the camera body itself is not easily accessible.

Using Raspberry Pi also gives you ability to use motion detection, and only record video when motion is detected. You can also configure it to alert you when motion is detected, perform face recognition and do many other cool things.

To cover my needs, two cameras were created and installed:

  • The first camera used Raspberry Pi 3, and was fully enclosed, with built-in power supply connecting directly to 110V.
  • The second camera used Raspberry Pi 2, was connected to Ethernet and used it for power too.

This post describes the first, WiFi-connected camera. Building an Ethernet-powered camera was a bit more complex, and will be described in a separate post.

Contents

Skills required

For this project the skills required are pretty basic.

Software: you should be able to setup and configure Raspberry Pi.

Hardware: you might need nothing besides plugging in and screwing/unscrewing cases. But in case you need to replace the cables in the power supply, you need to be able to solder, and have the proper equipment.

Components

For a Wi-Fi connected camera I’ve used the following components:

  1. Raspberry Pi 3, which I purchased off eBay for $35;
  2. A camera for Raspberry Pi, which could be also found on eBay for around $10-15 from China (search for OV5647 if unsure);
  3. A small power supply converting 110V AC to 5V DC – a typical micro-USB cell phone charger should work. I used the old cell phone charger, which was small enough. Make sure your charger has enough wattage (the recommended power output is 2 Amps), and is small enough to fit the camera case.
  4. A 32Gb MicroSD card bought in a local store for around $9.
  5. A camera case to hold the camera. I used this case which cost $7, but you can use any other case which would fit the Pi and the power supply.
  6. A 110 Ohm resistor to power on the built-in infrared LED lights (if you don’t need them, you don’t need this resistor)

Preparing Raspberry Pi

Download the Rasbpian, and install it into the MicroSD card. Connect the Pi Camera to Pi, and power it with the power supply.

Perform the initial configuration on the Pi. Make sure you enable the camera in the configuration. Power off the Pi, connect it to WiFi. Then connect the camera, and make sure it works (by using raspistill and raspivid).

After you made sure it works, run the following loop, which will record the video non-stop for 24 hours:

while [ true ]; do raspivid -o test.mp4 -t 3600000; rm test.mp4; done

Keep this loop running for at least 24 hours, and check periodically the temperature of the power supply to make sure it doesn’t overheat, and is capable to carry the load.

Preparing the place for the camera

After you set up the Pi, disconnect it from the camera, and bring it to the place where it will be installed. Power it on (with your laptop or a power bank), and make sure it can connect to your WiFi access point from there, and the signal is strong enough. Adjust your WiFi routers (or add a repeater) if this is not the case.

Preparing the visor

Disassemble the fake camera case. Cut the LED cords from the battery section, and disconnect the visor part (with the glass) from a camera. Remove the part with LEDs.

Get the double-side adhesive tape, and cut three small pieces. Stick it to the front of the Pi camera, at the bottom, and at both sides (do not cover the top of the camera with the small connector):

picture1

Remove the protective tape from the other side of the double-adhesive tape, and attach the camera to the LED ring as shown below:

picture2

The LED panel has a photo sensor (the middle-bottom one); when the light is low, it automatically powers on the infrared LEDs, and they produce the dark-red light which reflects from the glass, and is visible on the camera. To prevent this, the camera needs to be shielded from the LEDs.

To do this, find a small object with a cylinder shape (such as a thick Sharpie or a small bottle) which would fit the small ring between the surrounded LEDs. Wrap this cylinder with a piece of black paper, or a piece of electric tape (sticky side out). Wrap it on top with Scotch tape, so the resulting shield would keep its shape when removed from Sharpie:

picture3

Remove the shield from your Sharpie, and insert it into the camera visor:

picture4

Try to measure the LED panel back on the visor. Most likely your shield would be too tall; trim it as needed. The shield must touch the glass to prevent reflections, just make sure it doesn’t bend enough to actually cover the camera viewangle. This shield will not be visible on the camera then.

Screw the LED assembly back to the visor part. That’s how it should look from the front:

picture5

Connecting the power supply

While Pi could be powered through the USB socket, in my case there was not enough space in the camera case. Therefore to power Pi I had to cut the power cable, and to solder it to the power contact pads as shown below. Red wire is +5V and is using PP1 pin. PP2 pin is ground.

picture6

Connecting the visor

If you want the LEDs to operate, also solder the LED red wire to +5V through the 110 Ohm resistor, and solder the black wire to the ground. You can use the Pi connector for that. Note that they add very little to the overall visibility in the dark, and their real range is around 2-5 feet, so it is perfectly ok if you don’t want to connect them. Still, when connected, they give it a “real camera” look.

Attach the visor-camera assembly to the camera case, put the Pi inside the case, and connect the camera wire to Pi. Test the assembly to ensure it works:

picture7

Fixing the power cord of the power supply

If you have enough space in Pi for your power supply, you do not need to do it. Just attach the power wire to the power supply using electric tape. Be generous with the tape, and wrap the cable around the power supply to make sure a pull wouldn’t strip the wire, and make a shortcut.

I wasn’t that lucky though and my power supply did not fit into the case, so I had to cut the electric prong from it. Warning: this is dangerous, do not do this unless you have experience working with high-voltage circuits. There are high-voltage capacitors inside it, which may still be charged even when the power supply is unplugged, and some might keep charge for hours, so there is risk of major electric shock.

For my power supply I cut the prong first:

picture8

and soldered in a power cable. The hole is covered by a piece of plastic glued in:

picture9

Removing the battery holder

The battery holder takes up valuable space inside the camera body, and you don’t need it, so you can cut it off with the utility knife:

picture10

Finishing

Now the camera case could be closed, and screwed together. I used the velcro sticky tape to attach Pi and the power supply to the camera case. You can still see the power cable on top, which is routed out through the original hole.

picture11

Put back the battery cover, and the top cover. If water-proofing is needed, cover all the seams with waterproof electrical tape. I also recommend taping the top cover to the camera case as it is not sturdy.

Now do the final test, and you’re all set to mount your new camera!

This entry was posted in Linux, Raspberry Pi.

4 Responses to Building a WiFi-connected streaming camera and video recorder using Raspberry Pi 3

  1. Bob Sanders says:

    Hey George,

    Extremely impressive setup! Congrats! Would you care to share how much power the Pi connected via PoE ( Power over Ethernet) drew? I am just curious that you had enough juice to power it because of how many amps you would need to draw for the camera.

    Cheers!

    Bob

  2. Abhigyan says:

    Do we have to connect the negative wire to pp2?


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /home/ulduzs/public_html/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048