Remote Treat Dispenser Sends You Adorable Photos of Your Pet

Lisa Martin

A typical day for Lisa includes: getting up to see the sunrise, bicycling, interning at Make:, reading and writing short stories, and listening to audiobooks and podcasts for hours while working on projects or chores.

61 Articles

By Lisa Martin

A typical day for Lisa includes: getting up to see the sunrise, bicycling, interning at Make:, reading and writing short stories, and listening to audiobooks and podcasts for hours while working on projects or chores.

61 Articles

Article Featured Image

It can be tough to leave your pet at home when you head out for the day. Tough for your pet, but maybe it’s also tough for you! After all, some days just drag along, and you need to see a friendly, furry face to pick up your mood. Rich Nelson promised his wife a way to check in with their adorable pup Gus while she was away at work. This remote controlled treat dispenser was the result.

The box is pretty ingenious. There’s a Raspberry Pi B+ for the brains, an arduino nano for the servo, a 5MP Raspberry Pi Camera Module, and it’s stuffed with dog treats. After it’s remotely triggered via text message, the servo first jiggles the box, then takes a photo, and pushes out a treat for Gus.

While Gus probably thinks this whole project is all about having treats dispensed by a benevolent white box, the real point is to grab his attention long enough to snap a photo. “If you want a dog to pay attention for a picture nothing works better than the promise of a treat,” Nelson explains. The treat dispenser certainly succeeds here. When the box rattles — making what’s sure to be a mouthwatering sound to Gus — the small pup comes running.

“When I was filming for the video he would run over then sit down in front of it and behave like he would for me or my wife when he wants a treat, he probably loves the magic white box as much as us,” Nelson says.

Pic-2016-02-16-23;31;50

Pic-2016-02-16-23;44;53

The pictures that come out of this are adorable (see photos above for proof), but working out a way to activate the treat dispenser and receive photos through text message presented its own challenges. Nelson was familiar with a method for using Twilio, a service that provides programmable phone numbers, to take a photo with the push of a button, but it still took some work to create an efficient way to manage the text-based commands for the treat dispenser:

The most challenging part was figuring out how to instantaneously receive a text message and trigger the python function. The first method that I got working used polling, the script continuously checked the twilio servers at a set interval for any new messages. But that just seemed too inefficient. Say you check the server every 30 seconds, there would still be a noticeable delay before the message is received, your’e hitting the server almost 3000 times per day, and it required a database to make a record of messages that were already received so you didn’t act on them again. The solution was to set up a webserver on the Pi, that way Twilio could send an HTTP POST to the server the instant a message was received. I used the python Flask framework since it’s simple and the rest of the program was written in python. It was my first time setting up and home webserver and using Flask so I learned a lot.

Twilio is cheap, but it isn’t free, so Nelson says that if he were to do it again he might try to work out his a way of remotely triggering the device like using a custom app or a button on a website. In the meantime, he and his wife can still check out this cute little guy even when they’re at work.