element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs RaspBaby Monitor
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: dammitmcgee
  • Date Created: 26 Sep 2016 10:14 PM Date Created
  • Views 1456 views
  • Likes 2 likes
  • Comments 5 comments
Related
Recommended

RaspBaby Monitor

dammitmcgee
dammitmcgee
26 Sep 2016

After binge-watching the Ben Heck Show, and hearing about this community constantly, I also stumbled on this blog entry by aaroNiGHTS, and decided that with a baby due in the next few months, it seemed like the stars had aligned, and now was a perfect time to stay up much too late working on a brand new project.

 

My only real experience with Linux up to this point has been with the Raspberry Pi 2. I've built a RetroPi for playing old video games in my living room TV, and that was terribly fun, and pretty doable for a newbie who's computer literate but not familiar with Linux. So far, getting these projects to work has felt a whole lot like playing .Conf Hunter. Using the Pi for projects that others have already undertaken is a good way to start, as far as I'm concerned, because the community is so strong, and people have run into, solved, and documented many of the issues you'll run into. I'm not writing this blog as an expert, but as a beginner+1 with the hopes that the information / links I collected will be helpful to others. Also, I just wanna show my work.

 

The Project

I built a baby monitor that streams video and audio to local browsers, and can see in the dark. It doesn't look creepy at all, see?

 

image

 

image

 

 

Hardware Ingredients

Raspberry Pi 2

Pi 2 Case

Pi Camera NoIR Ver. 2

Cheapo Labtec clip-on mic

USB sound card

USB WiFi dongle

Camera Stand (with grabby legs)

 

Software Ingredients

UV4L

Raspbian Jessie

 

 

image

 

 

 

I'm assuming you've got Raspbian installed on your Pi. If you need help with your OS, I'll need to send you hunting on the internet, as I'm not any of guru, let alone one that knows multiple flavors of Linux. I'm using Raspbian Jessie.

 

I was only able to get as far as I have with this project by breaking it down into small manageable chunks. If I had just plugged all the stuff in that I thought I needed, then turned the thing on, I would never have able to figure out which particular thing was misbehaving when it inevitably didn't work. Even so, it took a while to really iron the streaming out, and it was helpful to have gone through the components one by one beforehand so I had a feeling for each of them.

 

 

Camera Setup

imageimage

So with that in mind, let's set up the camera first. Do it only when the Pi is off, and be gentle when doing so, as this type of connector can break when mishandled. I used double-sided foam tape to fasten the camera to the Pi case (for now).

 

Rather than me try and reinvent the wheel, follow this guide to make sure your Raspberry Pi is up to date. Then, follow this other guide to get yourself acquainted with the PiCam via Python. This group of pages will also be handy if you want to use commands instead of Python. I found it very easy to get the camera working. Once I knew it was working, I moved on to the microphone situation.

 

Sound Setup

 

image

I plugged in my USB Sound Card, which was a cheapo from Amazon, and tested the sound playback by plugging in speakers to it, to make sure it was operating. Then I used the command

 

$ arecord -l

 

(which is a lowercase L) to list all of the available sound devices. This info will come in handy.

 

I then plugged my little Labtec mic into the mic input on the usb sound card, and ran

 

$ alsamixer

 

which allowed me to set the levels and such for the device. I found this pretty easy to use, as the handful of commands were listed on the screen.

 

Without much trouble, my Pi (with speaker plugged in) was able to hear and play the mic's input.

 

Streaming Software Setup

Now that I've got sound and video inputs on my Pi, I'm using a terrific package called uv4l for Linux that allows you to stream video and audio from (in this case) your Raspberry Pi's camera and mic.

 

Here are the instructions I used for getting uv4l running with the required extras. I would recommend you follow those. If you followed the earlier posts as well, you've probably done your apt-get update . I installed:

 

uv4l

uv4l-raspicam

uv4l-raspicam-extras

uv4l-server

uv4l-uvc

uv4l-xscreen

uv4l-mjpgegstream

uv4l-dummy

uv4l-webrtc

uv4l-xmpp-bridge

 

These are all explained some on the uv4l installation page linked above, and also have their own information floating out there as well. I probably did not need all of these, but I wasn't quite sure what did what, and I didn't figure it would hurt to grab them.

 

Next I needed to set the .conf file for uv4l, with this command:

 

$ sudo nano /etc/uv4l/uv4l-raspicam.conf

 

I recommend you take some time to look at this file, and look up the various options in the Raspicam Documentation to see what they're all for. Once I got this far, I figured I ready to go. I fired up uv4l just by typing:

 

$ uv4l

 

then I found my local internal network IP address by using the command:

 

$ ifconfig

 

and finally I opened a browser on another computer in my home network and connected to the Pi's address via port 8080 (which looks like 11.23.0.9:8080 - your Pi's address will be different). I was greeted with a nice landing page offering several different ways to connect and stream.

 

For my purposes, I found that the Multi p2p conference option was the easiest to get working. Be aware that the multi p2p conference starts up MUTED, and when viewing it you need to un-mute to hear the microphone's sound. A lot of time was spent troubleshooting before I discovered this!

 

It seems that simply running $ uv4l was not grabbing the .conf file I had tweaked. I was able to view my stream, but not at the resolution I had specified, and some of the other options weren't quite right. Instead, I added an argument to force it to grab my config file:

 

$ uv4l --config-file /etc/uv4l/uv4l-raspicam.con

 

More Sound Settings

Despite discovering the sneaky mute button, I still wasn't getting the microphone's signal on the stream, even though the mic was working locally on the Pi itself. I tried lots of different things, and ultimately found how to make sure the mic input on my USBsound card was the default device.  Here is a StackExchange post that helped me troubleshoot why my device wasn't using the microphone when streaming. This answer in particular did the trick for me.

 

Since I'm using Raspbian Jessie, I used this command to add the default audio settings (to what had been in my case a blank configuration file):

 

$ sudo nano /etc/asound.conf

 

and I added this, from the StackExchange post I linked to above:

 

pcm.!default {
  type hw
  card 0
}

ctl.!default {
  type hw 
  card 0
}

 

Make sure to change the card number to match what you discovered when you ran arecord -l or aplay-l .

Finally, I was able to stream audio and video pretty clearly from any browser and device on my local network. I haven't set up any way to do this from outside my network because I don't want weirdos staring at my baby.

 

Illumination Circuit

 

The Pi NoIR offers 8 megapixels, and is sensitive to Infrared light, so it's great for a night-time camera. It plugs right into the Pi's camera input, and works out of the box. You need an IR light source in order to illuminate things in the dark, so for starters, I built a sloppy battery-powered circuit that I purposely don't have a picture of. It was based on this article, which helped me design my circuit, diagrammed below.

 

 

image

(I've updated this schematic to correct several silly errors)

 

NOTE: I want to caution you against taking my electronics schematic as advice, because I am very much a beginner with designing circuits. I used to build project kits in high school, but that's as much as I know. Instead, click on some of the links I'm sharing and go learn from all the smart people image

 

I have two resistors in parallel, because I needed around 62 Ohms of resistance and the RadioShack package of resistors i bought didn't have any. These two together offer 50 Ohms of resistance, which was close enough for my testing needs. I learned how to calculate resistance in series and parallel from this page. The resulting amperage on the LEDs should be ~ 60 mA, which is below the maximum of 100 for these.

 

The 3V DC is coming from two AA batteries in series, which each provide 1.5 volts. I've got a simple switch to allow me to turn the thing on and off. I don't know how the battery drain will be. Some fancier circuits I've seen have a light sensor attached that will open the circuit (turn it off) when it's not dark.

 

To understand how voltage, current, and resistance are related, follow this rabbit hole!

 

The circuit is effectively illuminating objects up to about 3 feet away, but beyond that, the picture gets dark, at least for the PiNoIR. I'm not sure it will do the job of lighting up the baby in the dark, so I may have to build a bigger one (muahaha) SEE BELOW! I am gathering the courage to try and tap into the Raspberry Pi's GPIO 5 volt pin, but I haven't learned enough about how to do that safely yet.

 

Of course, I want to find a way to save power and not have the IR on all the time, but I also don't want to leave the IR LEDs on all the time because it may not be great for baby's eyes. Since human eyes can't see the IR light, it could be very bright without baby's eyes realizing it and reflexively closing for protection. To adjust for this, I'll ultimately try to set up LEDs that are a little brighter, but add some diffusers in front of them to spread the light out some. If I can also get the light sensor integrated so it can automatically turn the circuit off in the day time, that will be even better.

 

Ultimately, if you aren't interested in the tinkering and experimenting I described above, you're probably better off shopping for some PiNoIR accessories. There are almost certainly pre-built circuits you can use for IR illumination.

 

 

 

 

Next Steps

So far, I'm very happy with the core functionality of this project. Possible improvements and additions for the future:

- Safe power-on and reset buttons on the Pi case

- GPIO-powered IR illumination circuit

- Media player on the Pi to allow us to trigger soothing sounds (like gentle rain, ocean waves, etc.) playing back to help the baby sleep. I'm already working on this, and will possibly use Mopidy to control playback, and the pictured speaker below. Maybe my wife and I can put the baby back to sleep without getting up from our beds!

 

Please don't be shy about commenting! I wouldn't want to misinform anyone here, and half of the useful information I've found came from comments in others' posts, blogs, and sites. I'll hope to update with new info as I get this fine-tuned.

imageimage

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

UPDATE 9/29/2016

 

So, the 2 LEDs I used didn't appear to be enough, and I did indeed build a cleaner circuit with 4 instead. I then discovered how much of an effect the camera's ISO exposure, brightness, contrast, and saturation settings can have, and I may not have needed to do this. But now I have something I can show you. The resistors and LEDs are on two little square board chunks, separated by electrical tape and hot glue (they won't short, trust me!). I'll probably just velcro this to the top of the Pi case for the short term, with the little speaker behind it.

imageimage

 

Even more exciting is that I was able to set up Mopidy as a way to control playback of digital music on the Pi. I have audio coming out of the USB sound card, and I'm playing some some modified following open-source sounds:

 

Raining In The Bart

Soft Rain on a Tent & Bird Ambiance

Gloucestershire, England » England: A River Spring in Spring!

Rain, thunder, then..."silence"

Feb 25 1988 730-750 a.m. or so (which, first of all, sounds just like the sounds they used in Star Trek 4, and second of all, could be re-punctuated "amoroso" because I bet the whales are totally flirting with each other.)

Rain Loop Ontario

Atmospheres » Dawn_1

 

I modified these in a few ways using Audacity to:

1) convert them to mono mp3 files at 320kbps

2) normalize their levels so they would all play at roughly equivalent volumes

3) ensure gentle fades for the sake of keeping baby asleep

4) removing or de-emphasizing moments that were extra loud and would be startling

 

I've got the MPDroid app on my Android and can trigger basic playback instructions for any of these mp3s. It's meant as a complete media server solution (and you can do lots with it!) and the documentation is pretty great (as is the documentatino for uv4l, by the way). Still, both packages were tricky for me to dial in, and the only advice I can give is if you're trying to troubleshoot something, only change one parameter at a time, so you know which tweak fixes your issue.

  • Sign in to reply

Top Comments

  • dammitmcgee
    dammitmcgee over 9 years ago in reply to jkutzsch +1
    Ooh, inspiration! Thanks very much John. A recording of Mommy or Daddy could be really cool! I had thought it must be possible to do an intercom-type setup, but I have to be careful not to bite off more…
  • dammitmcgee
    dammitmcgee over 9 years ago in reply to DAB +1
    Neat idea! I'm particularly inexperienced with circuitry, but very enthusiastic about it. Would the pulse width modulation control the brightness by turning the LED on and off rapidly, and varying the…
  • DAB
    DAB over 9 years ago in reply to dammitmcgee

    As you dig into the RPi capability, you will discover that some of the pins can be PWM.

     

    PWM lets you change the on/off duty cycle to adjust brightness.  You could easily set up software control to change the brightness level.

     

    If you use OPENCV, you can take intensity readings from the image and adjust the brightness as needed.

     

    There are a lot of options with OPENCV, which could set up a number of notifications, actions and all kinds of useful features.

     

    It may take you some time to review and understand the material, but you will be greatly empowered for your project.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dammitmcgee
    dammitmcgee over 9 years ago in reply to DAB

    Neat idea! I'm particularly inexperienced with circuitry, but very enthusiastic about it. Would the pulse width modulation control the brightness by turning the LED on and off rapidly, and varying the ratio of on:off?

     

    Using OPENCV would allow me to find out when something has visually changed, I'm assuming. It could trigger notifications, I'm assuming?

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dammitmcgee
    dammitmcgee over 9 years ago in reply to jkutzsch

    Ooh, inspiration! Thanks very much John. A recording of Mommy or Daddy could be really cool! I had thought it must be possible to do an intercom-type setup, but I have to be careful not to bite off more than a relative newbie like me can chew, else risk discouragement! But seeing the well-established projects like the TalkiePi help a lot.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 9 years ago

    Good start on the basic design.

     

    You can adjust LED brightness with a PWM output from the RPi, so that is just a small change to your overall function.

     

    Have you considered using OPENCV to do image change analysis to detect movement or intrusion?

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jkutzsch
    jkutzsch over 9 years ago

    Looks like you could have some fun with this with future modifications!  Of course the current implementation looks very useable and has the potential to be in a future Transformers Movie!  ;-)

     

    Depending on how virtual you wanted to get you could look at adding a screen with maybe some pre-recorded videos of your wife or yourself to help sooth the baby.

     

    The TalkiePi project might also give you some ideas, allowing for you to speak through another RPi.

     

    https://github.com/dchote/talkiepi

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube