Search

Wednesday, September 26, 2012

Raspberry Pi Logitech QuickCam Communicate STX USB cam P/N 861223 added to micasaverde Vera

Updated, based on new motion version. And it works a lot better now!

Lets hope I’m finally able to write a tutorial how I was able to add the Logitech QuickCam Communicate STX USB cam P/N 861223 to Raspberry PI and then also connect it so I can see the video in the micasaverde vera. If this looks easy it wasn’t at all. I have spent so much time testing so many software's without any good result. Some disclaimers that this is the way I got it to work, not stating that this is the way it should be done… But here it comes….
The instructions is based on the Debian Raspian “wheezy”
The camera must be plugged into a _powered_ usb hub. I also run the Pi from the same hub.
Install the software:
sudo apt-get install webcam v4l-conf
To find the value that should be in the input field in the .webcamrc file

v4l-info | grep name
        name                    : "gspca_zc3xx"
        name                    : "Brightness"
        name                    : "Contrast"
        name                    : "Gamma"
        name                    : "Exposure"
        name                    : "Gain, Automatic"
        name                    : "Power Line Frequency"
        name                    : "Sharpness"

Create the config file
sudo nano /home/pi/.webcamrc
[ftp]
host = localhost
user = pi
pass = password
dir = /var/www
file = webcam.jpg
tmp = imageup.jpg
local = 1
[grab]
device = /dev/video0
width = 640
height = 480
delay = 1
wait = 1
input = zc3xx
#norm = pal
quality = 50
trigger = 0
once = 1

For setups where the cam is on a different system than the Web server, you'd have to: Set the local value to 0 in the config file
sudo mkdir /var/www
Test it:
sudo webcam /home/pi/.webcamrc
Stop the webcam with Ctrl+C
Install the web server
sudo apt-get install apache2 &
Remove web server logging so it does not use all your disk by remarking the lines in:
sudo nano /etc/apache2/apache2.conf
#LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\""$
#LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combi$
#LogFormat "%h %l %u %t \"%r\" %>s %O" common
#LogFormat "%{Referer}i -> %U" referer
#LogFormat "%{User-agent}i" agent
sudo nano /etc/apache2/sites-available/default
#       CustomLog ${APACHE_LOG_DIR}/access.log combined
Test the web server
http://x.x.x.x/webcam.jpg?Quality=Standard
Create a bash shell script to start it:
sudo nano /home/pi/cam.sh

#!/bin/bash
while ! sudo webcam /home/pi/.webcamrc  >> /dev/null 2>&1 &

Change the file so it can be executed:
chmod 777 /home/pi/cam.sh
Run it:
sudo nohup /home/pi/cam.sh&
This time it runs in the background until you restart the Pi. Press ENTER to get your prompt back.

If you like the app to start every time you start the Pi
This will add the cam to the right run level
update-rc.d cam.sh defaults

Add the Panasonic camera plug in to Mios.com Vera and configure the URL field with webcam.jpg?Quality=Standard
First times it might not show the picture directly. Then I had to go to the settings tab and then back.

2 comments:

  1. Hi! I also have such a webcam. My raspi is yet to arrive, but I was wondering if it's possible somehow to get it to work without a powered HUB. I'm building a device (actually a cuddly bear) that would have a builtin webcam and a raspi, but having to use a powered hub would complicate things a little). Maybe with a more powerful charger (eg. 2A) the USB ports would be able to supply enough amperage? Thanks! Bence

    ReplyDelete
  2. Hi Bence, Only one way to find out... For me and my version of Pi and my charger I never got anywhere to a stable picture without the external powered USB hub. And I do agree with you that it does complicate things...

    ReplyDelete