Dog learned to take a selfie with Arduino



    Engineer and dog breeder Greg Baugues trained his dog Cairo in several useful tricks. For example, she can command "Light!" turn on the light in the room by stepping on a switch on the floor.

    When the dog mastered the inclusion of light, Greg thought about what else the dog can do on command, pressing the button.



    He read the recommendations of other dog breeders, whose pets mastered electronic devices, and came up with the idea that Cairo could well master selfies, that is, it could take pictures of itself and send the picture via MMS.

    Greg Boges designed a device with a webcam , which is activated by clicking on the big red button. A stylish cigar box is used as the case; these are sold by a local store for two dollars apiece.



    After a short time, Cairo learned to make a self portrait.



    Inside the box, there is an Arduino Yun board with two microprocessors. The second one runs the OpenWRT Linux distribution, which is often installed on WiFi routers. In total, two programs run on two processors, with a total size of no more than 60 lines of code.

    Arduino just waits for a key to be pressed, runs a command to record a photo, and runs a Python script to upload the photo to Dropbox and send MMS.

    The script is also simple.

    import datetime
    import dropbox
    from twilio.rest import TwilioRestClient
    dropbox_access_token = "YOURDROPBOXTOKEN"
    twilio_phone_number = "YOURTWILIOPHONENUMBER"
    twilio_account_sid = "YOURTWILIOACCOUNTSID"
    twilio_auth_token = "YOURTWILIOAUTHTOKEN"
    cellphone = 'YOURCELLPHONE'
    timestamp = datetime.datetime.now().strftime("%h-%m-%S")
    filename = "kaira-" + timestamp + ".jpg"
    f = open("/mnt/sda1/pic.jpg")
    dropbox_client = dropbox.client.DropboxClient(dropbox_access_token)
    response = dropbox_client.put_file(filename, f)
    url = dropbox_client.media(response['path'])['url']
    twilio_client = TwilioRestClient(twilio_account_sid, twilio_auth_token)
    twilio_client.messages.create(
      to = cellphone,
      from_ = twilio_phone_number,
      body = "Woof.",
      media_url = url)

    Also popular now: