Jeff Geerling's Ansible Playbook Turns a Raspberry Pi and HQ Camera Module Into a USB Webcam

Just set the playbook up on a Raspberry Pi Zero with Camera Module in place and you can avoid the scalpers reselling high-priced webcams.

Gareth Halfacree
3 years ago β€’ Photos & Video / Communication

Maker Jeff Geerling has, in the face of a continuing shortage of decent-quality webcams as those who can transition at least temporarily to remote working, published a guide to turning a Raspberry Pi Zero single-board computer and HQ Camera Module into a fully-functional webcam.

"I'll show you now to set up a Raspberry Pi Zero with the HQ Camera and the 6mm lens as a high-quality webcam to rival the quality of other cameras costing even more (if you can find them this year!)," Geerling writes in the introduction to his latest video.

"And I'm not going to make you dive into the guts of your Raspberry Pi and compile code or anything like that β€” it's just one automated job that runs to set everything up for you, on any Raspberry Pi! (Right now it's only working correctly on the Pi Zero though!)."

With a little USB OTG trickery, a Raspberry Pi Zero and Camera Module make a great webcam. (πŸ“Ή: Jeff Geerling)

The heart of the build, hardware aside, is an open source project maintained by Geerling dubbed the Raspberry Pi Webcam which turns a camera-equipped Raspberry Pi into a USB webcam using the USB On The Go (OTG) functionality. "Inspired by David Hunt's blog post showing how to use a Raspberry Pi Zero with a Pi Camera as a USB Webcam, as well as justinschuldt's gist," Geerling explains, "I wanted to make my Raspberry Pi do the same thing, but automated and with all the scripts wrapped in version control, since the blog post was a little bit vague in some areas. This Ansible playbook can be run on any Raspberry Pi to set it up as a USB OTG webcam."

There are, of course, a few caveats: Geerling's playbook has only been tested with the Raspberry Pi HQ Camera Module, and not the older Camera Module variants, and only on a fresh installation of Raspberry Pi OS which has not been modified β€” "though," he notes, "it should work correctly with an existing installation."

Other warnings include brightness adjustment requiring modification of a hard-coded variable and a recompile, frame drops over 720p resolution, and lock-ups using the playbook on a Raspberry Pi 4 Model B.

The full video is up on Geerling's YouTube channel, while the playbook and step-by-step setup instructions are available on GitHub.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles