Pi-Rex – Bark Activated Door Opening System with Raspberry Pi

(DISCLAIMER: Not meant as a security solution or a lesson in good dog behavior. It’s an experimental proof of concept to play with the application of embedded computing to solve particular use cases)
Sleep deprivation has been driving me mad recently. And it’s all down to a new member of the family (kind of), our new dog. She barks at night when she’s left out. She barks early in the morning when she’s left in. So once I recognized the patterns of her barking, I realized that all I needed was something that would let her out when she needed to go for a pee, usually around 6:30 in the morning. I could do this with a timer switch and a door strike, but where’s the fun in that.

I wanted this to be an educational project, so I decided I’d use the Raspberry Pi again, this time for a non-camera related project. And I decided on a bark activated automatic door opener.  So here’s what I came up with:


It involves a bark detector (noise detector circuit) wired to the input of the Raspberry Pi so that it can detect the barks. A motor driver circuit to drive the actuator that unlocks the door, and a weight/pulley system that swings the door open when its unlocked.


Here’s the pulley system. As soon as the door is unlocked, the door swings gently open, allowing Rex to go to do their business. 🙂

I picked up the audio detection circuit in Maplin as a DIY kit for €9.99, the kind of ones where you get all the components and a PCB in a bag, and solder them all together. It took about 30 minutes, but worked perfectly, I could bark, and the LED’s would light as I barked. My family thought I was gone mad when they heard me making dog noises in my workshop.

Electronics engineers will now cringe at what I did next. I probed the audio sensor with a voltmeter, and saw that when the volume into the microphone was at a decent level I saw about 3-3.5 volts at one point, so I hooked that directly up to the GPIO on the Raspberry Pi, and it worked beautifully. Ideally, a proper buffer circuit would be used to give a proper logic signal to the GPIO, but I’m not always one for the perfect solution, as is obvious by the fact that I built this contraption at all! 🙂

Here’s the actuator I used, it’s a 12V model, €3 with €3 shipping from Hong Kong. There’s about 30mm of travel in the actuator, which is ideal for the lock/unlock mechanism that I built.

And here’s what the actuator is driving. I had a few pieces of metal lying around, and an angle bracket which got around the concrete blocks nicely to meet the door lock. I added a couple of bearings to reduce the friction on the mechanism, I didn’t want to burn out the actuator. When it was built, it was still a little stiff, so I greased it up, and it was then moving nice and smoothly.

The actuator came with a metal rod so I used that to connect to the locking system. Notice the small bit of tape to keep it from falling out of it’s hole! 😉

The actuator as two positions, and here it is in the latched position, where it just catches the door bolt.

And when the bark is detected, it moves the lock mechanism to the following position, allowing the door to swing open.

So, here’s the brains of the project. A Raspberry Pi in the centre, a motor driver PCB to the left. I used this because it easily allows me to send 12 volts to the actuator in either polarity, for pushing or pulling the door bolt. The PCB on the right is the audio detection circuit from Maplin. And at the bottom is the 12V actuator. The small veroboard PCB is just a voltage breakout with GND, +5v and +3.5v, to make the wiring easier. Coming into the board from out-of-shot above is the 5V supply for the Raspberry Pi, and the 12V supply for everything else. I used a piece of 5mm clear acrylic to mount everything on, which makes it nice and neat, and also portable if I ever bring it to a show-and-tell! 🙂


All the wiring is done with dupont connectors, 0.1″ (2.54mm) pitch, just like the Raspberry Pi GPIO header. I got a crimp tool off eBay, as well as a a few dozen blank connectors and a roll of female crimps. Make cabling up this kind of project very easy, where you don’t want to solder everything into place.  And now I can make a custom connector for the GPIO header very easily without fiddling with individual jumpers, and forgetting where they’re all supposed to go between projects! 🙂

Here’s the code to read in the GPIO from the audio circuit. I just count pulses, and when I get a particular number of pulses in a predefined time, I activate the unlock. It’s really low-tech, would be nice to sample the audio using the Pi itself and compare to known barks, etc. 🙂

import sys
import wiringpi2
from time import sleep
gpio = wiringpi2.GPIO(wiringpi2.GPIO.WPI_MODE_GPIO)
enable_1 = 27
enable_2 = 17
enable_3 = 18


sleep (0.1)

samples = [0 for i in xrange(50)]

ons = 0;

while (1):
        sample = gpio.digitalRead(enable_1)
        samples[j] = sample
        ons = 0;
        for i in xrange(50):
                if (samples[i] >0):
                        ons = ons +1;
        j = j + 1
        if (j>49):
                print ons
        if ons >25:
                print ons
                sleep (0.1)
                sleep (2)
                sleep (0.1)
                for i in xrange(50):
                        samples[i] = 0;
                sleep (0.01)

So, there you have it!

Oh, one more thing, I was asked to include some footage of the dog using the device, which I don’t have yet, but here’s a pic of her just after we got her chipped (tracker, not CPU). 🙂


Raspberry Pi is a trademark of the Raspberry Pi Foundation

About the Author:

By day I’m a senior embedded Linux software engineer. In my spare time, I take pictures, and play with gadgets and technology.

Twitter: https://twitter.com/climberhunt @climberhunt
Facebook: https://www.facebook.com/davidhuntphotography

Be sure to check out my other Raspberry Pi related articles, and if you like, you can subscribe by entering your email address at the top right of the page. 🙂

Other Related Posts:



This entry was posted in Computer Stuff, Raspberry Pi, Tutorial and tagged , , , .


  1. smihael May 12, 2013 at 11:35 pm #

    OMG so cool!! but how do you close the doors once they are opened? 😉

    • daveh May 13, 2013 at 10:26 am #

      Door stays open. She’s free to go in and out during the day, but she has to be put in at night and the door is closed manually. 🙂

  2. Michael Horne May 13, 2013 at 10:38 am #

    That is a really excellent use of the Pi 🙂

  3. Bartek May 13, 2013 at 2:31 pm #

    What if burglars start to bark at your door ?
    Strangely, wouldn’t it be safer to train the dog to use door handle and open the door ?

    • daveh May 13, 2013 at 2:36 pm #

      Bartek, the dog sleeps in an outhouse, full of worthless junk. I’d be quite happy for someone to take it away! 🙂
      It’s purely an educational and fun project, not a serious security application! 🙂

  4. Jan May 13, 2013 at 6:02 pm #

    Why didn’t you let the raspi perform the sound detection using a very cheap USB soundcard and microphone ?

    You might even be able to detect whether the dog is barking, or a burglar pretending 🙂

    • daveh May 13, 2013 at 6:19 pm #

      Good idea, Jan. The audio sensor I used is what triggered the idea, and it had least amount of programming. 🙂

  5. Philip Ashmore June 28, 2013 at 1:46 am #

    What about a detector that can read and recognise the chip ID of the chip in your dog, to avoid sleep-overs?

  6. Brandon Brown June 29, 2013 at 7:45 pm #

    Excellent work on this project I enjoyed the video. I have one suggestion though if you are going to actually use this system to help clean it up a lot. There are Electric door strikes you can purchase on eBay for $20 that run off of 6-12 volts I ordered one some time ago and it works magnificent. Here is a link to one http://www.ebay.com/itm/Electric-Strike-Lock-Wood-Metal-Door-Fail-Secure-NO-/250784848454

    • daveh June 29, 2013 at 7:53 pm #

      Excellent! Time for a tidy up!

  7. Jean-Paul June 30, 2013 at 5:55 pm #

    Nice trick, do you have a link to the audio detection circuit ? I can’t find it 🙁

    • daveh June 30, 2013 at 6:00 pm #

      Jean-Paul, I just had a look on the Maplin website, and it doesn’t seem to be on there. Maybe it was an in store special?

24 Trackbacks

  1. By Cool Raspberry Pi | Circle and Square on May 16, 2013 at 10:28 pm

    […] Bark-activate door-opener piRadio Like this:Like Loading… […]

  2. […] ที่มา http://davidhunt.ie/?p=3132 […]

  3. […] a weekend project from Dave Hunt for dog owners whose best friends can’t work out whether they want to be inside or […]

  4. […] a weekend project from Dave Hunt for dog owners whose best friends can’t work out whether they …read […]

  5. […] Bark Activated Door Opening System with Raspberry Pi – for more info check out my blog at http://davidhunt.ie/?p=3132. Done for the laugh, could be done a lot easier with a timer, etc. It was great fun doing it, and […]

  6. […] Dave Hunt je objavil zanimiv projekt, ki je namenjen vsem lastnikom psov, saj si bodo lahko olajšali delo z odpiranjem vrat. Idejo je dobil, ko je njegova psica lajala in on še globoko spal, saj ji je sicer moral odpreti vrata, da je vsak dan ob istem času šla ven. Dave je razmišljal, da bi lahko uporabil neko časovno stikalo, vendar se je premislil, saj se ob tem nebi mogel kaj dosti zabavati. Tako je izdelal pravi sistem, ki se odzove na lajanje. […]

  7. […] Pi-Rex — Bark Activated Door Opener | David Hunt Photography via Raspberry Pi […]

  8. […] Pi-Rex — Bark Activated Door Opener | David Hunt Photography around Raspberry Pi […]

  9. […] Dave Hunt shared: “Pi-Rex — Bark Activated Door Opening System with Raspberry Pi – for more info check out my blog. Done for the laugh, could be done a lot easier with a timer, etc. It was great fun doing it, and my kids showed a real interest in the progress as I was building it.” (read more) […]

  10. […] Pi-Rex — Bark Activated Door Opener | David Hunt Shooting via Raspberry Pi […]

  11. […] not take into account correct dog behaviour or training methods. For more info check out my blog at http://davidhunt.ie/?p=3132. Done for the laugh, could be done a lot easier with a timer, etc. It was great fun doing it, and my […]

  12. By Dörr som öppnas av hundskall | Feber / Pryl on July 2, 2013 at 1:39 pm

    […] han utvecklade Pi-Rex så hittas mer detaljerade instruktioner på länken nedan. via LifeHacker http://www.davidhunt.ie […]

  13. […] not take into account correct dog behaviour or training methods. For more info check out my blog at http://davidhunt.ie/?p=3132. Done for the laugh, could be done a lot easier with a timer, etc. It was great fun doing it, and […]

  14. […] Photographer David Hunt has created this rather awesome system that requires a bark for the door to open. In the video below we see the set up and an example of it working. Before you poke holes in it, David notes that this is not a security system and is just a proof of concept only. You can find out more info over at his blog. […]

  15. […] all that complicated. Hunt even gives you all the code you need to make a Pi-Rex for your very own over at his website. Finally, Fido is free to relieve himself at will — so you can get some […]

  16. […] [David Hunt] via […]

  17. […] HARK A BARK: Looking for a project for your Raspberry Pi computer? One Irish inventor wanted his dog to be able to let itself out and in through the door, […]

  18. […] David Hunt created a clever hack for a door for dog owners who are tired of getting up to let Fido outside at […]

  19. […] a metal arm, which pulls back the tongue of the door’s lock. You will find more detail on Hunt’s blog. Here’a a video for […]

  20. […] * SpaceX shows off new nav gear with latest Grasshopper rocket launch-and-landing >> * Anki will bring artificial intelligence and robotics into people’s everyday lives >> * Pi-Rex – Bark Activated Door Opener with Raspberry Pi >> […]

  21. […] The project requires a bit of know-how when it comes to soldering and basic electronics, as well as the code used by Raspberry Pi to trigger the device – but fear not – Hunt explains it all over at his website in a step-by-step guide. […]

  22. […] und der Verschluss öffnet sich. Und geschlossen wir die Tür natürlich auch wieder. Auf seiner Website erläutert Hunt, wie er die Konstruktion zusammen gebaut hat. Gekostet hat sie ihn vermutlich […]

  23. […] Rex” ha sido creado por David Hunt, el cuál explica que su motivación fue el tener un nuevo miembro en su familia. Un perro que se […]

  24. […] Acompanhe o link: http://www.davidhunt.ie/?p=3132 […]