3 Comments

Using A Raspberry Pi Zero as a webcam without SD card

{}
January 7th, 2021

The covid lock-down is sentencing a lot of people to work from home. For that we need webcams, a new pc, better monitor  and other equipment. The Raspberry Pi 400 is  a great and affordable second desktop, it’s the fastest Pi available suited for desktop use. It lacks a camera connector, so you need a Zero to connect a camera board.

So what about reusing that old gadget that was collecting dust in the drawer: a small and cheap Raspberry Pi Zero. If you also happen to own a camera board for that little computer, here is a nice project showmewebcam to turn that cheap computer into a handy webcam. It uses a small Buildroot Linux version and boots really fast.

And now that project has been forked on Github: showmewebcam-usbboot. No SD-card needed. That project will let the Raspberry Pi Zero boot over USB!

If you don’t have a camera board. You can buy a clone version of the v1 board for a few dollars in China, or get a v2 board or for the best results the really great HQ-camera board.

Interested in photography, that High Quality camera board can do some really great macro-photography.

Cheap Raspberry Pi webcam

With the Raspberry Pi Zero costing about 5 euro, and a clone camera board around 3 euro on AliExpress, you can have a very nice and decent webcam for less then 10 euro’s. And that is a bargain. Remember you don’t need an SD card. So save on the hardware where you can.

How does it work?

How does the Pi boot then? Over USB, so you do need the usbboot/rpiboot tool. That is free and opensource software made by the Raspberry Pi organization, a program that makes the Raspberry P Zero boot by pushing the operating system over USB.

Let’s try it out. I’m using an Ubuntu desktop.

Step 1: download showmewebcam-usbboot

Download the latest release .

Unzip it. You will extract a directory called showmewebcam-usbboot.

Step 2: install usbboot/rpiboot

If you have already installed a version of this tool, you can of course skip this tool and jump to step 3.

Download the usbboot/rpiboot, unzip it and build it according to the instructions.

Step 3: Connect the raspberry Pi Zero

(with installed camera board) by putting the USB plug into the middle USB connector.

Step 4: boot the webcam

You can start the webcam by executing the rpiboot tool and pointing it to the unzipped showmewebcam-usbboot directory

sudo ~/usbboot/rpiboot -d ~/showmewebcam-usbboot

After about half a minute booting the Raspberry Pi Webcam will be ready.

How to use the Webcam on the PC

For a quick start, and when no other cam is connected, you can start the webcam with (Ubuntu):

mpv /dev/video0

On a laptop with a build-in webcam the command that you have to issue will be :

mpv /dev/video2

To control your cams on the PC, you need `v4l-utils` (apt install v4l-utils)

To set the resolution

v4l2-ctl --set-fmt-video=width=1280,height=720 -d /dev/video2

To list all video devices:

v4l2-ctl --list-devices

To list the specs of your video devices:

v4l2-ctl --list-formats-ext
ffmpeg -f v4l2 -list_formats all -i /dev/video2

A serial connection will also be available, so you can connect to the Webcam to control the settings and do debugging. That works exactly the same as in showmewebcam

Control the webcam

Finer control offers the camera-ctl tool on the Zero

Connect to the Zero:

sudo screen /dev/ttyACM0 115200 Start the tool # /usr/bin/camera-ctl
Showmewebcam-usbboot - Controlling the webcam with camera-ctl

Controlling the webcam with camera-ctl

Create a stereo webcam

The tool will let you boot more then one Raspberry Pi Zero from the same directory. Just connect the two Raspberry Pi Webcams and start the tool. One will boot, just execute the tool another time and the other one will boot.

The webcams will be available as /dev/video0 (you) and /dev/video2 (your cat) on your Pi400.

Now make that video call with your boss, and ask for a raise. Switch the webcam to your cat the moment you stopped speaking.

What can showmewebcam-usbboot do what showmewebcam can’t do?

Nothing. It can do the same with less hardware, because it doesn’t need an SD card. But is does need extra software, which can limit compatibility. It also boots slower.

It hasn’t been tested that much.

Have fun, try it out,  en let me now your thoughts!

Links:

No Comments

Running Raspberry Pi OS on a RPI Zero without SD card

{}
January 2nd, 2021

I’ve blogged before about how to boot a Raspberry Pi Zero over USB without an SD card, just powering it with an USB cable in the middle USB connector, and connecting at the same time.

This Christmas I tried it with a new Buster version and a trusty old Raspberry Pi Zero and following the tutorial it’s still running fine with the latest Raspberry Pi OS 2020-12-02-raspios-buster-armhf-lite.img.

Time for some improvements. Updating and upgrading was always possible, but not always successful: you could easily run into disk-space problems.

Default images are shipped/downloaded as small as possible and the default action of booting a Pi with a new image is resizing the root partition to claim all available space on the SD card.

We’re mounting over NFS and of course the resizing did not happen in our case. Luckily, otherwise your guest OS would end up with no space and the Pi would have a partition size of 1GB (or so).

But for upgrades we need more space than the default.

How to increase the image size of an mounted image over NFS?

The image I have downloaded is `2020-12-02-raspios-buster-armhf-lite.zip`, and we have to follow 4 simple steps.

Step 1: unpack it:

unzip 2020-12-02-raspios-buster-armhf-lite.zip 2020-12-02-raspios-buster-armhf-lite.img

Step 2: resize raw image:

Then use qemu-img (QEMU disk image utility) to resize the raw image.

sudo qemu-img resize 2020-12-02-raspios-buster-armhf-lite.img 3G

Here we resize it to 3G, that must be enough to install some extra programs, and download and install updates.

Step 3: set it up as loop device:

sudo losetup -P /dev/loop101 2020-12-02-raspios-buster-armhf-lite.img

These day I set it up as loop101 instead of loop0 as I did in the blogpost of 2018 to avoid conflicting loop devices. Snaps are also installed as loop devices.

Step 4: resize root partition

start gparted with the loop device to resize the root partition.

sudo gparted /dev/loop101

Normally gparted never shows loop devices, but it does when you explicitly start with a loop device.

Then simply push the slider to resize the image, and apply the changes and you’ve gained 900MB of disk-space.

More than enough to do updates and upgrades for years to come.

No Comments

Using a Logitech G203 mouse under Linux

December 4th, 2020

Both the Logitech G203 Prodigy and the newer Logitech G203 Lightsync are affordable gaming mouses that have a normal size, a small lag, nice sensors, and also suitable for general use.

The mouse has six buttons, and by default the the fourth and fifth thumb buttons are defined as back and forward buttons, that come in hand browsing the web. I’m not sure what the sixth is by default, but it can easily set up to switch or cycle resolution.

But how to control the RGB lighting, the buttons and the resolution under Linux / Ubuntu?

Configuring the Logitech G203 mouse

You have to do the following to get the mouse working under Ubuntu 20.04:

Install the ratbagd system daemon to introspect and modify configurable mice:

sudo apt install ratbagd

Install the GUI Piper, that is available as flatpak:


flatpak install flathub org.freedesktop.Piper

The G203 Lightsync is a relative new mouse, the ID is still missing from the definitions shipped with ratbagd, so we have to add that manually.

To find the ID:

lsusb
Bus 003 Device 002: ID 046d:c092 Logitech, Inc. G203 LIGHTSYNC Gaming Mouse

Edit usr/share/libratbag/logitech-g102-g203.device


sudo vi usr/share/libratbag/logitech-g102-g203.device
DeviceMatch=usb:046d:c084;usb:046d:c092

Restart the ratbagd daemon:

sudo systemctl restart ratbagd.service 

Run Piper, and the GUI will start, so you can set resolution, buttons and RGB effects.

Configuring the Logitech G203 mouse under Ubuntu with Piper

Configuring the Logitech G203 mouse under Ubuntu with Piper

The proper SVG image is still missing though.

No Comments

Text with pattern the new way

October 4th, 2020

In the past the only way to to get colored text, like from an image or gradient was to use SVG.

Nowadays pure CSS is enough.

Although a prefix with -webkit- is still needed for Safari and Blink browsers.

.post-2027 h1{
background-image: linear-gradient(
90deg,
#7383c1 0%,
#bed876 50%,
#e0b384 100%
);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
width:max-content;
}
1 Comment

Why the upgrade from Ubuntu 18.04 LTS to Ubuntu 20.04 LTS is not available yet.

September 9th, 2020

Linux users of the Ubuntu 18.04 LTS (Long Term Support) are still waiting to upgrade their systems to 20.04. Normally at around the time the first point release of the new LTS distribution is released.

What is a point release?

These point releases include support for new hardware as well as rolling up all the updates published in that series to date. So a fresh install of a point release will work on newer hardware and will also not require a big download of additional updates. These include security updates and corrections for other high-impact bugs, with a focus on maintaining stability and compatibility with Ubuntu 20.04 LTS.

And 20.04.1 was released on August 6. But the problem is: not all flaws have been ironed out yet in 20.04.1. So at the moment you can’t be confident to get a smooth upgrade from 18.04 LTS. That’s why the upgrade is not yet available. Yes you can get a smooth install, but not a smooth upgrade.

Upgrade blocking bugs for 20.04

There are 2 blocking issues at the moment, and they must be solved first:

  1. eoan to focal upgrade hangs when lvm snapshot is present (bug 1876506) resolved
  2. grub-pc upgrade support (bug 1891680)

Here you can track the release status.

If you wanna take the risk, you can always force a upgrade with:

do-release-upgrade -d
No Comments

Getting the date right in Javascript in your language of choice

August 20th, 2020

The Internationalization API provides language number formatting, string comparison, and date/time formatting in Javascript. It’s a global object.

Intl.DateTimeFormat('en-GB',
{
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
weekday: 'long',
era: 'long',
year: 'numeric' ,
month: 'long',
timeZoneName: 'long',
hour12: false
}).format()

What is the time today?