I’ve been wanting to dive deeper into Raspberry Pi development for a while but needed to make the time and find a project. Image classification using machine learning has been an interest so something using the motion sensor and camera sounded ideal.

As it turns out, my significant other’s cat provided an opportunity to put those to use. The cat tends to go places that are off-limits such as the kitchen counter tops. Products like this PetSafe SSSCAT Spray Deterrent exist but require expensive compressed air cartridges and go off with any motion – pet, human, or otherwise. Another option is the Echo Flex with the motion sensor – a time based automation routine can help in the kitchen or maybe a hallway outlet near a bedroom. Other options include fragrances or custom mats but they all leave something to be desired.

The goal for the project is simple:

  1. Detect motion with Infrared sensor
  2. Take pictures and/or video with a camera when motion is detected
  3. Classify footage and determine if it’s the cat
    • Not any cat but a specific cat
    • Using a previously trained machine learning model
  4. If it’s a match to the cat, perform relevant actions:
    • Play a startling noise to discourage the cat from restricted areas
    • Optionally send some form of notification

Conceptual Overview

Series Overview (In Progress)

Current and planned topics in this series are broken down into the following posts.

  1. Raspberry Pi Cat Motion Siren (Project Overview)
  2. Scripting Raspberry Pi Image Builds
  3. Automating Raspberry Pi Setup
  4. Deploying, Running, Debugging .NET Code on Raspberry Pi
  5. Deploying .NET Apps to Raspberry Pi with GitHub Actions and Docker
  6. Raspberry Pi Infrared Motion Sensor with .NET
  7. Capturing Images and Video with Raspberry Pi Cameras (Coming Soon)
  8. Performing Image Classification on Raspberry Pi
  9. Turning a Raspberry Pi into a Siren

Tentative Hardware

It’s worth noting that not all of the hardware listed below is strictly required for this project. Some of it was used just for evaluation or because I already had it handy and some planned items may not be used. Also some items listed individually can be bought cheaper as part of a bundle.

Raspberry Pi 4 4GB – I use 2 of these, one that’s a “clean” release / runtime target and another that’s for dev debugging and experimentation. 1 is sufficient as are earlier Pi versions. 4 GB is overkill for runtime use but can be handy for dev debugging.
Case(s) – I use an Aluminium Heatsink Case for heavier dev workloads and a basic plastic case for lighter runtime use.
HC-SR501 Passive Infrared (PIR) Motion Sensor – Various versions will do but this one is commonly used with Pi and Arduino and it’s cheap and configurable.
Raspberry Pi Camera Module v 2.1 – I had an older 1.3 rev laying around and it works but image quality suffers.
MakerFocus Camera Night Vision Camera – Since the cat often goes off limits in the middle of the night, I tried this for camera footage in the dark.
SanDisk Industrial MicroSD Card (32 GB) – This industrial version is overkill but is ideal for long-running use and higher heat from the Pi. A basic SD card is fine. 32+ GB is a good size for storage of camera photos and videos.
MicroSD Card Reader – Anything will do. I like the this Anker but if space around ports is tight, a smaller reader may be better though inserting and removing may not be as easy.
Freenove Ultimate Starter Kit – Mostly just using miscellaneous items from this kit such as jumper cables but other relevant items include a breadboard, infrared motion sensor and more. Various similar kits exist.
HONKYOB USB Mini Speaker – Mini speaker for the siren aspect to play audio louder.
UKCOCO Piezo Electronic Buzzer Alarm – Another evaluated option for the siren. Not near as loud as the mini speaker but much more compact.

Software / Tools / Tech

Up Next

Scripting Raspberry Pi Image Builds – the next post in this series looks at automating the process of downloading Raspbian lite, extracting the image, formatting the SD card, copying the OS image, mounting / un-mounting / ejecting disks, configuring Wi-Fi and SSH, and more.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.