Novice Security System Using Python, Raspberry Pi, and a camera.

Vincenzo Scotto Di Uccio
3 min readSep 11, 2022

--

I had the pleasure of having my package stolen from me so I decided its time to create a security system.

My build is simple, all you need is a Raspberry Pi a little bit of python code, and a camera that is compatible with your Raspberry Pi.

If you need help setting up your Raspi 4, my previous article goes into the details. Once you have the Raspi setup, the next step is to make sure to attach the camera. I purchased this one, which is compatible with a handful of pi systems. What I liked about this camera is that it came with its own stand that you can use instead of 3D printing your own.

The downside is the camera needs to be put together but there is a great video to help you with that. Attaching the camera to your Pi system is easy, just make sure the connections are snug.

Attach the camera here. The Pi system also conveniently says “camera” on the board to indicate where it should go.
The camera attached to the Raspi 4.
Camera pointing at my front door

Once the camera is attached and turn your Pi system on and make sure everything is working accordingly. You might find that the camera system is not working right out of the box, here are some steps to take before assuming you have a dead camera.

  1. Make sure that in the system settings the camera module is enabled. start>preferences>raspberry pi configuration>interfaces
  2. Make sure in raspi-config it is enabled. Open a terminal and type:

sudo raspi-config

Interface Options>Camera> Enable

Assuming that those potential fixes worked for you, we now have half of the project done! Now we need to write some python code that will allow us to interact with the camera.

The way I approached this was to stream the camera video from the pi and I can ssh into my pi via the cmd on my desktop, run the script and then open a web browser to my pi’s IP address.

ssh pi@IP address

The python script can be found here. From here you can path to your python script and run it.

Running the script

Now that we have a script we can open our web browser and check out our camera! Live!

The address is YourIPAddress:8000

Video stream of my front door :)

And that’s it! Now I have some visibility on my front door! I hope you found this article useful. My next steps are to add some intelligence to this camera by leveraging machine learning to detect individuals in front of my door. I always want to have an email notification of when detection occurs.

--

--

Vincenzo Scotto Di Uccio

Creating useful data science solutions one line of code at a time.