book collections email follower instructable user

The PiNG Video Doorbell is powered by a Raspberry Pi and is retro-stylishly cased in a 1986 Intercom and an old Sony cassette player.

When the doorbell button is pressed the Pi makes a high-quality video call using Google Duo, which can be answered on a phone, tablet or computer, letting you see and speak to callers when you're away from home (or at home but trapped under a cat). It works over WiFi and cellular, so you can even answer the door when you're out pounding the streets.

It also sounds a standard wireless door chime inside the house as a fail-safe, in case the call can't be taken.

The setup and code are very straightforward, read on and I'll show how you can make your own video doorbell from scratch in just a couple of hours for well under £50 (or for practically nothing if you already have a Pi and some components lying around!).

There's a full video showing the build and features on YouTube at https://youtu.be/Bn1qj2Uvl0w if you can't see the embedded version. The video's quite long but there are individual chapter links below so you can skip to the relevant section. There's also a behind the scenes video at https://youtu.be/7_2Ll03UDBw

Step 1: Opportunity Knock Knocks

Picture of Opportunity Knock Knocks
20190413_193036.jpg
20190420_165251.jpg

I've always fancied making a video doorbell using a Raspberry Pi, but until recently I couldn't find an easy way to make video calls that would both work in a project and be straightforward for others to recreate. That all changed on 26th February however, when I read reports that a browser-based version of Google Duo had been released - meaning that it would run without installing a dedicated app.

Having already researched the challenges of making Pi calls with Skype and WhatsApp I was on the point of installing Android to try and use Google Duo, but was put off by not being able to easily integrate the GPIO interface, so the web app news was really encouraging. After devouring the articles I first tested Duo on my windows laptop, and swiftly moved on to try it with Chromium on my workshop machine, a Pi 2. This didn't go so well, the Duo site appeared and let me log in, but didn't display my contacts list or any options to change settings. I decided to look into using other browsers (the write-up said it also worked on Firefox and Safari) and also test it on a more beefy Pi 3.

I hooked up a Logitech webcam to the Pi 3 then fired up Chromium, and to my amazement was able to video call my wife in the living room seconds later, after tweaking a few settings. The webcam I tested had a built-in microphone and even on the first thrown-together test call the quality was great. This was a very exciting moment, unlocking the potential of the video doorbell project as well as many other possibilities.

So video-calling with a keyboard, mouse and screen was a definite go - but how to make this work with a headless Pi and buttons?

croweragan23 days ago
Hi. Thanks for sharing this.

I'm running the latest Raspbian but there's no "Install Google Duo" under the three dots/hamburger. When I use More Tools --> Add to Desktop it just creates a shortcut to that webpage. Opening it just runs Chromium and goes to that page. What am I missing about running a standalone Google Duo app?

Thanks for any insight you can share.
GjuljoB4 months ago
Great job. Nicely done. Thank you.
PaulChau4 months ago
There is a modern version that is readily available in stores today. You can access the app from anywhere where there's a connection and you can save the video recordings too. It works great for receiving of parcels when you are away and to prevent thefts as the app detects motion too.
Very nostalgic, i loved it!
SpinobiFire4 months ago
Hey MisterM,

First of all thanks for your time and effort in sharing this resource, you've done an amazing job!
I'll start by sharing something small that I've seen a few people asking about, then I've a question of my own too if that's okay?

I noticed a few people asked about their camera taking a photo after the button depression, this thread is for people using Webcams:
https://www.raspberrypi.org/documentation/usage/webcams/
eg 'fswebcam image.jpg'

This is for people using a Raspberry Pi camera:
https://www.raspberrypi.org/documentation/usage/camera/raspicam/README.md
eg 'raspistill image.jpg'

This would be a bash script to make a webcam take a photo and save it with datetime:

#!/bin/bash
DATE=$(date +"%Y-%m-%d_%H%M")
fswebcam -r 1280x720 --no-banner /home/pi/webcam/$DATE.jpg



So that's my contribution {^_^}! Now, I'm trying to follow in your footsteps and I'm encountering a problem with pymouse.

I've made some notes here to try to document what's gone wrong and ways I've attempted around it:



So the issue centers around it not being able to see the pymouse module, although it should be satisfied as you can see above, it's been presumably installed via PyUserInput, but to be doubly sure I've taken pymouse down on it's own.



Next up, you can see some of the permutations of the module name that I've attempted changing:

'from pymouse import PyMouse' {your original, working line that seems off now}
says:
pi@raspberrypi:~ $ sudo python3 PiNG.py
Traceback (most recent call last):
File "PiNG.py", line 7, in
from pymouse import PyMouse
ImportError: No module named 'pymouse'

'from PyMouse import PyMouse'
says:
pi@raspberrypi:~ $ sudo python3 PiNG.py
Traceback (most recent call last):
File "PiNG.py", line 7, in
from PyMouse import PyMouse
ImportError: No module named 'PyMouse'

Then adding '-1.0' to the name as it arrives after download from pip3 causes a syntax error:
pi@raspberrypi:~ $ sudo python3 PiNG.py
File "PiNG.py", line 7
from PyMouse-1.0 import PyMouse
^
SyntaxError: invalid syntax

pi@raspberrypi:~ $ sudo python3 PiNG.py
File "PiNG.py", line 7
from pymouse-1.0 import PyMouse
^
SyntaxError: invalid syntax

Perhaps you could shed some light on what I've done wrong please? Has this affected the running of your door, or is it that I'm making a mistake that I'm not noticing?

Thanks for your time & effort as it's much appreciated,
Kenneth


Edit after more attempts:


So having learned of the merge of PyUserInput combining PyMouse and PyKeyboard, I've been following through their Github {the latest one, https://github.com/PyUserInput/PyUserInput}

So I've fully removed PyUserInput and what I've established as an older redundant version of PyMouse, then taken down PyUserInput, Xlib, six and have attempted further ways of calling the modules:

You can see here how I've tried to get it to import from PyUserInput directly ^


After those changes, it doesn't complain about not finding the modules, however it's not able to see Xlib even though it's been taken down.


Is there anything obvious that I'm getting wrong? After taking all of the packages down again, I'm getting the same problems in PiNG.py or position.py.

Thanks for your time,
Kenneth
MisterM (author)  SpinobiFire4 months ago
Hi Kenneth and thanks very much for sharing the useful links and your code experiences! I had similar head-scratching with PyUserInput at first but tracked it down to how I'd installed it, if I remember rightly I first installed it with "pip install PyUserInput" then got those "No Module Named ..." errors, then when I instead used "pip3 install PyUserInput" it was fine all the way, I think it's to do with the version of Python that pip and the Pi use as default. Hope that helps!
Hey there! Thanks for your prompt reply!
It seems as though Instructables has cleaned out the images I'd been sharing that were ladden throughout my post.

Thanks for the tip on pip/pip3! The flumocksing thing about it is that the behaviour I'm mentioning happens even when I attempt pip3 install PyUserInput.

So you can see here how I'm attempting to get it to take 'from PyUserInput import pymouse':
https://monosnap.com/file/oSQV01abLU7x1UxWocFgfV5WwvVBP2

Once you get that far it seems happy enough with the pathing to the modules PiNG.py wants, but it then starts to act up about not being able to find Xlib. Even with a pip3 of Xlib, it's still giving out:
https://monosnap.com/file/eRhqNZVqcjHQVioyWEkwcarxXTWh97

Once I can get past the issue of PyUserInput, my ambition then is to run a second python script that acts as a flask server, giving the user a HTML page with a button & remote GPIO, as it'd be the next logical step to allow a person trigger the door open if they're a friendly. You can see here in Matt Richardson's guide how it's quite easy to allow for a webpage that can add that functionality:
http://mattrichardson.com/Raspberry-Pi-Flask/index.html

For what it's worth, while investigating all of this manner of project, it is worth noting that UV4L can allow data transmissions, so in theory, it'd be possible to have a call in which one could invoke some python to allow the user to activate a relay switch to a door lock. However in the mean time, I'm hoping to get your project working with Google Duo and another HTML page to do what I'm after.
Thanks,
Kenneth
Okay, finally making a bit of ground here. It seems that you need to run this:
pip3 install --user PyMouse
Found here : https://stackoverflow.com/questions/51337887/cant-use-pymouse

Having done that, I started to get new errors, at which point I twigged that the reason it was happening was because I was SSH'd into it.

pi@raspberrypi:~/pingdoorbell-master $ sudo python3 position.py

Traceback (most recent call last):
File "position.py", line 4, in
m = PyMouse()
File "/usr/local/lib/python3.5/dist-packages/pymouse/x11.py", line 86, in __init__
self.display = Display(display)
File "/usr/local/lib/python3.5/dist-packages/Xlib/display.py", line 89, in __init__
self.display = _BaseDisplay(display)
File "/usr/local/lib/python3.5/dist-packages/Xlib/display.py", line 71, in __init__
protocol_display.Display.__init__(self, *args, **keys)
File "/usr/local/lib/python3.5/dist-packages/Xlib/protocol/display.py", line 84, in __init__
name, protocol, host, displayno, screenno = connect.get_display(display)
File "/usr/local/lib/python3.5/dist-packages/Xlib/support/connect.py", line 73, in get_display
return mod.get_display(display)
File "/usr/local/lib/python3.5/dist-packages/Xlib/support/unix_connect.py", line 76, in get_display
raise error.DisplayNameError(display)
Xlib.error.DisplayNameError: Bad display name ""

This is what it looked like via SSH^

I skipped back over to the Pi itself directly {although VNC would be the same} and then tried position.py and it's doing what it's meant to now, pumping out x&y coordinates.

The final hurdle now will be to get it to behave as it should via PiNG.py

Thanks for your help MisterEmm, I'll share any other findings I have in case they help the next guy!
MisterM (author)  SpinobiFire4 months ago
I'm glad you're making progress there! I remember having problems like that with it when I was getting it to run on boot from the autostart file, turned out it would only run *without* the sudo before the python3, which sounds similar to your SSH problems. Good luck with the rest of it!
Muchas gracias por darte tu tiempo y compartir tus conocimientos , se agradece sinceramente; sigue asi amigo
auto131428284 months ago
What's the total cost for all of these parts?
MisterM (author)  auto131428284 months ago
Good question - I used a lot of bits I already had, to use exactly the same things it'd probably be around £60, but I splurged on a specific speaker for the case and used the pHAT Beat, really for a basic version you just need a Pi, a webcam, button and a battery speaker so could be as little as £40-45 :)
MarkosMark4 months ago
Nice project! Is it also possible to preview the video before answering? Because if I'm seeing it right, you can only see the video after picking up the call.
MisterM (author)  MarkosMark4 months ago
I think technically if you have "Knock Knock" turned on in the Duo settings then it's set to show the video as a preview, but in reality on the Pi it makes the connection first and starts ringing then shows video as soon as it can, which takes a second or two - I imagine it would show the preview if it was left ringing long enough?
Would you, or someone who is using this, like to test this for me if that works? Because I don't have the hardware yet so I can't test it myself. And I can imagine that this would be an interesting feature for a lot of people.
MisterM (author)  MarkosMark4 months ago
That was an interesting test - I left it ringing until it timed out, about a minute, and the "knock knock" preview video didn't show through at all. Wondering if it would be any different with an integrated Pi camera rather than a USB webcam, will give it a try once I've got the "one box" version working.
That's a bummer, hoped that the "knock knock" preview would work.
I see more people have problems with the knock knock feature. I don't know if it isn't working at your setup because of the software in the doorbell or de settings on your phone. A few solutions I found are:
- check settings to see if the option "limit mobile data usage" is disabled
- clearing the app cache of Google duo and reboot
- make sure it has the latest version
- some countries block knock knock for legal reasons (privacy?)
MisterM (author)  MarkosMark4 months ago
I'll give it a go later this afternoon and reply back - curious myself now!
pauldg994 months ago
You need a laser cutter! :) Awesome project
RumpelS4 months ago
This is an interesting project. However your biggest error is using Google Duo. Do you remember that Youtube once was completely free of ad's? Now Google even puts ads which you cannot turn off anymore and asks you to pay for Youtube. The same will happen in the future with Google Duo. An other problem of a web based app is that in the future Google will modify it so it will need a newer browser. So you will permanently having to keep your doorbell up to date. Apart from that: Are you sure that you want Google to see all the people who ring your door? Did you know that Google uses Artificial Intelligence to scan ALL the data that runs over their servers? They make a profile about every user. So what you do is let Google see ALL your friends ringing you door bell and make a profile about you. Wellcome to George Orwell's state of surveillance!
sevenmead4 months ago
Excellent work! And the Instructable is top notch.
MisterM (author)  sevenmead4 months ago
Thank you!
Taverde4 months ago
I love this whole project. The bit about being stuck under a cat was a highlight in the explanation!
MisterM (author)  Taverde4 months ago
Thanks, it happens quite often here - I do need to work on voice operated answering in case of being both stuck and having phone out of reach!
Frosty704 months ago
Love the idea! Thanks for posting.
MisterM (author)  Frosty704 months ago
Thanks!
Henmarsh4 months ago
Great project, beautifully and complehensively presented - thank you. I've had most of the bits (except the brilliant re-purposed housing) kicking around for many months and this'll be my first foray into Google Duo so lots of fun ahead!
MisterM (author)  Henmarsh4 months ago
Thanks! I love that it works pretty simply with fairly standard bits 'n pieces, good luck with your build!
Archibold4 months ago
hi, can this be programed so it takes a static photo as soon as the button is pushed?
MisterM (author)  Archibold4 months ago
I think so, yes, you'd probably need to install the Python module fswebcam but then it'd be straightforward to take a pic, just an extra few lines of code to do the capture after the button is pushed. Bit more info at https://www.raspberrypi.org/documentation/usage/webcams/ - what I'm not sure about is whether access to the webcam is "locked" by Google Duo (because the webcam is already selected in the Audio & Video sources) - in this case the fswebcam module might not be able to do the capture.
kenbob4 months ago
I just added a new project to my white board. Thank you for posting your work!
MisterM (author)  kenbob4 months ago
That's great, good luck with it! And also thanks for reminding me to update my board, that's supposed to be the ceremonial thing I do after hitting Publish :)
jessyratfink4 months ago
This is such a great project! Excited to hear your first real world call went well, too :D
MisterM (author)  jessyratfink4 months ago
Thanks! There was no-one more surprised than me when it worked!