Tuesday, January 15, 2013

Baby Monitor DIY (sorta)

When there's a new baby around, people seem to use the occasion as an outlet for their creativity. For example, our lovely neighbour hand-painted a beautiful lamb onto a wooden hanger for our baby. One of our friends knitted a sweater and a stuffed toy for her. My wife knitted a little cap and mittens. I tried to make a baby monitor.

What does it do?

Here's a screenshot of what it looks like.
In a nutshell, it lets me view a video feed of my baby's crib from anywhere. I can do it using a laptop from the living room, I can do it from my computer at work, and I can do it from my phone if I'm on the move. There are a few other handy features, like being able to tilt the camera, and viewing the temperature and humidity of the room. The nice thing about MJPEG is its almost universal support. It runs on Chrome and Firefox on my Ubuntu machines, as well as on Chrome on Android.

What does it not do?

It doesn't have a sensitive enough motion sensor to reliably tell if the baby is breathing (although the quality of the video is high enough that you can easily see that she is). It doesn't carry any audio (although that would be super-easy to hack on - I just didn't have a need for it).

What is it made with?

(It's a prototype and nothing more, so please don't cringe!)

This one is made with a PandaBoard ES-based ARM processor board. It's connected over (ugh) USB to a microcontroller that I use to read out the sensors and operate the servo motors. There's a standard Arduino UNO microcontroller there, a Passive Infrared (PIR) sensor, a DHT-11 Temperature/Humidity sensor, a Logitech webcam capable of 720p video, and a small servo to control camera tilt. The most expensive parts are the PandaBoard and the webcam (together ~300 CHF). Everything else together is under 50 CHF. You could just use whatever "small computer" you have lying around, so it doesn't need to be this expensive.

The second version that I'm working on is based on the Beaglebone. It'll cost a lot less to make, and I want to get rid of the ugliness of talking to the microcontroller through USB. I could have done this with the PandaBoard, but I didn't have the courage to solder headers to my PandaBoard.  Not a problem with the Beaglebone - it has headers mounted. I'm also going to make this version a lot smaller, and power it with a Li-Po battery. The only drawback of using a BeagleBone is that it doesn't come with built-in WiFi, which one can easily solve with a small dongle.

The software is quite simple. I used a patched version of the mjpeg-streamer tool, mod_python for the backend that the Javascript UI talks to, and a small python daemon that talks to the microcontroller, relaying commands back and forth, and logs timeseries data from the sensors. There's some C++ code on the microcontroller that reads and formats sensor data, and moves the servo motor. I've set up NAT+DynDNS on my router, which lets me use the service when I'm not at home. I use Apache's VirtualHost-level Basic Authentication support.

If you want to make something similar and have any questions for me, please let me know!