Skip to main content

Geekery

An AI project using Raspberry Pi

I recently acquired a Raspberry Pi, after being curious about them for many many years. My plan was to always build a “retro-pi” system - a gaming system for hundreds of 80’s era 8-bit video games, as well as other platforms.

However, before I ever got started on that, another idea hit me. One morning as I was sipping coffee, my daughter left for work. She returned only a moment later informing me that the garage door was left open all night! Fortunately, nothing appeared to be missing, but it got me thinking - maybe I can use the pi and a camera to recognize whether the garage door is open or closed, and alert me when it is left open for some threshold?

After about 30mins of googling and consulting with ChatGPT, I had a parts list, rough algorithm for training the pi, and even a sample python program to interpret the images and send an alert via AWS SNS.

Version 1 of the garage door detector used a single “reference image” of the closed garage door, and using OpenCV python computer vision library, compared an image taken every minute to the reference image, and made a decision on whether the door was closed or not. This actually worked very well! With a little tuning of the image difference threshold, the pi would accurately predict if the garage door was fully closed or not. If the door was open more than 10 minutes, it would send an alert to an SNS I had set up, that would alert me via email or txt message! If the door was closed, the pi would then reset the timer and stop alerting. It worked brilliantly!

For version 2 I plan to tweak the algo a bit, and use a machine learning model. The plan is to load several images of the door in various open/closed states, and in various lighting conditions (ie day vs night) and train a model that the Pi would then predict the door state. I even had a thought for version 3 to add a web interface for configuration of an alerting schedule, alert frequency & suppression, etc. More to come on this as time permits!

There's no articles to list here yet.