Saturday, 1 March 2014

Raspberry Pi Baby Monitor with IR Camera

I wanted to build a video baby monitor, using a Raspberry Pi and Android Tablet. For now it is video only, I'm looking to add audio via a USB microphone in the future. Here is what happened..

Acquire Hardware

After a bit of Googling here is the parts list I came up with, where I had to buy things I have included links.

Put the hardware together

  • Solder LEDs to stripboard, 4 LED series sets, in parallel.
  • Solder Power LED cable to the stripboard (I used this as the connectors fit onto the GPIO port).
  • Drill holes in stripboard to fit the camera case, and Pi case.
  • Cut out corner to leave space for the GPIO cables.
  • Assemble camera into case and bolt to the stripboard.
  • Connect 5v to the GPIO (pin 2 and 6)
  • Assemble Pi and Camera into their cases, bolt it all together.
  • Trim bolts down.

The Software

While setting up the software I plugged the Pi into a monitor, using a hub to connect the keyboard and wifi at the same time. My hub seemed to be having a good time ;) I'm no Linux Guru, this setup is the result of 3 evenings of trial and error. I'd welcome any suggestions to improve efficiency (there is roughly a 2 second lag on the video output)
  • Install Raspbian - http://www.raspberrypi.org/downloads
  • On the installer screen:
    • Expand filesystem
    • Enable camera
    • Enable SSH
    • Finish!
  • Get the Wifi working
    • wpa_cli
    • > add_network (it will return a number which we'll refer to as 'x')
    • > set_network x ssid "Your Network SSID"
    • > set_network x psk "Your Network Key"
    • > enable_network x (it will then connect to the network)
    • > save_config
    • ctrl+c
  • Wifi is now configured to auto connect with DHCP, I use my broadband router to reserve IP addresses so I can now connect to the Pi knowing the IP.
  • Make sure everything is up to date..
    • sudo apt-get update
    • sudo apt-get upgrade
  • Install Screen and VLC
    • sudo apt-get install screen vlc
  • Disable the camera activity LED:
    • sudo nano /boot/config.txt
    • add : disable_camera_led=1
    • Save/exit
  • Launch the camera streaming at startup. After a lot of experimenting this uses raspivid and VLC to stream the video. These parameters provide nice performance with a good frame rate. Experiment with the startup string to suit your own needs.
    • sudo nano /etc/rc.local
    • insert this line before 'exit 0'
    • screen -dmS webcam bash -c "su -l pi -c 'raspivid -w 440 -h 240 -hf -vf -t 0 -o - | cvlc -vvv stream:///dev/stdin --sout \"#rtp{sdp=rtsp://:8554/pi.sdp}\" :demux=h264'"
    • Save/exit
  • Reboot, camera should auto start..
  • From VLC on your tablet/PC, load the following URL:
    • rtsp://IPOFYOURPI:8554/pi.sdp
  • I also found the software 'anPlayer' useful as VLC does not store/bookmark URLs

8 comments:

  1. Hello,

    Very nice guide and babycam :)

    Can you post a photo or more details about the other side of the strip board ? Specifically how the connection with the GPIO interconnects with the 4 LED series sets in parallel ?

    Thanks a lot!

    ReplyDelete
    Replies
    1. Hi, the LEDs are grouped into 4s and then in parallel, connected to the 5v GPIO pins. Try powering the LEDs from a phone charger if you are unsure, its cheaper to replace than the Pi :)

      Delete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. Hi did you have any luck with the audio? Great tutorial by the way - worked very easily - i couldn't believe how easy it was to set up my iphone to see the stream. Adding audio to the vlc stream would be a real bonus.

    Also do you have any thoughts on the infra red led's possible effects on eyesight. There are rumours out there that even though they aren't in the visible range they may be harmful if stared directly at - probably at this low power there is no effect....

    ReplyDelete
    Replies
    1. The Pi doesn't have audio on board, so it would need a third party module like this.. http://www.amazon.co.uk/gp/product/B00IOS77RY/ref=as_li_tl?ie=UTF8&camp=1634&creative=19450&creativeASIN=B00IOS77RY&linkCode=as2&tag=clickedmeuk06-21 and then some more config! Not bothered about the IR personally, compared with the amount you are exposed to every day outdoors it's nothing.

      Delete
  4. Im having trouble capturing video and sound. I have a USB sound chip that mic plugs into. I dont want to stream the A/V, just save it to sd card or maybe a larger external drive. Any help would be appreciated. Yeah Im a noobie.

    ReplyDelete
  5. I'd recommend asking for help here.. https://www.raspberrypi.org/forums/

    ReplyDelete
  6. Thanks for great information you write it very clean. I am very lucky to get this tips from you. Source

    ReplyDelete