Stuff Babies Need

Building a Raspberry Pi Baby Monitor – Part one

As an expectant Dad, I was searching for helpful things to do in preparation for the arrival of our little one. Once I had all the essential items ready, hospital bag packed and nursery painted I set about a little hobby project. I bought a Raspberry Pi when they first came out – a tiny, cheap low power computer. Until this point, I had been searching for a use – the baby monitor seemed like a perfect fit. Today I will walk through how to create a simple Raspberry Pi baby monitor with motion detection, temperature and a simple web browser interface so you can watch your little one on your Laptop or phone.

What you will need for the Raspberry Pi Baby Monitor

1 Laptop (to prepare the Raspberry Pi)
1 Raspberry Pi
1 Raspbery Pi Case
1 SD Card (at least 2gb, ideally 8gb or more, microSD for the newer Pi’s)
1 USB charger and micro usb cable
1 USB Webcam
1 Ethernet cable
2 Ethernet Powerline Adapters

If you’re not sure – I’d recommend getting a Raspberry Pi starter kit. The new PI comes with wifi, so no need for the ethernet powerline adapters, unless your wifi signle is unreliable, like mine!

Finally, the Raspberry Pi can be a little picky about webcams – I’ve used the Microsoft LifeCam HD-3000 (Retail Packaging) and it seems to work OK.

Step 1 – prepare the Raspberry Pi

Firstly, you will need to install the base Operating System onto the SD card for your Raspberry Pi. Head to the Downloads page of the official Raspberry Pi site and download the latest Raspbain SD card image onto your laptop. Follow the installation instructions on the official site.
In summary

  • on Windows, download the free Win32DiskImager and point it at your SD card.
  • on a Mac or Linux, use the dd command (e.g. sudo dd bs=1m if=path_of_your_image.img of=/dev/diskn where /dev/diskn is your SD card)

Warning – writing the OS to the SD card will replace all existing files on the card, so make sure you have backed up anything important!

If you can’t get your head around that – just buy a preprepared disk image.

Once the SD card is prepared, you are ready for step 2!

Step 2 – Install motion

I find it easiest to connect to the Raspberry Pi via SSH to run commands. On Windows – get Putty. On Mac OS / Linux, you probably already have SSH.

Put your shiny new Raspbian SD card into your Raspberry Pi. Plug in the Ethernet adapter and connect it up to the Raspberry Pi.

We’re now ready to boot! Plug in the USB charger and connect the Pi up via its micro-USB port. Once it powers on, you’ll see a few LED’s blinking – but that’s it – there’s no noisy fans or disks here! This is one of the reasons it makes a good baby monitor!

Now to connect to the Pi. You’ll need to find out the IP address it has been assigned – this is probably easiest done via your router. By default it will request an IP address via DHCP, so check your routers connected devices to see if the Raspberry Pi has turned up. For this walk through, let’s assume our IP address is 192.168.0.5

The OS ships with a default username / password. So to connect via SSH:

ssh pi@192.168.0.5

You will be prompted for a password – the default is password is raspberry

You will then see a standard console bash prompt. First things, let’s update the OS and make sure we are running the latest packages.

sudo apt-get update

and then

sudo apt-get upgrade

For both commands, follow the prompts and press Yes (y) when requested.

This will download and install the latest updates from the Raspbian distribution, ensuring that any improvements, fixes and security patches issued since the disk image was created are running. The Raspberry Pi isn’t the fastest little computer in the world, so it might take a little while to churn through all the updates – go make some tea!

The heart of our baby monitor is a package called motion – this is the software which will monitor the webcam for us.

sudo apt-get install motion

Confirm the install with

yes (y)

when prompted and again the Raspberry Pi will download and install a bunch of software.

Note – you will probably see a final warning ([warn] Not starting motion daemon, disabled via /etc/default/motion … (warning).) – don’t worry, we will sort this out next by configuring motion.

Step 3 – Configure motion

Now we need to set about configuring motion to our requirements. Have a look at the configuration guide to see what’s possible – I’ll cover the basics to get a basic monitor set up.

Motions configuration is controlled by a simple text file which you can find at

/etc/motion/motion.conf

To edit we use the command

sudo nano /etc/motion/motion.conf

The config file is big – we want to set the following items:

daemon on
framerate 2 
width 640
heigh 480
ffmpeg_video_codec mpeg4 
webcam_localhost off 

We want it to run in daemon mode so that it starts automatically once the Raspberry Pi boots. The Raspberry Pi isn’t terribly powerful, so let’s set the framerate to a lowish value to keep it stable. We want to be able to see the webcam from other devices on our local network (e.g. Laptops, phones) so make sure the localhost setting is off.

Once these are set, save the file and exit:

ctrl-x

followed by

y

One last bit of config is needed to allow the daemon to start:

sudo nano /etc/default/motion

and then change the “start_motion_daemon” line from no to yes

start_motion_daemon=yes

Save and exit as before. Now we are ready to start the motion daemon!

sudo service motion start

Step 3 – Check its working!

You should now be able to browse to your Raspberry Pi baby monitor from a laptop or phone connected to your local network.

http://192.168.0.5:8081

Note – remember to swap the IP address for the assigned to your Raspberry PI!

I’ve had the best results from using FireFox – see what you find and let me know in the comments. With our simple setup, we have two brilliant features:

  • Each time the camera detects motion, an image and video is saved into the /tmp/motion folder
  • You can see a live stream of the camera at http://192.168.0.5:8081

Phew!

In part 2 of this series, we’ll look at some cool things to do next with the Pi – setting up a Raspberry Pi Temperature Logger.

 

If anyone else has any brilliant ideas, let me know in the comments!

Tiny disclaimer – Whilst I had fun with this project, I wouldn’t suggest relying on it as your only baby monitor! Check out our review of a more reliable baby monitor if you are looking for ideas!

 

51 comments for “Building a Raspberry Pi Baby Monitor – Part one

  1. June 21, 2015 at 11:16 pm

    How About mat that tracks movement or breathing alarm?

  2. EK
    November 13, 2015 at 6:31 pm

    Not a big deal, but you have 2 o’s here:

    Motions configuration is controlled by a simple text file which you can find at

    /etc/motion/mootion.conf
    To edit we use the command

    • November 13, 2015 at 6:34 pm

      Ah, thanks, I’ll update it later!

  3. danny
    January 24, 2016 at 4:39 pm

    where is the part 2?? I really like into your project

  4. Celery Man
    January 27, 2016 at 6:29 pm

    Does it support audio playback?

  5. Jake
    February 5, 2016 at 2:18 am

    Hello,

    I would like to know if I can add a vibrate alert for baby monitor?

  6. February 18, 2016 at 11:20 pm

    This is lovely and a great summary. It’s so versatile a setup and you can use it in so many places.

    Motion has so many options, I don’t think I’ve discovered a fraction of what it can do.

    For a bit more expense, but less intrusive, we used the Pi NoIR camera and an infra-red source. It was amazing getting a high quality image. Night vision! Using Video for Linux, we were able to stream the video in the same way. At the other end, we have another Raspberry Pi running Kodi. We added the stream as a video link so we could watch the baby on the TV. We also appreciated the fact that it was possible to view on our phones – we used a webcam monitoring app.

    I put a few bits on my blog. Motion doing timelapse and also detecting mice!

    https://rpikitchen.wordpress.com/category/photography/

  7. February 19, 2016 at 6:29 pm

    Why did you use a USB webcam rather than the Pi camera?

    • February 19, 2016 at 8:49 pm

      I had the USB webcam already so I wanted to see if that would work. I think the Pi camera would probably give better results. I’ve got an original Pi, and the USB webcam can be a little flaky – had to play about with the resolution of the images to get it stable.

  8. Jerome
    February 20, 2016 at 12:45 am

    Interesting article. I would suggest you look at the MotionPie project. All of the same functionality, but with a web GUI. I have 3 Raspi at home with MotionPie, works pretty well.

  9. February 22, 2016 at 10:22 pm

    So I have been following your guide and I have noticed a few things.
    I cant seem to find “webcam_localhost”. The closest I can find is “stream_localhost” or “webcontrol_localhost” both of which are off. I can’t seem to connect to the “control” port, I can however access the “stream” port (8080 / 8081 or which ever way round it is :P). Neither of the IP’s work on my desktop PC.

    Also with running local host I get an image but it only seems to last about 10 seconds then comes up with “unable to load page”. I only have an 8GB SD card. Is it running out of memory and shutting down? I have turned off all the “capture and save” settings in the config.

    Any help would be greatly appreciated.

  10. February 22, 2016 at 10:45 pm

    Ok scratch all of that I have it working after reinstalling motion and changing only the “_localhost” to off. Works great.

    • February 23, 2016 at 5:53 am

      Cool, good to hear it works!

    • Vino
      March 25, 2016 at 8:45 pm

      I’m running into the same issue. I couldn’t find the webcam_localhost. Did you add a new entry for _localhost? I tried adding that to the end but no luck “_localhost off”.

    • JJoyce
      May 26, 2016 at 6:25 am

      when you changed to _localhost off which is that? I dont see a setting that is just named that. Any help would be appreciated!

      • May 26, 2016 at 7:05 am

        I think it’s called webcam_localhost

        Have a look here http://www.lavrsen.dk/foswiki/bin/view/Motion/ConfigOptionWebcamLocalhost

        • Jjoyce
          May 29, 2016 at 1:34 am

          Thanks I got it to work – simply rebooted and checked the settings. Now running into another issue where the screen shows as gray and says “unable to open video device”. I changed the port to 8082 and still the same error.

          Scoured the web and tried everything but still no dice, any idea? Thanks!

          • May 29, 2016 at 3:46 am

            What camera are you using? Maybe try a lower resolution image, or a different Pete supply, assuming the camera is supported.

          • Jjoyce
            May 29, 2016 at 4:01 am

            Rasberry Pi camera v2

          • May 29, 2016 at 4:03 am

            Ah, not sure as I’ve not used one, sorry.

  11. June 23, 2016 at 8:25 pm

    Good boy Raspberry, the device of Chuck norris.

  12. Timo Paschke
    June 29, 2016 at 9:39 pm

    Great start! Do you have any ideas for adding audio to the video stream?

  13. July 7, 2016 at 2:39 am

    I found your blog right now while surfing through the internet. It’s matter of joy that for me. I like the tips you shared through your blog. Though I have tried different ones. But I think yours is better.

    Thank you!!!

  14. August 31, 2016 at 5:53 am

    Great summary and great baby monitor. I’ve been looking into a lot of baby monitors lately and so far your article has me hooked. I really like the idea of building a raspberry pi baby monitor.

  15. September 7, 2016 at 10:34 pm

    Thanks for the great cover-up! It was really helpful!

  16. NoWhereNerd977
    September 12, 2016 at 3:51 am

    Hey, just a quick question. I am new to programming and using the Raspberry Pi, I was wondering would this work with the Raspberry PI 3?

    • September 12, 2016 at 7:27 am

      Yeah, it should do, probably even better! I’ve got a pi3 now too, and it’s basically the same, Just much faster and more responsive as a desktop.

  17. September 27, 2016 at 9:22 am

    That’s a lovely article, and indeed it’s very easy to build. However, this is not really a baby monitor, but a security camera. A baby monitor does/should include the receiver too, and in this case, opening a browser or your phone is hardly practical. You need something that is always-on and gives you real-time feedback about sounds and movements, otherwise it’s pretty useless…

    Any thoughts? It’s that last part – an always-on receiver – that has stopped me in my tracks – the transmitter is the easy part 🙁

    • September 30, 2016 at 9:48 pm

      Well, I suppose you are right. A cheap android tablet would work as a reciever, and would probably still come in at less than the cost of a wifi baby monitor. If you had a tablet, you could leave it always on, and mount it on a wall?

      • October 1, 2016 at 7:20 am

        That could be a solution, yes, but not a mobile one. Cue turning the house into a 1984 space with screens everywhere 😀

        • October 1, 2016 at 12:22 pm

          I wonder if there are any of those fitbit / activity trackers that have a decent API, then you could bluetooth an alert to your wrist when it detects movement. That would be cool.

          • October 1, 2016 at 3:28 pm

            That’s some seriously out-of-the-box thinking there!

            Granted, my baby hasn’t arrived yet so I wouldn’t know the first thing about movements, but I suspect it’d take a hell of a lot of trials to get the alert thresholds right… 🙂

          • October 5, 2016 at 9:59 pm

            Ah, good luck with the new arrival when it comes!

          • October 6, 2016 at 7:59 am

            Thanks mate 🙂

  18. March 24, 2017 at 2:09 pm

    Thanks for the great cover-up! It was really helpful!

Leave a Reply

%d bloggers like this: