Fixing the blurry focus on some Raspberry Pi Camera v2 models

The original Raspberry Pi Camera model v1.3 came from the factory set to ∞ (infinity) focus, so when you used it out of the box for something like a landscape timelapse rig, or for security or monitoring purposes (where the Pi is at least 5 meters away from the subjects it's recording), everything would look crisp and sharp.

For many fixed-focus cameras and lower-end camera sensors, it makes sense to set them to infinity focus; closer objects are still recognizable, but slightly blurry. Most of these cameras don't need to focus on a person a meter away for a portrait, and they're also rarely used for FaceTime-like video chat.

For the Raspberry Pi Camera v2, the Raspberry Pi Foundation originally decided to have the focus set for 1-2 meters away, so if you bought a v2 camera and used it for distant subjects (like I do for most of my pi-timelapse videos), then everything looked a bit blurry or hazy out-of-the-box.

For example, when I swapped out my v1.3 camera for a v2 model this week to record some residential road construction, I ended up getting a pretty poor image:

Raspberry Pi Camera v2 with blurry focus set at the factory

Notice especially the inset cone at slight magnification; it is not only blurry, but also washed out since a blurry image can really mess with the camera's autoexposure, resulting in a muddy picture that is at best a hazy reproduction of the scene.

The Raspberry Pi Foundation decided to set v2.1 and greater cameras back to inifinity focus, so this wouldn't be an issue with the latest camera. But a lot of resellers (including Amazon) are still shipping from their stock of v2 cameras with the focus set at a short distance.

Warning: Adjusting the lens in the way described below will likely void any warranty you may have had, and you won't be able to return the camera module after doing this. So either be careful and suffer the consequences if something breaks... or don't do it and try to buy a newer camera module with infinity focus from the factory!

Luckily, there's a fairly easy fix: If you have a pair of jeweler's pliers or mini needle-nose pliers, you can use them to directly manipulate the lens focus; just grasp the front element of the lens and rotate; if the lens is difficult to rotate (it has a slight amount of glue locking it in place from the factory), you may need to use another tweezers/pliers to carefully hold the base of the camera module, then give a little back-and-forth twist until the lens starts rotating.

Mini needle-nose pliers for precision electronics work
I bought this long-nose, or needle-nose pliers from Amazon; but any small needle-nose pliers or a sturdy pair of tweezers should do fine.

Raspberry Pi Zero W in case with camera on top cover
To adjust focus, pinch the indentations with the pliers (gently), then give a small amount of torque (just enough to break the thin glue that sets factory focus). Turn back and forth in small increments while taking pictures to confirm the correct focus.

In my case, I needed to rotate the lens about 50° counter-clockwise (I rotated about 5°, took a picture, rotated another 5°, etc. until the image was about as sharp as I could make it), and the sharpness was greatly improved:

Raspberry Pi Camera v2 with sharper focus set manually

And here's that other blurry picture again, for comparison:

Raspberry Pi Camera v2 with blurry focus set at the factory

HollandJim on Reddit mentioned there's also a little $0.95 purpose-built Lens Adjustment Tool available from Adafruit. It is worth picking up this specialty tool if you plan on using your Pi camera in a variety of settings where focus would need to be changed.

If you don't have small pliers, then a credit card, a drill, and a file will do in a pinch. You would need to drill a hole in the credit card that's about 5/16" (~8mm), then file away slots in this hole (with a very small file) to line up to the indentations on the top of the camera lens. See this Q&A thread on the Raspberry Pi forums for more on that technique, and some of the explanation of why the v2 camera was made the way it was.

Comments

Thanks for this, great write up of the problem, do you have a link on the statement "Raspberry Pi Foundation decided to set v2.1 and greater cameras back to inifinity focus" can't seem to find that statement from the Foundation. Also how would you tell if you have an older or newer focal camera?

I definitely have the older one; I had to futz around with it's focus to get it to show clouds / distant objects sharply. There wasn't an official statement, but I remember reading about the focus change in the Raspberry Pi forums, I think in a post by one of the engineers on the camera team.

This comment came from someone who seems to have been blocked from posting a comment on the site:

It happens the first batch of v2.1 cameras had that issue. Following releases had focus set to infinity:

https://www.raspberrypi.org/blog/camera-board-comparisons-pi-noir-v1-vs-pi-noir-v2/#comment-1259481

In this topic/thread, Eben Upton gives more insight about this issue. Just the explanation you were after.

https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=145815&start=200#p971091

This worked for me as well. The Pi Camera I bought had a little white plastic wheel that slipped over the lens to make it easier to focus, but that was basically it - it needed to be focused. And I could have done it with some pliers as well if I was very careful.

Thanks. It didn't occur to me that the Raspberry Pi camera would have a focal adjustment. After following the instructions, the image is clear again.

Hey Jeff - I just wanted to shoot you a quick thank you for this post. I'm doing a few things with image processing and was having a really hard time getting a clean shot - until now! As a heads up, for those of you that don't have needle-nose pliers, you can also use a small flathead screw driver.

Thanks again for your help, Jeff!

MR
http://michaelbryanross.com/
https://www.linkedin.com/in/michaelbryanross/

Oh, is THAT what that white plastic cone is that shipped with the camera! No documentation at all and I couldn't figure out what it was. My V2 camera seems to be set for infinity and I don't want that! Thanks for this page!

Yeah, I just returned a NoIR V2 camera, because I couldn't seem to find any distance where objects were in focus. Had they documented what that white plastic "cone-shaped" disc was for, the return could have been avoided. :-/

Exactly! I've had two of those plastic cones for 2 years now and only just discovered what they are for! Meanwhile seem to have trashed a camera trying to use a pair of pliers...

Massive thanks for this, I thought my camera was broken!

This was a real eye opener. I was about to buy a usb webcam and have to re-setup my octopi until I read this. Used a set of tweezers to bring everything into focus. So useful! Thank you.

I used my fingers to rotate the lenses and it worked just fine.

Hi Jeff,
Thank you for the tip. One of the pi cameras I bought came with a small white piece that I had no use for... It turns out that it's the tool to replace the pliers in your explanations :D