A USB Microscope
I have rediscovered my love of hobby electronics and have recently been experimenting with KiCad to build surface mount device(SMD) printed circuit boards(PCBs). If you have no experience with these, just know that the 0805 light emitting diododes(LEDs) I am using are 2mm x 1mm in size.
In order to effectively inspect these circuits during assembly, I am going to need some significant magnification. Luckily, ten plus years ago I purchased a cheap generic USB microscope from Microcenter and it has been sitting unused since the first time I plugged it in. These are still the same inexpensive microscopes you will find on Amazon, so don't worry this is all still relevant to any device you will most likely source. This is the process I used to get the device working on my Ubuntu 24.04 Desktop.
Sorting It All Out
Using dmesg
we can print the diagnostic information the operating system's kernel is producing when it interacts with new device hardware.
sudo dmesg --follow
Plug in the device and you should see similar device information printed to the screen.
[18389.692053] usb 1-4: new high-speed USB device number 10 using xhci_hcd
[18389.944540] usb 1-4: New USB device found, idVendor=0ac8, idProduct=3420, bcdDevice= 1.00
[18389.944546] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[18389.944549] usb 1-4: Product: Venus USB2.0 Camera
[18389.944552] usb 1-4: Manufacturer: Vimicro Corp.
[18389.961547] usb 1-4: Found UVC 1.00 device Venus USB2.0 Camera (0ac8:3420)
[18390.017722] input: Venus USB2.0 Camera: Venus USB2 as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-4/1-4:1.0/input/input25
[18404.957256] usb 1-4: USB disconnect, device number 10
[18411.193736] usb 1-4: new high-speed USB device number 11 using xhci_hcd
[18411.447508] usb 1-4: New USB device found, idVendor=0ac8, idProduct=3420, bcdDevice= 1.00
[18411.447515] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[18411.447517] usb 1-4: Product: Venus USB2.0 Camera
[18411.447520] usb 1-4: Manufacturer: Vimicro Corp.
[18411.464513] usb 1-4: Found UVC 1.00 device Venus USB2.0 Camera (0ac8:3420)
[18411.520666] input: Venus USB2.0 Camera: Venus USB2 as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-4/1-4:1.0/input/input26
The line Found UVC 1.00 device Venus USB2.0 Camera
tells us that the kernel found a device that conforms to the the USB Video Class (uvc) standard. This means that the uvcvideo
driver, which is a standard Linux driver for webcams, will be loaded for the device. This driver will create new /dev/video*
device files which we can see here.
toor@toor-runcible:~/workspace/home-lab$ ls /dev/video*
/dev/video0 /dev/video1
In this case the /dev/video0
is the primary video capture interface. The second file /dev/video1
Is most likely exposing some additional metadata capture interface, like time stamps, or other control information like USB lighting, the zoom, etc. We don't need this metadata information to simply use the device.
I have chosen mpv
which is a simple commandline media player that can display input from a usb camera using the video 4 linux 2 API.
sudo apt install mpv
We can start video capture using this command:
mvp av://v4l2:/dev/video0
Above we provide the video device using the av://v4l2:<video device>
format. Here av://
tells mpv
to use FFMpeg's libavdevice
library to open the media. v4l2:
stands for Video4Linux2, which is a set of APIs and drivers for Linux that allow you to capture video from devices like webcams, TV tuners, and video capture cards. Lastly, we are providing the device location as /dev/video0
which was created by the uvcdriver
above.
This will open a UI element displaying the video steam. We can resize the screen and if needed we can capture input using the s
key. Files will be saved to the current working directory of the terminal session where the mvp
command was invoked. Excellent, I can finally get back to inspecting those tiny components.
Wrap Up
To finish this out I am adding a bash alias like alias scope='cd /home/toor/USBScope && mpv av://v4l2:/dev/video0'
to my ~/.bashrc
file to ensure I am always saving any screenshots I make to a consistent location.