PebblyPi Smart Doorbell

After this tweet…

…alot of people asked for some kind of tutorial so here it is :-)

First a youtube video of it in action



Parts

  • Raspberry Pi Model B
  • Pebble Smart Watch + Smartphone
  • Pushover App (iOS or Android) plus Pushover Account
  • A Button to act as the doorbell – I used this Waterproof Metal Pushbutton with Blue LED Ring but you could use any momentary push button.
  • A 10K Pull-up resistor – needed for the button circuit.
  • Multicore cable to connect the button to the RPi – I used telephone cable as it has 4 wires and I needed to both power the LED ring and detect the button pushes.
  • PC Speakers – I just used some that I had lying around.
  • (Optional) Adafruit PiPlate – I used it just to make my life easier with wiring but you could jumper straight into the RPi GPIO if you like.
  • (Optional) EDIMAX Wifi Module – You can use the ethernet port on the RPi but I wanted mine to be wireless.

Method

  1. Wire and Mount Your Button
    The button I chose had both a normally open and normally closed setup. As I want to pull the button low to activate the python code I soldered the ‘NO1′ to the ‘Blue+White Stripes’ wire and the ‘C1′ to the ‘White+Blue Stripes’ wire. I also want to power the LED so soldered the ‘+’ to the ‘Orange+White Stripes’ wire and the ‘-’ to the ‘White+Orange Stripes” wire. Honestly, the wiring layout doesn’t matter just make sure you note down what wire is what before you permanently mount the button.
    Doorbell Wiring
    I used the laser cutter at Makespace in Cambridge to make a nice mounting plate for the button and mounted it on the outside of my house with wall plugs. Snazzy huh?
    DoorbellDoorbell
  2. Raspberry Pi & Pushover – Software and Wiring
    The current build of raspbian has the EDIMAX drivers included as standard. However if you are using a distro without these drivers, Robert Savage has a good tutorial on how to use the EDIMAX wifi adapter.Now download the Pushover App, make sure you can send notifications to your pebble (see this entry in the Pushover FAQ for help) and login at http://pushover.net. Create a new application by clicking ‘Register an Application’.Pushover_RegAppFill out the form with the required information then click ‘Create Application’. This will take you to the application page where you need to note down the API token. This will be used later.Pushover_AppKeyNow you also need to note down your user key which can be found on your main dashboard page on Pushover.Pushover_UserKey
    For the code I simplified Adafruit’s tutorial code on playing MP3′s with buttons on the RPi to use only one button and added some code to push messages to the Pushover notification service. All you need to do is copy the code below into a new *.py file on your RPi and replace the ‘application_token’ and ‘user_token’ strings with those from your Pushover Account that you noted down earlier. Also you will need to save an MP3 for playing in the directory with the *.py script. Mine is called ‘doorbell1.mp3′ in the code below, but you can play any file you like.

    !/usr/bin/env python
     
    from time import sleep
    import os
    import httplib, urllib
    import RPi.GPIO as GPIO
     
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(23, GPIO.IN)
     
    def PushOver(title,message,url):
       application_token = "EnterYourApplicationTokenHere"
       user_token = "EnterYourUserToeknHere"
       # Start your connection with the Pushover API server
       conn = httplib.HTTPSConnection("api.pushover.net:443")
     
       # Send a POST request in urlencoded json
       conn.request("POST", "/1/messages.json",
       urllib.urlencode({
       "token": application_token,
       "user": user_token,
       "title": title,
       "message": message,
       "url": url,
       }), { "Content-type": "application/x-www-form-urlencoded" })
     
       # Listen for any error messages or other responses
       conn.getresponse()
     
    # Application specific variables
     
    PushOver('Doorbell','Started','')
    print 'Doorbell Server Started\r'
     
    while True:
     
       if (GPIO.input(23) == False):
          print 'Button Pushed!\r'
          os.system('mpg321 /home/pi/doorbell1.mp3 &')
          PushOver('Doorbell','Ding Dong!','')
       sleep(0.2);

    Now for the wiring on the RPi. Shamelessly using the wiring diagram from Adafruit, you can see that you need to connect a 10K pull-up resistor between 3.3V logic level and the GPIO pin you want to use (in the case of the code about I used pin 23). The button is then wired to ground (‘C1′ wire) and the GPIO pin (‘NO1′ wire).

    When the button is pushed GPIO pin 23 is pulled to ground and the ‘if (GPIO.input(23) == False)’ condition is then satisfied, firing the MP3 to play and the notification to be sent.

    You will also need to plug in the speakers into the audio out on the RPi.

    Additionally we want to power the LED so need to wire it up to the RPi for power. Despite what the data sheet says for the push button, you can power the LED from the 5V line on the RPi. Just find the pin that says 5V, connect it to ‘+’ and connect ‘-’ to ground. It looks awesome too.

    IMG_20140429_210215

  3. Try it outIf everything went well, run the script and when you press the doorbell the MP3 should play followed by the Pushover notification popup on your phone and Pebble smart watch.Result

Further Work

So there you go, should all work, kinda, sorta. Though honestly it was hacked together so there are a few other things I would like to do with the system.

Ultimately I would also like the doorbell to:

  • Track doorbell presses against time in a IoT service like Thingspeak.
  • Some kind of webpage visualisation hosted on the RPi showing the doorbell stats.
  • Attach a camera to the system so the doorbell can send and log a picture of the doorbell user.
  • There is an issue that you can spam the doorbell button and it will also spam the Pushover notifications. I would want to put a timeout or something in the code to stop that situation.

12 comments

  1. […] to popular demand, Daniel Garden has put together a tutorial for his PebblyPi Smart Doorbell project. Check it out […]

  2. […] Daniel Garden made his doorbell ring on his Pebble smartwatch! […]

  3. […] perfect match. This is probably what [Daniel] thought when he embarked upon his latest project, a smart doorbell called the PebblyPi (tip submitted by […]

  4. […] [get more information on PebblyPi]google_ad_client="ca-pub-9951566236021307";google_ad_slot="0794282718";google_ad_width=300;google_ad_height=250; People who visited this article also visited: […]

  5. […] PebblyPi Smart Doorbell | Muacks & Glomps via Hack a Day […]

  6. […] PebblyPi Smart Doorbell | Muacks & Glomps via Hack a Day […]

  7. […] a nice writeup of the project at Daniel’s blog, and if you’re in Cambridge you can head down to the Makespace (where […]

  8. […] a nice writeup of the project at Daniel’s blog, and if you’re in Cambridge you can head down to the Makespace (where […]

  9. […] PebblyPi Smart Doorbell [Muacks & Glomps via Hack a Day] […]

  10. […] Wer es nachbauen möchte, der findet alle Details auf Daniels Blog. […]