Introduction: Multiple Webcam Server With Motion Detection Using Raspberry Pi

About: We run YouTube channel and provide some video tutorials on electronics and programming and also videos on cool projects - how to make them, tech news and more. Subscribe to our channel. :)

Hey guys, Welcome to Being Engineers.

In this post we will discuss how you can create a Webcam server mesh using Raspberry pi. This system will also include motion detection system with triggering function.

We will be using "motioneyeos" OS to solve the purpose. So let's start this tutorial by thanking the developer "ccrisan" for creating a super awesome OS. Also keep in mind that this whole thing can be done without using the "motioneyeos". If you want to know how, then take a look at our older post in instructables about How to Make Raspberry Pi Webcam Server. It was doneusing the "motion-project". That needs some more work and little more knowledge about what you are doing compared to this method.

I will be assuming that you know how to install any given OS to pi. If you don't know that, then checkout this post that gives a detailed step by step instructions - https://www.instructables.com/id/HOW-TO-INSTALL-RA...

You can check our youtube channel and subscribe if you feel like - http://www.youtube.com/c/being_engineers1

If you don't feel like reading this doc thoroughly, we have got you covered, check out our video tutorial -

So now without further ado let's start this Instructables.

Step 1: Things You Need

In this project, you will need the following:

  • Raspberry Pi 3 Model B (Any version will work, but in PI 3 we have the provision for WiFi that can make this server wireless.)
  • 2 or more USB Webcam (I will use two my old Logitech Webcam. Use better cameras for better results.)
  • 5V 2A Power Source (I will use my Huawei power adapter.)
  • Lan Cable (RJ - 45 Cable, You will only need it if you are using any older version of raspberry pi that doesn't have Wi-Fi module on board.)
  • Minimum 8 GB Class 10 SD Card (I will use Strontium Nitro 433X 16GB class 10 SD Card.)

Step 2: Install the OS "Motioneyeos" on SD Card

Visit this link - https://github.com/ccrisan/motioneyeos/releases

Download the latest version of motioneyeos for raspberry pi 3. The name of the file will be similar to this - "motioneyeos-raspberrypi3-********.img.xz".

Install this OS in your SD card. Follow the link given in the intro if you don't know how to do it.

After you are done, don't remove the SD yet. Go to next step.

Step 3: Enable SSH and Configure Wi-Fi Settings for Easy Connectivity

To enable SSH just place a empty text file with name "ssh" in the boot directory of the SD card.

Now, if you are using older version of pi which doesn't have Wi-Fi, connect the LAN cable to the ethernet port of the pi and put the other end in your router.

For Wi-fi enabled version you have to create a .conf file. To do that follow the steps -

  • Download the following .conf file.
  • Open that with notepad or notepad ++.
  • Change the SSID name and passcode for your Wi-Fi network.
  • Change your country code in the top section of the text and save it. Look into this table for your country code - https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#...
  • Now place the file into the SD card where the 'ssh' file was stored previously.
  • Remove the SD card.

Step 4: Do the Connections and Check the IP Address

  • Connect the USB cameras in the USB ports of Raspberry Pi.
  • Insert the SD card.
  • Power up the Pi. Better you keep it in a well ventilated place, the processor is gonna get really hot. If you can buy a external cooling fan for raspberry pi. They are not that expensive.

Now you need to know the assigned IP address for the Raspberry Pi. There are many process to know this. That depends on your router and ISP. I will be telling you the generic way to find the IP -

  • Go to your router default gateway address.
  • Login to your router setup page.
  • Look for the name lan settings or anything with lan in it. There you will find a list of all the devices connected to the network. Check for the name "meye-********". Beside that you will find the IP address. Take a note of the address. You have to make sure that is a static IP. If not, you can assign that IP to your pi permanently. Google it about how to do it. Take the help of a network engineer if you are feeling lost.

Let say your IP is "aaa.bbb.ccc.ddd". I will use this IP from now onwards.

Step 5: Setup the Camera in Motioneyeos

  • Open up a browser.
  • Put the IP address i.e. aaa.bbb.ccc.ddd in the address bar and press enter.
  • Motioneyeos homepage will open.

There you have ample of settings to play with. But before that turn on the advanced settings.

Here I will give some example about how to setup the cameras. First of all you have to login into the portal. The User id will be 'admin', password will be blank by default. After first login, you must change it. As I have attached two camera to the pi, there are two camera options named camera1 and camera2.

If any of your camera is not peeked up automatically, then you can add a camera by clicking "add camera".

Basically you need to change 4 settings for each camera - Resolution, Frame Rate, Streaming port and finally the motion detection function. If you want to alter any other options, surely you can do that. But these are the most primary one.

Charge the resolution and frame rate as it suits your need. Enable the motion detection with default threshold change in frame. Whenever any motion will be captured, the video feed will be saved on the SD card by default. But for accessing the recorded video over internet, you may want to change the video storage path to some NAS or FTP server.

Check the streaming port. That is where we can view the video feed directly from any browser.

It will look like this - https://aaa.bbb.ccc.ddd:ABCD , Where ABCD is your video streaming port. This will be different for two cameras.

Step 6: Forward the Raspberry Pi Port

Now you have to forward this streaming port to be able to watch the feeds over internet. There is no definite steps to follow to achieve that. That's mainly because different routers have different styled layout and menu system in the settings page. Better you do some research by your own for the exact router model you have at your place.

You can watch the process I had to go through to forward the port. In most cases there will be a settings named "Port Forwarding rules" or "virtual servers". There you have to put the IP address of the raspberry pi and the streaming port.

Step 7: It's Done!

Fire up your browser and put your public ip with the streaming port. Press enter.

You can see the live webcam feed on your browser page. Same goes for the second camera, only change will be the streaming port.

Hope you have liked this tutorial. If yes then please do SUBSCRIBE to our channel Being Engineers. It really helps us a lot on seeing your support and interest towards our channel and don't forget to share :)
Channel link - https://www.youtube.com/c/being_engineers1

Peace.