Upgraded lens for Raspberry PI V2 camera

3D printed a holder so that I can use my old SLR lens with the raspberry PI v2 camera

Public Chat
Similar projects worth following
I had some older lenses for a Pentax SLR camera. They have manual aperture and focus adjustment so they lend themselves to working for this project.

I had some older lenses for my Pentax SLR camera.  The lenses have manual focus and manual aperture control.  So, I went about designing a 3D printed holder for the lenses and the raspberry pi camera module V2.

First, I measured the Pentax SLR camera body - particularly the distance from the lens mount plane to where the film was.  Then, I designed a barrel and holder so that the bayonet lens can twist into the print, the raspberry pi camera module v2 can mount on the other side, and the whole thing can be mounted securely.

Note - you have to take off the original lens that shipped with the raspberry pi camera module v2.  You can use the lens removal tool that came with the camera, or 3D print your own (  ).

It worked out pretty well!  Here is a photo using a 28 mm lens.

The distances were roughly correct - the subject was about 2 m away, but the lens reading was about 1m.

I put some black construction paper on the inside of the print to help block the light, but there is still a little light leaking through the back, so the picture has a delightful blueish tinge.  :)

Since the lens ended up a bit closer to the sensor, then you can always add spacers at the back where the sensor is to adjust the lens through normal to macro operation.  You only need a few millimetres, which is something I never fully appreciated until this project.

Note that the sensor area is quite a bit smaller than the film for the SLR camera, so you get a smaller slice of the image.


STL file of the mount

Standard Tesselated Geometry - 345.09 kB - 02/05/2021 at 16:15



Helper file for the mount

scad - 666.00 bytes - 02/05/2021 at 16:15



OpenSCAD design of the lens and pi camera mount

scad - 4.59 kB - 02/05/2021 at 16:15


  • 1 × Raspberry PI 3 Model B+
  • 1 × Raspberry PI Camera Module 2
  • 1 × Manual SLR lens

  • 1
    Ramdisk for raspberry pi

    So, you want to take a bunch of photos, but don't want to burn the SD card on the raspberry pi?  Place the files on a ramdisk.

    Make the ramdisk

    sudo mkdir /mnt/ramdisk

    Edit the rc.local file

    sudo nano /etc/rc.local

    Add the lines above exit 0

    mount -o size=30M -t tmpfs none /mnt/ramdisk

    /bin/chown pi:root /mnt/ramdisk

    /bin/chmod 777 /mnt/ramdisk

    Reboot, then check the file structure with

    df -h

    Now, when you use raspistill, direct the output to the ramdisk


    raspistill -n -t 2 -o /mnt/ramdisk/test.jpg

  • 2
    How to take a bunch of fast timelapse pictures

    Let's say you want to use the raspberry pi to take a bunch of fast timelapse pictures (i.e., 1 second between pictures).

    First, you kick off the raspistill (this command will work with SSH too!)

    nohup raspistill -n -t 0 -o /mnt/ramdisk/test.jpg > /dev/null 2>&1 &

    Then, find out the PID with:

    pgrep raspistill

    Then, whenever you want a new picture to be taken, you use the "kill" command to send the message to raspistill to take a picture:

    kill -USR1 12125

    where 12125 is the PID you found using pgrep

    Then, you can rename the pictures or network copy them.  I think raspistill also takes in an incrementing filename.

    Don't forget to kill the raspistill process when you are done!  For example,

    kill 12125

View all instructions

Enjoy this project?



sciencedude1990 wrote 04/03/2021 at 15:32 point

If you want to see what can be done with this setup, head on over to:

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates