The Official Raspberry Pi Projects Book - Projects_Book_v4

(singke) #1

(^56) The Official Raspberry Pi Projects Book raspberrypi.org/magpi
hile pondering what to
get Shirin, his fiancée, for
her birthday, Eric Page
realised how much she misses her
dog Pickles while she’s at work.
He decided to build a device to
allow her to serve treats to Pickles
remotely. “She uses it almost
every day! Usually once a day when
she is at her office. When she’s
travelling, she probably sends
him three or four treats every
day. I think it helps her feel closer
to home.”
There are four ways to trigger
the Pi-powered device: email,
MQTT, IFTTT, or Alexa. It then
plays a sample of Shirin’s voice,
dispenses some dog treats, and
checks for motion using OpenCV
Projects SHOWCASE
With motion detection and video capture, is this the ultimate dog treat dispenser?



Build details
are on
Instructables
magpi.cc/
2sTf5qU
There are four
ways to trigger
the device
It can dispense
treats of
different sizes
Eric has added
a ball launcher
He intends
to extend
it further
Quick
Facts
DOG TREAT
MACHINE
The Camera Module is
used to detect motion
and capture photos
and video of the dog
W
ERIC PAGE
Eric enjoys building things for his
fiancée, Shirin, and their dog, Pickles.
When he’s not DIYing, you’ll probably
find him backpacking or running an
accounting business.
magpi.cc/2sUurv1
analysis of the view from a
Raspberry Pi Camera Module. If
motion is detected, it captures a
photo and video of Pickles, which
are sent to Shirin in an email with
a randomised cute comment. If
no motion is detected, it sends
an ‘I’m not home but will enjoy
the treats later’ message, along
with a couple of photos of Pickles
playing outside.
Eric says motion detection was
an important addition. “I didn’t
want to send my girlfriend a video
of a floor full of treats. Even if
Pickles was home, if he walked
over to the treats more quickly or
slowly than expected, the video
would be blank for a period of
time. So I built a motion detection
system using really good code
from Adrian at PyImageSearch.
This ensures that the video always
starts with Pickles entering the
area, and Shirin can see him
trotting up with excitement.”
Far from being a seasoned maker,
Eric reveals “this was my first
attempt at anything DIY in probably
25-plus years since junior high,
so it took some trial and error.”
After starting the project with an
Arduino, he soon realised that it
lacked the processing power and
storage required for video and other
complexities. “After I switched to
the Pi, it took 30–45 days to get
to a version that would reliably
deliver treats via email. After
that, I periodically tinkered with
A stepper motor rotates
the inner cylinder to
dispense the treats
The cylinder is divided
into sections for storage
and dispensing


Free download pdf