When I first <a href=”http://www.softwaresamurai.org/2017/10/10/raspberry-pi-video-doorbell/”>looked into adding a Video Doorbell</a> I was surprised by the lack of available choices ( thus far )

Our doorbell had to be slender which meant less than 2″ ( 50mm ) and could be 4.8″ tall ( 123mm ). None of the ones I saw met this criteria. I also required a little 5mm shim to handle the uneven surface.

Anyways long story short I decided to do a custom build of the chassis for the Doorbell.

Rough drawing of the chassis

Creating the Custom Video Doorbell:

To convert this image into a physical reality I had to use some tools and then see if all eventually fits in. To screw the top and the bottom together will be the very last step before painting, after I have places, screwed, soldered and glued all the pieces into their final place. This will allow me to adjust the height if needs be.

From the pictures below you can see that it is a tight fit with all the pieces in place. Unfortunately I can’t use the USB plugs. If I would connect them, then the PI Zero would no longer fit inside the box.

Since the PI Zero exposes the usb contacts on the bottom and I have to remove the USB plug from the soundcard anyways.

All pieces put tgether

This is the assembled Raspberry PI with camera, the New doorbell button, the sound card, loudspeaker, as well as the original wireless doorbell button.

Side View

The assembled pieces from the side

top and bottom part of the doorbell

Please note that the tape is just a temporary holder until I create all required holes, brakets etc.

The sound card fits in sidewards

After removing the USB plug and soldering on the wires, The sound card does now fit sidewards into the chassis.

Wireless Doorbell button

Before cutting out the back to place the current wireless Doorbell Button into its socket.

Wireless Button integrated into back of Doorbell

All fits snug into their place.

Power

As power source we do have 24V AC coming out of the doorframe, which require a small power converter. Using the standard 7805 regulator brings this down to a few small pieces. Alternatively I can find the source fo the wiring and feed it directly with 5V DC to the door.

7805 voltage regulator schematic

Things are starting to come together. I still have to connect the loudspeaker, the microphone, and make sure that the original doorbell button gets some protection before connecting it up and closing the case.

Step 1: Signaling: both peers connect to a signaling server (using websockets over 80/443, comet, SIP,etc..) and exchange information (about their media capabilities, public IP:port pairs when they become available, etc.)

Step 2: Discovery: Devices connected to LAN or mobile networks are not aware of their public IP (and port) where they can be reached at so they use STUN servers located on the public Internet to discover their ip:port pair (ICE candidates). In the process they punch a hole through the NAT/router which is used in step3:

Step 3:P2P connection: once the ICE candidates are exchanged through the initial signaling channel each peer is aware of each other’s ip:port (and holes have been punched in NATs/routers) so a peer to peer UDP connection can be established.

Step 4: If a P2P connection can’t be established ( maybe through firewall rules or the usage of Symmetric NAT ) then TURN servers can be used, which will relay the data between the peers. Please note that this will require the TURN server to receive and send all video and audio and is the last resort in WebRTC.

Under normal circumstances you would establish the connection between two web-browser. However in this case I need to establish Android WebRTC streaming to the Raspberry PI Zero W. Fortunately we have the required tools and libraries available on both platforms and can take full advantage of this technology stack. This allows us to basically build a video conference similar to skype between the Raspberry PI and Android. As an aside, iOS can also handle WebRTC, which may be a project for later.

I have spent the past two days working with the uv4l driver to get WebRTC working. I eventually got everything to work with three major issues

I could not get the transmitted quality to anything close to what I needed

I could not get rid of the the watermark which was put over the video

The complete CPU utilization for 640×480 was above 90% and caused issues.

Another slightly annoying issue was that I had to re-install Jessie after I found out that uv4l is currently not available for Raspbian stretch lite. I could only find the full version for Jessie, which requires at least a 8GB microSD card. And off I went to replace my 4GB microSD card.

On the positive side I installed rpi-webrtc-streamer from github and was able to look at the results in realtime right away.

I bought the following external usb sound card from Amazon for $7,- to integrate into my Video Doorbell project.

External USB sound card

So why did I chose to go this route. Simple, I was looking at some audio pHATs for the Raspberry PI and found that they will cost about $4,- a pop, then of course you also need a microphone, and bang you are at around $9,- to $10,-. So paying $7,- for a audio I/O ( 7.1 sound card ) is a smart choice. Another thing I saw which won me over was that the setup is quit simple.

In order to do the setup I connected a micro-USB male to USB female adapter to my PI zero and made two small changes.
Please note though that I do intend to remove the USB plug all together and solder things together in the final setup.

1: Find the US sound card number ( in my case the USB card is card # 1 )

This concluded the setup and testing. To use this external USB sound card in my project it had to fit tightly into the chassis which I built from scratch. So the USB plug had to come off and I had to solder some wires onto the card to connect t up to the Raspberry PI.

So one of the thing which I tried out was to see if the PI Zero can handle video streaming to our TV.

In order to setup the Raspberry PI Zero W as Chromecast, I followed the series of 7 videos below and plugged it into our large TV. However the result was unusable. The video did only play for a second or two before the whole thing stopped and tried to continue playing.

This is not too surprising considering that the PI Zero has only a single core 1GHz CPU while the instructions assume the PI 2 or 3 which has a quad core CPU to handle the stress.

Step 1 : Raspbian Jessie Lite Install Guide

Step 2: Raspbian Jessie Lite wifi config

Step 3 : Raspbian update upgrade omxplayer

Step 4 : Install youtube download video and python

Step 5 : Raspbian Jessie Lite Golang

Step 6 : Raspberry pi as Youtube TV

Please feel free to sign up or follow my home made hardware projects here …

So I have not written anything about AstraNOS, my web desktop, for a while. That was for a good reason, as I was busy doing a batch of other things the past months.

However I have never give up on it and I am still using it heavily all the time to store pics, ideas, notes, videos and other things.

Progress

I recently fixed my AWS instance and re-enabled Conference, my WebRTC based video conferencing tool. Also since I always have a multitude of windows open I added a virtual desktop feature to the mix.

The number of virtual desktops is currently hardcoded to 4 however I believe that this will be plenty. The current version of AstraNOS is now grown up enough to handle a lot of the everyday tasks. It provides a central place online to -feel-at-home.

Feel free to sign up for a free account <a href=”https://www.AstraNOS.org/virtual”>Here</a>, connect your DropBox account and link some youtube videos to your folders.

For $5,- I could simply not resist. Not only is this a full blown computer with micro-hdmi out, it also can be used to connect other hardware to it with ease. The connector on the right is there to connect a camera to the PI Zero.
Well, after installing raspbian onto a micro-SD card, I went ahead and bought a camera as open-box item for only $12,- and got the combo to work in no time flat.

That is all well and good but what can you truly do with this hardware ? The answer for me is/was

Home Automation.

I have looked into

Ring Video Doorbell

However my issue was not so much the price of these devices, after all it takes a lot of effort and money to develop a great product, it was the physical shape and size which made any of the available products unusabe for me.

So I thought I would simply add a few pieces together and create my own Video Doorbell from scratch using the PI and a few other software and hardware parts, which can be found online.

It is of course very helpful, that there is such a huge community behind the PI and that almost everything you can come up with has been attempted before. So googling around I found a bunch of sites with similar goals, like this one here.

I chose DyGraphs a long time ago mainly due to its small footprint of 123530 bytes for dygraph.2.0.0.min.js

One of the things it allows you to do now is to add a different plotter algorithm to plot data. One such example can be found on the demo page is that of a BarChart plotter. If you look at the code it is a fairly small addition.

One of the possible plots missing though is a PieChart. It happened that I needed a PieChart for my project and I did not want to switch to E.g. ChartJS [ Release 2.5.0 ] so I wrote my own little PieChart function for DyGraphs.

The one thing you will see in this code is that I calculate the required PieChart data once and then check for its existance each time I enter this function. This is requried beause DyGraph does currently not call the plotter function in a context but rather in the global browser context ( I.e. the this object is the browser Window ).

So instead I ‘added’ ( read hacked ) myCtx to the dygraphs – plotter options to gain access to my local JavaScript object where I buffer the _pieData.

DyGraphs Pie Chart plotter

While this may not be the nicest pie chart around, it is a small, basic function which can be expanded on fairly easily.