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 -
  • 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