Connecting a Pencam to the Omnima router


This week-end I tidied up my electronics stuff and in the process found a 'Mercury' pencam I bought ages ago and had long forgotten (see above). In case you're wondering, I added an external battery holder so I could use AAs instead of the AAAs it normally uses. I decided this would be ideal to use with the Omnima since I could use the 3.3v supply instead of the batteries, and wondered if I could use the USB port to transfer pictures to the router.

The camera has an optical viewfinder to position the shot, and an LCD display (cracked in my case) with two digits showing the number of shots left. There's also a shutter button on the top and an on/off/reset button at the back.


PC Connection

Here's what happened when I plugged it into my laptop:

drivers/media/video/stv680.c: [stv680_probe:1425] STV(i): STV0680 camera
drivers/media/video/stv680.c: [stv680_probe:1465] STV(i): registered new
video device: video0
usbcore: registered new interface driver stv680
drivers/media/video/stv680.c: [usb_stv680_init:1546] STV(i): usb camera
driver version v0.25 registering
drivers/media/video/stv680.c: STV0680 USB Camera Driver v0.25

It gets recognised by hotplug which loads the STV680 driver, however that's for 'webcam' mode (isochronous), and not well supported by the ADM5120 USB driver, so I unloaded the driver to see if it could be accessed via another means.


Gphoto2 is supposed to have support for this device, and it lists the pictures on the camera:

root@cent:~# gphoto2 -L
There are 6 files in folder '/'.
#1     image001.pnm
#2     image002.pnm
#3     image003.pnm
#4     image004.pnm
#5     image005.pnm
#6     image006.pnm

Unfortunately the 'snapshot' feature doesn't work :-(:

root@cent:~# gphoto2 --capture-image
ERROR: Could not capture.
*** Error (-1: 'Unspecified error') ***

For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list <>, please run
gphoto2 as follows:

    env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt

Please make sure there is sufficient quoting around the arguments.

Also, the picture download didn't work, so I couldn't use it to recover pictures previously taken from the camera.


I also found a piece of software called pencam2 written back in 2002. With some minor changes it worked with my 2.6 kernel. I hacked out the hideous menu system so it could easily be run from a script - the only thing I'm interested in here is taking a picture. I also had to remove all references to term.h, since that doesn't seem to be available in the OpenWrt include path (at least the way I'd configured it). My version is here

Connecting to the Omnima

The camera gets recognised when connected to the router:

usb 1-1: new device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Dual-mode Camera
usb 1-1: Manufacturer: STMicroelectronics
hub 1-0:1.0: state 7 ports 2 chg 0000 evt 0002
hub 1-0:1.0: port 1 enable change, status 00000103

And I can use pencam2 to take a picture:

root@OpenWrt:/# pencam2
Cameras found: 1 @ 001:002  **   Active Camera @     Camera Pictures
Firmware     ASIC rev     Sensor ID
      001:002               6              3.00         7.60         500.4
Supported formats:   VGA (640x480)    QVGA (320x240)
Downloaded picture 1  (F_Exp=  3,  C_Exp=472,  APV= 90 => warm)

I initially thought something had gone wrong, because I had to wait a full minute and a half for this to complete. I don't think this is due to the speed of the CPU, because it only took a second on my laptop, and there shouldn't be such a speed difference. I will investigate what's holding things up in due course.

The picture gets written to the /tmp directory:

root@OpenWrt:/# ls /tmp
lock             resolv.conf      run              state
log              root             snapshot001.ppm

From here it's fairly easy to create a link to /www, i.e.:

root@OpenWrt:/# cd /www
root@OpenWrt:/www# ln -s /tmp/snapshot001.ppm snapshot.ppm

So the picture can be recovered with a web browser from the router. Left as an exercise for the reader to turn this setup into a (rather slow-refreshing) webcam. It should also be fairly easy to convert the ppm into a jpg.


bifferos 26/5/2008