Intro

About project

Fruitnanny is a code name for a DIY geek baby monitor. It uses RaspberryPi, a NoIR camera module, infrared lights, temperature and humidity sensors, and a custom Web UI.
Chrome and Firefox with native WebRTC are used as clients. Right now it means all major platforms like Windows, Linux, Android, MacOS, and iOS soon are supported.

Disclaimer

I assume that a reader worked with RaspberryPI system before and understand Linux systems.
Feel free to contact me using Disqus or my email iva9im@gmail.com.

History

When my son was born in March 2016 I got a holly mission to find a video baby monitor. After some research, I didn’t find good candidates(too expensive or didn’t have some features) and,
being a geek person, decided to build my own device. That time I had RaspberryPi v1 Model B which had been used for media center.
My wife wasn’t happy with the idea but she didn’t have a choice.

At the beginning I thought it would be an easy task, probably someone already had built something similar. Google found dozens of projects but none of them had real-time audio and video capabilities which I wanted to have in my project.
Some projects were trying to use VLC streaming, MJpeg or others technics. I was trying to use all of them but wasn’t satisfied.
Then I stumbled upon UV4L project and it was promising, especially WeRTC part. I chose this project as a main software part of the project.

Another big part of the project was an additional hardware. Connect a camera to Raspberry is not a big deal, but because baby monitor works mostly during the night, it must have some infrared lights to allow night vision. Plus, it’s good to have sensors data like temperature and humidity.
I didn’t design electronics from the college and I had to refresh a knowledge.

Due to all of these initial problems I managed to build Alpha version only after two months. I called it “lunch box” version:

This version worked good but had several problems:

Audio quality was horrible. There was a loud noise(like a helicopter)and it was almost impossible to hear a baby’s cry.

Power problems. After 20-30 minutes system rebooted itself.

Ugly “lunch box” case :)

UV4L is distributed only through binaries what prevented any modifications. The biggest concern for me was a fact that I couldn’t modify a WebUI.

Some of the issues were related to low CPU power and some circuits problems in RaspberryPi v1. I didn’t find other way but upgrade to RaspberryPi v3.
It’s much more powerful and suites better for video and audio processing and as a bonus contains built-in wifi.

I couldn’t spend a lot of time on the project next several months because of the baby.
Progress was very slow but at the end, project was finished and contained completely changed architecture, a new WebUI and, as a bonus, a new case.

Build guide

Hardware

The final version of my device contains next parts. Some parts are mandatory(like RaspberryPi) and some are optional (infrared lights, DHT sensor, case). Parts can be bought in different places. I used AliExpress and Amazon.
It’s possible to replace some parts with different compatible models (like Camera module, microphone, and all electronics).

Several words about the transistor. RaspberryPi’s gpio pin output is maxed 16mA and 3.3V. So transistor must be able to switch state based on that pretty small amperage.
After a small research I found Darlington type of transistors and bought TIP 120. It was designed for higher loads(up to 5A and 60V through Collector-Emitter) but it suits needs of this device as well.

Example of soldering:

Camera and Mic connections

Connect a microphone to any USB ports and a camera module to CSI port.

Software

When everything is assembled it’s time to breathe a life into the device.

NodeJS - is a server-side javascript environment. It’s used for 2 main purposes - 1. serve html and other content to browser, 2. run scripts on the server side.

Nginx - is a proxy to Nodejs and Janus allowing to use single URL access.

GStreamer is a library to create media pipelines. It forwards a H264 encoded video stream from camera module without modifications to browser. An audio stream is encoded using Opus codec before forwarding.

Sensors and LEDs access

Enable access to GPIO without root.

sudo adduser $USER gpio

LEDs

The application need to have ability to turn on and off infrared LEDs from browser.
I added a simple shell script to the Fruitnanny which can blink with infrared light. The same file is used by NodeJS Web app.

After module installation Python can get data from the DHT22 sensor. As for LEDs, Fruitnanny contains a python script which prints out current temperature and humidity.
The same script is run by the NodeJS Web app.

Autostart Audio, Video, NodeJS and Janus

Now we are one step closer to the final step. Main applications were installed and configured and it’s time to start them.

Nginx

To be able to serve janus and nodejs request from one entry point URL(http://RASPBERRY_IP/) I set a Nginx proxy to forward requests to the NodeJS(http://127.0.0.1:7000) app and to the Janus(https://127.0.0.1:8089) gateway.

Now accessing http://RASPBERRY_IP/ you will be asked to enter credentials and after can see a web page with Video Player.

Case

I used SketchUp to create 3D models. It was my first experiment with 3D printing and I would fail if not help from my friend Christos. The first model I created was not designed properly and slicer(special software to transform a basic 3d model into a 3d printer language) couldn’t even read it. The second model collapsed on the printing bed and only third attempt was successful…

I love how the case looks like but next time I would make it bigger and increase size and number of ventilation holes. Currently, all electronics and wires are tightly coupled and it causes problem with heat, the case needs more airflow.

Bottom line

The guide turned out into a huge instruction but I hope it will help someone who has a similar idea of building a baby monitor. Feel free to adjust the project to your needs, you can add or remove some sensors, add or remove some functionality, create a completely different case. All my sources are opensources

On my own, I had more ideas but didn’t have time resolve all of them. Some of them:

iOS application.

Motion detection and notifications - motion application for Raspberry can detect movements using a camera, the only problem that video stream must be splittet between Janus and Motion. I almost accomplished this with GStreamer, ffmpeg and v4l2loopback. Ping me if you are interested in my findings.