Posts SpiderBB - Raspberry PI Motion Detection

SpiderBB - Raspberry PI Motion Detection

For my BabySpy project, I need to detect motion with a Raspberry Pi Camera module. The previous posts handles the prototype hardware. This post will centre around the question, “How do I detect motion with my new PI Camera?”.

The hard way

With the search phrase “raspberry pi motion detection”, one can find numerous projects and posts about how motion detection is possible. Many posts are motivated by the exciting idea of understanding the basics of motion detection, mainly with the picamera project. For this project, motion detection is a tool and less of a learning objective. Therefore it is not the best path.

The lazy way

The other results point to the motion project. Motion is a program that takes multiple camera inputs and detects significate changes, e.q. Motion. It is highly configurable but overpowered, to be honest ;). I will use and explain only a tiny part of the project, but it will do the trick.


The installation of motion can be done in three different ways, the Linux standard trio.

  1. The Arch-user way means building from the source like cloning the git-repo, running automatic configuration, and compiling.
  2. The I want a specific version-user way: download the deb package from the releases via firefox or wget, install via your favourite package manager
  3. The I want the program-user way: this will be sudo apt-get install motion for most distros

I choose the last way because I don’t require the newest features and want the program. If you choose the first way, I recommend checking whether you need additional packages before starting motion the first time. Otherwise, weird errors may occur ;)


As mentioned before, motion is highly configurable. All settings are within their documentation. The default configuration is located under /etc/default/motion.conf, I will point out every setting I’ve changed for SpiderBB.

KeyDescriptionSpiderBB valuedefault 
logfileDefine the location of motions log file./log/motion.logstderr 
stream_portDefines the port where an http stream publish life images80900 e.q. off 
stream_motionIncrease pictures per second if motion detectedonoff 
stream_maxrateFrame rate while if motion is detected151 
stream_localhostRestrict stream access to localhostoffon 
stream_auth_method0 = disabled, 1 = Basic authentication, 2 = MD5 digest (the safer authentication)00 
stream_authenticationUsername and password for authentificationwont telldisabled 
on_event_startAction to execute when event startesecho “Event start”  
on_event_endAction to execute when event endsecho “Event end  
on_camera_foundAction to execute when a camera is foundecho “Camera found”  
on_camera_lostAction to execute when a camera is foundecho “Camera lost”  
event_gapSeconds an lasts at least1560 

Later the on_ actions will manipulate the state in a state store. The echos are for testing purposes. The stream_ settings are required because SpiderBB requires live streaming.


The values for on_event_start and on_event_end tell motion to print to the log each event start and stop. If I run motion with this configuration, every time I wave at the camera, “Event start” is printed. After holding still for 15s, “Event end” is published. I call this a total success, and for today its time to call it a night,


In this post, I’ve shown how I installed and configured motion. Motion alerts every event with printing to the log perfectly. In the next post, I’ll show how I store the current state and then tie it all together.

This post is licensed under CC BY 4.0 by the author.