loading

This Raspberry Pi, IoT Doorbell is basically a simple smart Door Bell, which takes a photo of whoever rings it, and emails it to the specified email address, and keeps all the photos in a folder. (along with going Ding-Dong). This is my first Instructable so I hope you enjoy :)

How I have set out setting this up is: OLD:

the camera is looking at the door bell. I couldn't have the camera above the box because my lead is not long enough

-----UPDATE!!----

I have Got a new setup where the Button Cable is routed through a small gap in a window next the frount door where the camera taped so it is looking out the window,

PS: The camera quality in my examples is bad because I have a cr*p camera.

Step 1: Parts/ Tools

Here is the list of parts with approximate prices and links, though you don't need to buy these exact parts

NOTE: :Project costs around $110, Though price can be made cheaper/ more expensive depending where you buy the parts, or using an RPi 1/2.

ALL PRICES ARE IN AUD,

Raspberry pi $55, I've linked Raspberry pi 3, though any should work, though you will need a Wifi adapter if you wish this project to be wireless. You can also use the Raspberry pi 1 B and save $20

Wi-Fi Adapter $10You don't need this if you're using ethernet or RPi 3.

Pi Case $14You don't need this but i recommend it so your pi doesn't get damaged.

Mini Breadboard $1.29 to do wiring on

Button $1.29 (waterproof, Normally Open)

Lengthy wire, to from pi to doorbell

1K resistor, $2.48required for button circuit (only one needed)

Bread Board Jumper Cables $5.19 - you only need 3 :)

Webcam $4 - $100

Box to hold button in $2-10

_____________

Tools:

Soldering Iron (Recommended)

Wire Stripers

Side Cutters/Sharp scissors

Computer

Internet

Step 2: Setting Up Hardware.

-------------------

IMPORTANT:

I made some mistakes:

It is 5v not 3v

It is 10K Resistor not 1K

------------

If you are using a non B+ Model

you will have to use GPIO 7 (or other) instead of 21!

-------------------

Hardware is pretty simple. Plug your Webcam into the Rasp-pi, along with your selected network interface. Then, using the images as a guide (the wiring diagrams + this pinout for rasp pi 1B), connect your button and resistors to the pi. With the breadboard image, the orange and blue wires are the wires running the the door bell (Project Box with button).

Step 3: Making the Door Bell

To Make the door Bell you will need to cut a 12mm (1/2") hole in the centre of the project box, and around a hole near the bottom for your wires. Im my case I have taped over the bottom hole(and wires) to stop water from coming in.

Step 4: Software & Programing

Now This is the harder part. First off SSH into your Pi (Raspbian Wheezy or Later).

--- Wondering how to SSH?

here you can find instructions by Antares72 for setting up SSH on Windows with the Pi

Or see here for instructions for Linux or Mac users.

________________________________________

For the "Advanced Users, I have put comments in the code explaining how it works

Follow these instructions (Once in the command line) (copy exactly

Remember to NOT copy the " $ " in these commands if you are copy and pasting.

First, make sure your in your home directory (or whatever directory you wish to install the program to ( PS: it is contained in one folder, so it won't go everywhere in your home directory)

$ cd ~

Then we want to download the dbell folder containing all the code:

$ git clone https://github.com/Happypig123123/dbell.git

Now we want to CD into the directory

$ cd dbell

$ mkdir photos


-------VERY IMPORTANT!!!!!! -------

# NOTE: If you do not use B+ Model, you will need to change the "Button" variable in bell.py from 21 to a # pin number that's available on your pi. TO do this do

# $ nano bell.py

# and change the Button = 21 line to something like Button = 7

# Pinouts are on the "Setting Up Hardware" Setting Up page


Now our setup is time to start editing the email code.


Step 5: Gmail Setup

Gmail?

For this program to work, you will have to make a GMAIL account (or use a spare one (thats Gmail) ) to send the emails to Your Email. Through out the next steps I will call this GMAIL account :

I made mine C*******Iot@Gmail.com

Step 6: 3.5.6) Email Script Customisation

Ok Now we setup the Gmail account we can now set up the Email Script. I would like to give credit to Gagandeep Singh, for his code is used in the IoTNotify script, And Sentdex, for his tutorial on python email tutorial, which allowed me to understand the process.

For the more advanced users who want to know how this works, Check out Sentdex's tutorial as I have not explained at all how this script works.

Now do this:

$ nano IOTNOTIFY2.py

and change the following values:

Do this for all of the Fields

to the Gmail account email address E.g: exampleIoT@gmail.com

Yeah, Ass-Word, Wops, Spelling Mistake...

to the email you want to be notified at (eg: your personal email that on your phone, so your phone goes "Buzz" When someone's at the door)

After you have changed all the values, press Ctr X, then Y to save the document

Step 7: 4) Running the Code

Do

$ python3 bell.py

And the script will repeat forever until you press Ctrl Z or Ctrl C

-----------

If there is any problems with the script, or i did something wrong, feel free to leave your feed back below (in comment form)

-----------

I hope you enjoyed this instructable :)

<p>i have this error please help to solve</p><p>what should i do</p><p>Email</p><p>Traceback (most recent call last):</p><p> File &quot;IOTNOTIFY2.py&quot;, line 29, in &lt;module&gt;</p><p> server.login('mewada72894@gmail.com','myoldjeans')</p><p> File &quot;/usr/lib/python3.4/smtplib.py&quot;, line 652, in login</p><p> raise SMTPAuthenticationError(code, resp)</p><p>smtplib.SMTPAuthenticationError: (534, b'5.7.14 &lt;https://accounts.google.com/signin/continue?sarp=1&amp;scc=1&amp;plt=AKgnsbv8\n5.7.14 I7caO_mMTlDCB5rUCEs-jGeqFe5ueUJTU75ApgdYJe-xePRmstwRm6bYLxKfnUC4NfAzAK\n5.7.14 TXC0QiaEdSNSsQQaQWR_cP43lU91PLFtnHaYHlz4Sr-9btEp8xdG-p_31EipeApWRTtXKu\n5.7.14 CxQiMALZSOj3VX80HsM332g4LCFnKyXulB-DMwhFZLy64XmiC9iQCpwNXFSBLfgjwQI7yO\n5.7.14 rNc2kyoDRxQxkYYTMMSqZt4kjVyUA&gt; Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 y6sm21630291pgc.40 - gsmtp')</p><p>Done Process</p>
<p>Darmish Did you get this working?</p><p>Looks like an authentication error on gmail</p><p>BTW did you change your password? You gave your password &quot;Myoldjeans&quot; away while cutting and pasting.</p><p>I would like to continue this project so I am interested in what others have done.</p><p>Thanks MM </p>
Hi Darmish, I will have a through look today. To help could paste in the contents of IOTNOTIFY2.py in here so I can see what changes you've made. (That the Instructables asked you to do). Before that make sure you've filled out all the fields
<p>I'm getting the following error when I run the python file:</p><p>Traceback (most recent call last):</p><p> File &quot;bell.py&quot;, line 6, in &lt;module&gt;</p><p> GPIO.setmode(GPIO.BCM)</p><p>AttributeError: module 'RPi.GPIO' has no attribute 'setmode'</p><p>I've tried everything. Please help, urgent!</p>
<p>Hi Jaimish. I made this on Pi3 but changed </p><p>the gpio setup to BOARD</p>
<p>Hi JamishA, I think the problem is on your side. What version of the raspberry pi do you have, and what version of raspbian is it running? And have you done any other projects using the GPIO pins on the pi? Then, I will be able to have more information on how to solve your issue. Thx, Angus.</p>
Hi JaimishA, I am currently away from my PC, so in around a day or so I should get back 2 you with the answer to your problem
<p>To use the pi cam </p><p>in bell.py</p><p>added &quot;from picamera import PiCamera&quot;</p><p>in oscmds.sh</p><p>changed the command to take the photo. Used raspistill without any switches.</p><p>I left the old USB there as a comment for my own purposes.</p><p>#!/bin/sh</p><p>cd photos</p><p>echo &quot;Taking the Photo&quot;</p><p>now=$1 #Now is the filename time stamp</p><p>#take pic</p><p># MM commented out to switch to PI Cam. fswebcam -d /dev/video0 -r &quot;640x480&quot; $now.jpg</p><p>raspistill -o $now.jpg</p><p>echo &quot;Pic Taken&quot;</p><p>echo&quot;&quot;</p><p>#ring Bell</p><p>echo &quot;Ringing Bell&quot;</p><p>echo &quot;&quot;</p><p>echo &quot;&quot;</p><p>cd ..</p><p>omxplayer DBSE.mp3</p>
<p>Changed raspistill -o $now.jpg</p><p>&quot;&quot;</p><p>&quot;&quot;</p><p>to raspistill -w 800 -h 600 -o $now.jpg</p><p>&quot;&quot;</p><p>&quot;&quot;</p><p>1. The preview process would grab my screen and could only ssh to machine/ attached monitor went grey.</p><p>2. Image was too large for emailing.</p>
<p>Has anyone modified this to send SMS?</p><p>I am in Australia and our telcos do not support sending an email to your mobile service as per the US article <a href="https://www.instructables.com/id/Get-Gmail-To-Text-Emails-To-Your-Phone/" rel="nofollow">https://www.instructables.com/id/Get-Gmail-To-Text...</a></p><p>If i had a sms subscriprion I could send a second email to my sms gateway. EG <a href="http://www.burstsms.com.au/" rel="nofollow">http://www.burstsms.com.au/</a></p>
<p>Revision... SMS working. Used burstsms.com</p><p>Added a new .py to the dbell folder to send another email to 55512345@mysmsprovidor.com</p><p>My mobile is 0404xxxxx5</p><p>My account for email to sms is with burst</p><p>So 0404xxxxx5@burstsms.com</p>
<p>0404XXXXX5@transmitsms.com</p><p>Correction. Burst uses transmitsms not burstsms</p><p>yours will be different if you use something other than burst</p>
<p>Create new file SMS.PY in the dbell folder</p><p>import smtplib</p><p>server = smtplib.SMTP('smtp.gmail.com', 587)</p><p>server.starttls()</p><p>server.login(&quot;youremail@gmail.com&quot;, &quot;yourpassword&quot;)</p><p>msg = &quot;Message from the doorbell at home. Read email I have sent a photo!&quot;</p><p>server.sendmail(&quot;youremail@gmail.com&quot;, &quot;0404XXXXX5@transmitsms.com&quot;, msg)</p><p>#Burstsms uses the address @transmitsms.com for communication to the &quot;email to SMS&quot; service.</p><p>server.quit()</p><p>Modify scmds.sh to call SMS.PY</p><p>#!/bin/sh</p><p>cd photos</p><p>echo &quot;Taking the Photo&quot;</p><p>now=$1 #Now is the filename time stamp</p><p>#take pic</p><p># MM commented out to switch to PI Cam. fswebcam -d /dev/video0 -r &quot;640x480&quot; $now.jpg</p><p>raspistill -o $now.jpg</p><p>echo &quot;Pic Taken&quot;</p><p>echo&quot;&quot;</p><p>#ring Bell</p><p>echo &quot;Ringing Bell&quot;</p><p>echo &quot;&quot;</p><p>echo &quot;&quot;</p><p>cd ..</p><p>omxplayer DBSE.mp3</p><p>python3 sms.py</p>
<p>DOHH!!! Did not disconnect the usb camera.</p><p>Will have to get back on using picamera rather than USB</p><p>AGGGHHH!!!!</p>
<p>in oscmds.sh</p><p>changed </p><p>fswebcam -d /dev/video0 $now.jpg</p><p>to</p><p>fswebcam -d /dev/video0 -r &quot;640X480&quot; $now.jpg</p><p>Larger image in email</p><p>I am also using a pi camera. Started with usb webcam/ swapped out to picam no problem or need to change any software or script</p>
<p>I love this made it on Pi3</p><p>changed the gpio setup to BOARD</p>
<p>Nice IoT starter to get your feet wet. Thanks!</p>
<p>Awesome Raspberry Pi IoT Doorbell!</p>
<p>This is an awesome doorbell.</p>

About This Instructable

11,131views

95favorites

License:

More by AngusC5:Raspberry Pi IoT Doorbell 
Add instructable to: