Software apps and online services
Hand tools and fabrication machines
Hello everyone! I came across some nice software to make a fast video / 2-way audio doorbell with a Raspberry Pi, and found a way to fit all the components in a small case.
I will show you how to build it, including how to make push notifications work when you press the button.
The hardware build requires a bit of drilling and soldering. The software portion is pretty straightforward with no coding required (unless you want to customize the sample programs). But it does require a Mac and XCode.
See the following video that documents all the steps.Step One: Prepare and assemble all the hardware components
Get all the components from the list of components. Grab the plastic case, and mark the spots where to drill some holes as per the following diagram.
Then drill the three small holes for where the speaker will be, so the sound can come out.
Next drill the bigger hole on top right to place the button. Check your button diameter to pick the proper drill size.
After drilling, the edges around the holes tend to have a bit of an edge, so just cut around holes with a box cutter to make it all flat.
You can leave your case transparent, or if you want to give it a paint job now is a good time. A primer paint for cars works well.
Now let's prepare the speaker cables. They are really long and so they probably would be tricky to fit into the case. So shorten them by cutting and soldering them back together, and fit a heat shrink wrap, as show in the following picture.
Next strip some extra jumper wires and attach and solder them to the button.
At this point all the components are ready to be attached to the case cover. First install the button.
And then the speaker: attach its wires, remove the adhesive band, and press it in place.
And then I attach the camera module, which clicks nicely into the special case fittings.
Now for audio out, cut and strip another jumper wire (male so it connects with female wire on speaker), and pull it through the hole near the audio.
And then solder it to the audio out pin from the 3.5 millimeter audio jack.
See the following image for the audio out pin location shown by the red arrow on the back of the Raspberry Pi.
Then push the Raspberry Pi into the base of the case and connect up all the wires.
Below is the diagram of Raspberry Pi pin numbers. Connect speaker power to Pin #1. speaker ground to #6. Button wires to pin #7 and #9.
Then close the case shut, and move onto the next step.Step two: install a fresh OS on Raspberry Pi
For your Raspberry Pi 3 (or 3+), download and unzip Raspbian Stretch.
Apparently you should not install the latest Raspberry Pi OS because the audio player has an issue. I would hope that at some point it will be resolved.
Download and install the Raspberry Pi Imager.
Connect and format your microSD card. Then launch the Raspberry Pi Imager.
Pick a custom OS to install, and navigate to the Raspbian Stretch file you had downloaded and unzipped.
Select your microSD card, and click on "WRITE".
When it's finished, plug the microSD card into your Raspberry Pi.
Connect a monitor with the HDMI cable, and connect a USB mouse and keyboard. Then power up the Raspberry Pi.Step three: configure Pi to connect to WiFi and get the camera to work properly
Once it's up and running, go though the initial dialogs and get connected to WiFi.
Then click on the Raspberry icon on the upper left, then "Preferences", then "Raspberry Pi Configuration".
Then click on "Interfaces". Enable camera. Click OK and accept to reboot.
To check the camera is working, open up a console by clicking on the following icon on the top left:
Type the following:
raspistill -o cam.jpg
Then open up File Manager by clicking on the following icon on the top left:
And double click on cam.jpg to check whether the image is correct.Step four: configure and check the speaker
Right click on the Volume icon in the upper right corner and select "Analog".
Now left click on the same volume icon and set volume. I suggest setting it to about 80%.
Next, let's open up a console again, and run the following command:
You should hear white noise.
If you want to hear a proper sound, type the following command:
Now you should hear a human voice.Step five: configure the microphone
Right click on the volume icon again, and then click on "USB Device Settings".
Then click on the "Sound card" drop down menu, and select "USB PnP sound device".
Click on "Select Controls...", and select both "Microphone" and "Auto Gain Control, then click on "Close".
Now set the microphone slider to about 80% as well and click ok. You might find the microphone is quite bad and creates quite a bit of white noise. You can always come back to this setting and reduce the slider, but then you will have a harder time to hear sounds from the doorbell.
At this point our raspberry pi is properly built and configured, so it's time to to take care of software.Step six: download the Seajei SDK and run the Raspberry Pi sample
Open up the raspberry pi browser, and type seajei.com.
Scroll down a bit and click on "Free SDK".
In the next page scroll down a bit and click on "Download SDK". It will get downloaded to your Downloads folder.
Open up File Manager, and go to your Downloads folder.
Right click on the Seajei SDK zip file, then click on extract here. Then move the Seajei SDK folder to the desktop.
Next, open a Console, and navigate to the doorbell demo with the following command (adjust of you have a different SDK version):
Look at what's in README by typing:
Then as mentioned in there run the sudo apt update command, and copy paste the other sudo apt command and run it. You can run the whole thing in one line like so:
sudo apt update; sudo apt install libopus-dev libssl-dev portaudio19-dev
When that's all done, run the build script for your Pi 3, which is the following command:
And then run the doorbell executable by typing:
Take note of the device ID, because you will need it to connect from the iOS app. In my case it's "vmy9dj".
This is a good time to check the pi button is working. Click a few times on it and check that you get the "Button triggered" message.Step seven: run the iOS sample
Now let's get the iOS app going. I assume you already have XCode and a developer account with Apple.
Unzip it and go to SamplePrograms/iOS/SeajeiDemoApp. Double click on the SeajeiDemoApp.xcodeproj project file so it opens in XCode.
You'll have to set your team in signing & capabilities to be able to compile.
Then select your target. It can be the simulator or an iOS device. Compile and run the app.
Once the app first runs, you need to set that device ID we saw in the Raspberry Pi sample program. For me it was "vmy9dj". Put whatever it was for you.
Then click on "CONNECT" and it should work. The video can look a bit funky on the simulator, so best is to run the app on an actual device.
Unfortunately at this point if you push on the Pi button, you won't see a notification. That's because notifications require your app to be set up for it in iTunes Connect.
So to fix that let's get to the next step!Step eight: get iOS push notifications to work
Quick note: for notifications to work, you'll need an iOS device. They won't work if you run the demo app in the simulator.
Go back to the Seajei SDK, and open up the SeajeiDeveloperGuideIOS.pdf file. In there, go to push notifications at the bottom.
Follow all the steps so that at the end you have a.p12 file. Send it to firstname.lastname@example.org, and they will get back to you with a token to use. For me it took less than a day.
Once you received the new token, which is just a string, go back to your Raspberry Pi, open up a Console, and go to the Doorbell sample program:
Edit doorbell.c with your favorite editor. A nice and simple one to use is geany. Just type:
Then scroll down a bit to company token, and replace the free trial token with your new one.
Save and exit, and run the build_pi_3_4.sh script again. Then run the doorbell program again.
Next, go back to your iOS demo app to replace the token there too. It is located in the PhoneAppViewController.m file. Scroll down just a bit to find it.
Re-compile and launch the app.
Put in the device ID again. If it's already there, it seems like you need to still click on it and then close the dialog where you set it or otherwise it might not work.
Now push the Pi button and you should see the notification.
Now you could call it a day, but wouldn't it be nice if the doorbell works automatically anytime it powers up? Here is one last step for that!Step nine: make the doorbell sample on Raspberry Pi start automatically when powering up
Go back to your Raspberry Pi, and to the doorbell sample:
And again look inside README with the cat README command.
There you see at the end 4 commands to run to make things work. So just copy paste and run them all. Or just run this single long command:
cp doorbell /home/pi/Desktop; sudo cp raspidoorbell.service /lib/systemd/system; sudo systemctl start raspidoorbell.service; sudo systemctl enable raspidoorbell.service
Run "sudo systemctl daemon-reload" if you are asked to.
And that's it! Reboot your Pi, and you should see the camera module's red light come on automatically, which indicates the doorbell program is running.
Now one small problem is that when the doorbell program starts automatically as a service and you want to edit doorbell.c and compile and run it, it will fail because it can only run one at a time. In that case you first need to stop the service by running this command:
Step ten: grab a drink!
sudo systemctl stop raspidoorbell.service
You deserve it!