Introduction: Polaroid Baby Monitor With RPi

About: Professional photographer (analog and digital), geek/early adopter, tinkerer and vegetable garden enthusiast.

When my girlfriend and I had our first baby in August, we were looking at solution for a baby monitor, but dang those things are expensive. On top of that most monitors could not give us the features we wanted.

Those features are:

- Sound

- Video

- Long range (we have a very large garden)

- No real receiver device to charge, take, ... (device independent)

- Ease of use

- 1 wire

We were talking about 350 euro for a baby monitor that could deliver this. So I decided to build my own using a raspberry pi, a webcam and a wifi stick.

Step 1: Bill of Materials

- Raspberry Pi B model 2 *- 39,95 euro

- 8GB class 10 micro SD Card *- 6 euro

- Edimax EW-7811UN Nano Wifi stick * - 10 euro

- 1 webcam with microphone - I used an old one I had laying around but you should be able to get a pi compatible one for 25 euro

- 1 case - I chose an old polaroid camera, I will soon post an instructable how to do that. But you can find good cases for about 5 euro

- 1 power supply of at least 1A - Almost every decent usb phone charger will work - 10 euro

So total cost: 81 euro

* Affliate links to amazon.fr

so let's start with the config.

Step 2: Install OS

As we are working with a raspberry pi, I propose to use raspbian.

There are plenty of tutorials on how to install Raspbian, I'll refer you to the Raspberry pi website for the base install.

Download either Raspbian or Noobs

If you downloaded noobs, install the latest raspbian as explained on the website, connect your wifi or network cable if you want to use that.

Now let's open up a terminal, by clicking on the black screen in the menubar.

*** If you are comfortable working with ssh, please do so.

We need to install a couple of things to have a fully working babymonitor. All commands are run as shown, if there is sudo (root access) need it will be in the command.

Make sure your install is completely up to date

sudo apt-get update
sudo apt-get upgrade

After that we are going to change the hostname of our server. for that we do

sudo raspi-config

Choose option:

9. Advanced options

A2 Hostname

read the warning, hit enter and you should see raspberry in a textfield. Change that to whatever you want, I changed it to babymonitor

After this we are going to install the programs needed.

*** Extra *** : If you want to use bonjour/zerconf, it's best to install avahi, so that it is easier to connect to your baby monitor remotely.

sudo apt-get install libnss-mdns

Step 3: Voice: Mumble, the Server Part

I have seen loads of solutions with several different protocols and they all had their problems, but one of the biggest problems were quite big delays on the transmission of audio.

After looking around I finally found another solution thanks to a certain Baka Chan

For the sound part of the baby monitor we are going to use Mumble, a voice chat protocol designed for gamers.

We first need to install the mumble server:

sudo apt-get install mumble-server

Now let's configure the mumble-server:

sudo dpkg-reconfigure mumble-server

You'll be asked a series of questions, answer as you see fit, just make sure you have autostart mumble-server on boot. So answer yes to "Autostart Mumble-server on boot?"

If you want some more settings to adjust, set them in the mumble-server.ini, the file is very well documented, so set whatever option you need with the following command

sudo nano /etc/mumble-server.ini

Now we are going to setup our remote client so we can test the setup but before that we need to know the ip-address of the server.

ifconfig

Look for the line with is similar to this one

inet addr:10.0.1.xx  Bcast:10.0.1.255  Mask:255.255.255.0

Write down the address behind "inet addr".

Step 4: Voice: Mumble, the Parent Side

We are going to setup the remote client so that we know that the server is working.

To download and install the client go to the Mumble wiki , they have a great explanation on that page as well as up to date download links for windows, mac os x and linux.

After you install mumble it's time to test if our server is working.

Go to Server -> Connect

If you are lucky, you see the hostname you chose in step 2 under lan servers. (see attached picture)

if not, you click add new in the lower left corner and fill in the fields like I did:

Label: Baby monitor (in my case, but you are free to choose whatever you want)
Address: 10.0.1.xx (use the ip-address you noted in step 3)
Port: 64738 (if you did not change it in the mumble server settings) 
Username: Papa (in my case, but you are free to choose whatever you want)

After you hit enter the server will be added under the header favourites, now just hit connect and you should see on the left side, connected followed by the standard welcome message or the one you've set in the config of the server.

This means everything is working, which is great. Let's move to the next step.

Step 5: Voice: Mumble, the Baby Unit

As far as I could find there were no decent working real mumble programs that work from the command line so we are going to setup the traditional mumble-client for raspbian. As the baby monitor will work without screen, keyboard or mouse in other words headless, we'll be setting up also a VNC-server, that way we can control the desktop from a distance also.

As I wanted to install the baby monitor in the room where it would be used before configuring the mumble client, I started by installing the vnc-server.

However as most VNC-servers setup their own desktop environment and don't use the one you would see on screen, we are going to install x11vnc, This program allows us to connect to display zero or the display which would be shown when we had a monitor connected to the raspberry pi. We also want it all to autostart when the server boots, so we are going to have it all start at boot.

So let's begin

sudo apt-get install x11vnc

setup x11vnc by starting it for the first time, it will ask you a couple of questions like do you want to set a password. I chose to do that, but it's up to you to do that.

Now try to connect from another computer to the raspberry pi over vnc (I use vnc-viewer on mac), use the ip-address from step 3.

(it is possible that when you connect, the client on your computer will complain about a non-standard protocol don't worry about it.)

Now we are going to setup the autostart for vnc. That way if we ever need to access the desktop we don't need to

create autostart entry for lxde

cd ~/.config
mkdir autostart
cd autostart
nano x11vnc.desktop

Paste the following in that file:

[Desktop Entry]

Encoding=UTF-8
Type=Application
Name=X11VNC
Comment=
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer
StartupNotify=false
Terminal=false
Hidden=false

Now hit CTRL+X, Y, Enter to save the file.

From now on you don't need to use a screen or keyboard anymore on the raspberry pi, we can do it all remotely.

Now install the mumble client on the raspberry pi.

sudo apt-get install mumble

if you go to the desktop now, you'll find in the start menu under internet the mumble client software. Open it follow the wizard to set it all up. (make sure you select the appropriate microphone setting)

When configuring the audio make sure to select the option "Voice activity" or continuous.

The first option only transmits when there is noise, you can choose at what level it should react. The second option transmits continuously, which for me is no option, because I'm using an old webcam microphone and when there is no sound the microphone tends to crackle.

To connect we are repeating the steps from the previous step:

Server -> connect -> add new

Label: Baby monitor (in my case, but you are free to choose whatever you want)
Address: 127.0.0.1 (or use localhost)
Port: 64738 (if you did not change it in the mumble server settings) 
Username: Baby

When you click connect, you should see that you are connected.

Now to make sure that mumble also starts and connects to the server we are going to do the following:

sudo nano ~/.config/lxsession/LXDE-pi/autostart

you should see something similar to the following:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@mumble mumble://Baby@localhost:64738
@xscreensaver -no-splash
@sh ${HOME}/.config/lxsession/LXDE-pi/autokey.sh

you should add the 3rd line at the exact location. If you chose another username for the baby station, change the part for between //yourusername@

Now we should be finished with the voice part. To be sure let's test everything by rebooting.

sudo reboot now

Once the pi has restarted, you should be able to connect to your mumble server and when there is sound, it should be automatically transmitted by the baby unit.

Make sure to fine-tune the audio settings, that they are not too sensitive or too strict. It took me a couple of nights when the baby was sleeping to find the sweet spot, mainly because of a lousy microphone.

You have a working baby-monitor.

The hard part is over, we just need to setup the video, which is very easy.

Step 6: Video: the Baby Unit

This step is rather short, we are going to use motion, it should work out of the box and the only thing we have to change after the install is making sure the webserver is running.

We start by installing motion on the raspberry pi.

(if you are using the cam module of the raspberry pi follow this guide: Motion-mmal )

sudo apt-get install motion

Now let's configure it. To configure motion we have to adjust settings in the config file, most settings will be perfectly ok for your camera.

sudo nano /etc/motion.conf

But feel free to play with them, the only ones that are really necessary to adapt are:

deamon On
ffmpeg_output_movies Off (if you don’t want to store pictures)
stream_localhost Off (in order to have access to your full network)

Press Ctrl-X, Y and Enter to save the file.

Let's start motion to see if it works:

sudo ./motion

Now you should be able to access the video from your browser (unless you are using chrome or internet explorer) with the following url: http://10.0.1.xx:8081 (replace 10.0.1.xx with your ip-adres from step 3)

For chrome and internet explorer there are work arounds, but that's beyond the scope of this already extensive tutorial.

If you see a video, everything is working as it should, hit CTRL+C to close the motion program.

there is only one step left in that case, make sure that motion starts on boot.

sudo nano /etc/default/motion

Change the line you see there to

start_motion_daemon=yes

Your baby monitor is now working and should be installed in the baby room.

Step 7: Extra's: Smartphone Setup, Internet Access

Smartphone

The goal of the whole project was to not lug around another device, until now we have only setup a computer as the receiver, but that kind of beats the goal of mobility.

There are some programs we can use on smartphones to achieve true mobility

Voice:

iOS: Mumblify or Mumble

Android: Mumble or Plumble

Video:

iOS: Camviewer

Android: Several programs use the one that suits you the best.

For settings use the ones you used in the previous steps

Voice: ip-address:64738

Video: ip-address:8081


Remote access

If you want to access the services from outside your local network, you have to forward the ports 64837 (voice) and 8081(video) on your router to the ip-address of the baby-monitor and either know your external ip-address or use an Dynamic DNS service like no-ip.com, dyndns.org or others.

Shutdown

Because the Raspberry Pi doesn't have a power button, you either attach one yourself, (I haven't done this yet, so you'll have to google it) or you go through ssh with the following command.

sudo shutdown -h now

This will power down the Raspberry Pi and once the activity leds have stop flickering you can remove the power. It's important you do it this way as otherwise you risk damaging the sd-card and thus rendering your baby-monitor useless.

To turn the baby monitor back on, just plug the power back in.

That's all folks!