How I Taught My Dog to Text Me Selfies

A few weeks after we got our puppy, we taught her how to turn on a light.

Turns out Kaira will do just about anything if you can clearly communicate your desires and have a treat in your hand. There’s an Ikea lamp in our bedroom that’s activated by stepping on a floor switch. We started her training by placing her paw on the switch, saying “Light,” and giving her a treat. Once she got that, we’d press on her paw and withhold the treat until she heard a click. Eventually, we could say “Light” from across the room and Kaira would run over and do the job:

Shortly afterwards I started thinking, “I’ve got a dog that can press a button. What can I do with that?”

Doggy Selfies

When Twilio launched Programmable MMS, I started to wonder if we could teach Kaira to send selfies. I’m pleased to say that thanks to the Arduino Yun and a big red button, the answer is a resounding “Yes!”:

My dog texts me a selfie
My dog texts me a selfie

What you’re seeing in the video is a cigar box housing a massive arcade button and an Arduino Yun. The second box serves as a stand for a webcam that’s plugged into the Yun. (My local cigar shop sells empties for $2 which make for sturdy and stylish hardware enclosures).

cigar-box-exterior

cigar-box-interior

The WiFi enabled Arduino Yun has two microprocessors: one does all the pin interaction you typically associate with an Arduino. The second runs a stripped down version of Linux called OpenWRT which can run programs in your favorite scripting language (Python comes pre-installed, but you could put Ruby or Node on there if you so please). This project has one program running on each processor. Together, they are less than 60 lines of code.

The Arduino sketch simply:

  • waits for a button press
  • runs a shell command to take a picture
  • runs a Python script to upload the picture to Dropbox and send the MMS

The Python script uses the Dropbox SDK and Twilio helper library to:

  • upload the picture to Dropbox
  • get a publicly accessible url for the picture
  • use that url to send an MMS via Twilio

If you’d like some more color on how we got here, we’ve documented the entire process from Arduino Yun unboxing to sending MMS in these three tutorials:

Onward!

What’s most exciting to me about this project, aside from the sheer novelty of my dog sending selfies, is how simple each component is. The button press is literally the second example from Massimo Banzi’s Getting Started with Arduino. The Python script is practically cut-and-paste from the Dropbox getting started guide and the Twilio SMS and MMS quickstart.

Hardware hacking can be intimidating if you’ve never done it before, but remember that  the most impressive hacks are often just simple building blocks stacked on top of one another. Wifi enabled devices like the Arduino Yun have drastically lowered the barrier to entry for web developers to dip their toes into the Internet of Things.

So let’s say you had a box that could interact with both the physical world and any web-based API using the programming language you already know. What could you do with that?

Whatever it is, I’d like to hear about it. Hit me up at @greggyb or gb@twilio.com.

Many thanks to Vlad Petrenko for translating this post into Russian

  • Where are the requisite dog selfies? Son, I am disappoint.

    • Good point! You can see them in the YouTube video, but then I realized that folks don’t necessarily watch those. A screenshot is now just below the video.

    • A screenshot is now just below the video.

  • So Awesome! Is there any way to remotely encourage the dog to send you selfies while you’re away?

    • That would be great! The Yun has a webserver, so you could set it up as your Twilio webhook. Then you text it, sound a piezo buzzer, and after she presses the button for X seconds, use a servo to activate a treat dispenser.

  • Oaktowner

    It would be awesome if your dog just had an Instagram or Twitter feed and every photo showed up there.

  • Kaira

    Woof.

  • KP

    Does your dog have her own phone number?

    • Of course! Feel free to give her a call on the number in the screenshot. She’s around.

  • gnrgrbl

    Next step: teach your dog to teach children to take selfies.

  • Erik G.

    Is that a Lapponian herder?

    • Unsure, since she’s a rescue. Hadn’t heard of a Lapponian herder before. She definitely looks like that, only with shorter hair and a curly tail. Our best guess is either some kind of Shiba mix, or an Australian Kelpie.

  • Adam Wespiser

    What kind of dog is she? My friend has an australian cattle dog that looks very similar(body size/ears). Anyway, came here from HN, nice integration of microcontroller and web technology! Keep up the good work!

  • The Engineer

    you might want to blur the phone number in the screenshot :)

    • Oh, that’s Kaira’s number and she’s totally cool with getting calls and texts. Give her a call. :)

  • Pieter

    I would put a pause of 50 ms or something in your loop. That way, the CPU load won’t use be a 100% all the time.

  • h4xp3t

    You do realize that making your phone number visible on the Internet may have undesired consequences? Maybe blur the number out of the image?

    • Thanks so much for the heads up. Totally agree that sharing your cellphone number on the interwebs is a recipe for pain. Fortunately, the number you see in the screenshot isn’t my personal cell but the Twilio number I used for the app.

      One of the cool bits about Twilio numbers is that they’re so cheap ($1/month) as to be disposable. For instance, I needed to submit my phone number to a lead gen service last week. Gave them a Twilio number forwarded to my cell. Once I got what I needed and was done with solicitations, I killed the number. burnerapp.com have built a business around this idea.

      Disposable, programmable numbers can be a lot of fun. If someone calls the number in the screenshot, they’ll get Kaira. If they text that number, she’ll reply with a selfie. Much to my disappointment though, according to my Twilio logs very few people have.

  • oh its reaallllllyy greaatt

  • Lisa Mo’ Chin

    Omg omg omg can we please reunite our two identical dogs with their long lost family? Someone sent me your video because of my dog nestle… https://youtu.be/Q9HPH7wfy6I

    • @lisamochin:disqus , Whoa. That’s uncanny. Do you have any idea what kind of dog Nestle is?

      • Lisa Mo’ Chin

        I always guessed husky (body shape, size, fluffy fur around neck and tail, runs 10 miles and is still a maniac, vocalization), rottweiler (coloring and more muscular structure than husky) and maybe chowchow because she has a black tongue and used to be super alpha at the dog parks. It’s all guesses. I see you think Shiba Inu mix. That makes sense. There are some shots of your dog where it’s like…wow that is exactly nestle. so cute! our baby is 11.5 years old now. she’s finally normal, not a hyper maniac.

        • She could also be a black and tan Australian Kelpie. Good to know she’ll calm down in a decade or so. We’ll look forward to that.

          (https://www.google.com/search?q=australian+kelpie+black+and+tan).

          • Lisa Mo’ Chin

            You just made me open my eyes really wide. It’s her long lost family! I didn’t think they existed. hahahah. And she kind of became normal around age 7. I mean she still perks up for the boys, but now she’s like, okay let’s do normal dog speed now. hey you threw the ball? really? I forgot, I saw a rock when I was running for it.

          • Lisa Mo’ Chin

            wow this picture of one mixed with husky is dead on sans the blue eyes. you really just changed my world. hahahah. https://dogsofsf.com/wp-content/uploads/2014/08/IMG_6770-600×536.jpg

          • Lisa Mo’ Chin

            By the way, your video is trending quite well because I posted it on my wall and a random friend said they had watched your video today in a company meeting on how to be more viral. :)

  • dany

    Next step: teach your dog to teach children to take selfies.
    http://histoire-bateaux-aviron.fr/

  • Devis Gratuit
  • Pierre Santien
  • Pierre Santien