8M autofocus sensor module failed demos


I think something is wrong with these Demo scripts, because they run more or less well, but closing them DOES NOT keep the focus, making it useless to take photos or video.
I have tested the official 8M V2 camera module on a raspberry Pi 3A +, with updated stretch and buster:

1- Snapshot.py

-When running it, the small window pygame appears in BLACK.
-Press UP key: value always 512 Image save OK.
-We set the focus completely to BLIND.
-We see all the jpg defocused.
-We close the main cmd window.
Result: 18 unfocused photos.jpg

2- Preview.py

-When executing it, two windows appear: the small and always BLACK pygame,
and the enormously large Preview, which hides much of the desktop.
-Close correct focus with the UP key up to a value of 272, and we stop.
-We close the window.
-We take a photo with raspistill -or previous.jpg of the previously focused object, totally out of focus.
Result: the camera DOES NOT SAVE THE FOCUS, making it completely USELESS

3- Autofocus.py

Similar to the previous ones, huge preview window that covers almost everything.
We close the window.
We take a test photo raspistill -o autofocus.jpg: Defocused
Result: Autofocus OK Photo OK, but when closing the window, it doesn’t keep focus with raspistill.

4- Folder C, manualFocus.py

-Huge pre-screen, which covers almost the entire desktop.
-Press the UP key, in the command viewer only UP or DOWN appears, (No numerical value)
-We got focus OK.
-We close the window.
-Test photo raspìstill -o manualfocus.jpg DEFOCUSED again.
Result: It does NOT save the focus value. END of the test.

I wonder if it is an error in the demo scripts and if not, what is the use of buying this module?
Hope someone from the arducam team can help me clarify this issue.
Thanks in advance.


Thank you very much for your excellent suggestions and comments. The examples we provide are just a simple test of the function of the camera motor. You are welcome to join us to improve these test examples.

Sorry, I’m not an expert in Python programming languages or C.
I think I have not expressed myself well:
What I really need is HELP in this forum.
My project is a raspberry pi 3A + camera trap that takes photo or video sequences of birds at fixed points, but it is impossible to focus the raspberry 8M V2 from a distance.

Robin in feeder

I hope someone from this forum can help me, if not, I will have thrown my money away.


I know your requirement. Why not use UVC camera with auto focus?

Raspberry Pi ISP does not support auto focus, we wrote a demo with software, the speed and effect are not very good. We have a UVC cmaera with auto focus, you can consider it.