Using the Raspberry Pi Autofocus Camera Module 3 as HDMI camera
Tags: raspberrypi, programming
Published: 2023-04-05 09:04:57

More than two years ago, I blogged about the [use of the Raspberry Pi as an HDMI camera for the ATEM Mini](https://webtechie.be/post/2021-12-20-raspberry-pi-as-hdmi-camera-for-atem-mini/). Although I have been using such a camera since then as my main Zoom camera, I wasn’t always happy with the image quality. The main problem was that the previous Raspberry Pi cameras had a fixed focus and it was quite hard to find the perfect focus.

But with the new version 3 camera module with auto-focus, this should all be solved… and… it is!

**TL;DR; Yes, you can build your own Raspberry Pi camera to use as an HDMI source for the ATEM Mini, and the auto-focus version is an amazing improvement!!!**

## About the V3 camera

In January 2023, [Raspberry Pi announced the 12 megapixel Camera Module 3](https://www.raspberrypi.com/news/new-autofocus-camera-modules/). Starting from 25$, there are four different variants with both visible-light and infrared-sensitive options, and with either a standard or wide field of view. But the most important improvement is powered autofocus for crisp images of objects from around 5cm out to infinity.

To give you an idea of the difference between normal and wide, check these two pictures taken with both version standing next to each other:

![Normal version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcwhr8it17dcq57bkwzj.png)

![Wide version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/182kk23u1twmommfnkas.png)

And these are comparisons of the V2 camera, and both versions of the V3. Sorry for the messy room.

![V2 fixed focus](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7on5f1bxvwjvstbscga.jpg)

![V3 autofocus normal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jejfezwo31f24pp3e6yx.jpg)

![V3 autofocus wide](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x85kaewtqrm9fpd7c28u.jpg)

As you may notice, the V3 also seems to have better light sensitivity and a better color balance. Sorry again for the crappy photo model ;-)

![V2 fixed focus](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1uwr8mfk1iq9rqigurr.jpg)

![V3 autofocus normal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39onx4j51pq80f20twcy.jpg)

![V3 autofocus wide](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m5rffl9xv7wzd0m99dzs.jpg)

## 3D Housing

On [printables.com](https://www.printables.com/model/10531-raspberry-pi-zero-camera-case/files) I found the perfect housing for a Raspberry Pi Zero with this new camera. I had to adapt the front cover as V3 has a different type of camera that doesn’t fit. Unfortunately, the license of the original model doesn’t allow me to share the modified file.

![Frontview of the 3D printed camera housing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2nev1ddnxu83vhaspls.jpg)

![Normal (left) and wide (right) auto-focus cameras](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/plro9x9hsi6sez4cuyt0.jpg)

![Camera screw](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97u9fpm2zrls83gh8c1e.jpg)

## Installation

Because there are no Raspberry Pi Zero 2 boards available at any official dealer, and they are sold for ridiculous prices on other websites, I tried with the original Raspberry Pi Zero. Check the [installation instructions of the original post](https://webtechie.be/post/2021-12-20-raspberry-pi-as-hdmi-camera-for-atem-mini/) for the full description, but use the following service script, that contains one additional line to delay the start of the camera. Without this delay, the service can’t start as the camera is not detected yet.

```
[Unit]
Description=Start the camera fullscreen

[Service]
Type=simple
ExecStartPre=/bin/sleep 30
ExecStart=libcamera-hello --viewfinder-width 1920 --viewfinder-height 1080 -f -t 0 &

[Install]
WantedBy=multi-user.target
```

With a Zero 2, the camera is started within 20 seconds after powering the board, with the original Zero and the required delay, you have to wait just above one minute before the camera is available.

## Conclusion

Camera Module 3 with auto-focus is a great improvement! And in combination with the Raspberry Pi Zero this is a great and affordable HDMI camera you can use as inputs for the ATEM Mini.

I hope to share some videos here soon, made with my improved setup.