Raspberry Pi Astro Cam





Introduction: Raspberry Pi Astro Cam

About: Executive Director of ExplorTech, a 501(c)3 nonprofit serving rural school districts, families, and students who have limited access to technology education.

I first attempted astrophotography more than 20 years ago. CCD astro cams were still pricey and low resolution, so many of us still used mechanical 35mm cameras attached to the back of our scopes. Despite having as much experience in photography as in amateur astronomy, I produced very little to show for all my effort. Fast-forward to 2016, and how technology has changed!

I recently renewed my interest in backyard astronomy when I purchased a Meade ETX-80 computer-driven scope. Computerized telescopes were also expensive in the 90's, so I never had one, and I really like my new scope. It has provisions to attach a DSLR to its back, but doing so blocks the movement of the scope into the opening of the mount, making viewing any object near the zenith impossible. I recently saw a YouTube video of the Moon, and another of Jupiter made with the new Raspberry Pi Camera Module V2. It is an inexpensive 8 megapixel CCD capable of taking 3280 x 2464 pixel static images.

The moon image above not a stock image, it is the actual first image taken with my new Astro Cam. And it is not even a high-resolution image - it is only 800x480 pixels. I discovered after taking my first shots that you must set the resolution in the Python code to get full-quality images.

Coming up, your first step will be to remove the original lens from the Pi Camera.

Step 1: Remove the Lens From the Pi Cam

The Pi Camera is a small circuit board with a mounted CCD (charge-coupled device) sensor. The CCD forms a digital image when light is focused onto its surface. Since your telescope's objective will project the image, the small lens assembly screwed into a plastic housing on the Pi Cam is in the way and must be removed. Use something very small to grab the lens unit, taking advantage of the small slots on its edge, and unscrew it (counterclockwise). I used a very small set of needle-nose pliers, but some have used tools meant for removing lenses. The instructions I followed said you have to "pop" loose some glue holding it place, but my Pi Camera lens released without any such resistance. Once it releases, just turn it counterclockwise until it completely unscrews and pops out.

The photo also shows the completed case for the camera. It was made from one of the little plastic cases that hold new Micro SD cards and an included SD adapter. We purchase a lot of Micro SD cards for our Raspberry Pi's, and most chips come with this same clear-plastic case shown here under the camera cable.

You also need an extra-long cable to replace the short one that comes with the Pi Camera.

Step 2: Cut and Paint the Case

It is just a nice coincidence that the little circuit board with the camera fits perfectly into the raised insets that usually hold the large SD adapter. Leave this as-is, but cut away the small insets for the Micro SD and anything else that might interfere with the cable as it exits the housing. You also have to make a slot at the end for the cable; cut the snap-lock piece off, and make sure the slot is wide enough for the cable to exit, but no wider, so the cable and camera can't wiggle.

Then cut a hole just big enough for the black plastic barrel around the lens to poke through the case. The photo shows the hole, and the case has been painted flat black inside and out (but don't paint it just yet).

Step 3: Glue on a Piece of 1.25 Inch O.D. PVC Drain Pipe

The camera needs a 1 1/4 inch barrel to slide into the telescope eyepiece holder. Thin white 1 1/4 inch PVC drain pipe pieces make an excellent barrel; they are the perfect size to fit snugly just like your eyepiece. One example is called a "drain pipe extension," found in the area of your hardware store that has bathroom and kitchen plumbing parts like drain pipes and toilet accessories. Cut it short enough to go all the way into the eyepiece barrel of your telescope.

Use epoxy, epoxy putty, or some other strong glue, but realize that it is unlikely that it will really adhere to the clear plastic case. Use plenty to form fillets both inside and outside to hold it place, then mask off the rest of the outside only of the white PVC pipe, and paint it all flat black inside and out. The inside of the pipe must be flat black.

Step 4: Connect the Cable and Snap the Camera Into Place

Remove the short cable that came with the camera and attach the new long cable. Place the camera into the recess in the case with the black plastic barrel pushing through the small hole. Close the case and fasten it with a small zip-tie. Insert the other end of the cable into the Raspberry PI's display port.

Our photo shows a Raspberry Pi attached to only the flat bottom piece of a Raspberry Pi case. Two flat phone charging "Power Bank" batteries have been affixed using double-sided foam tape. One power bank is enough, but two batteries ensure extra long photo periods.

Step 5: Attach a Display

I love this little 5 inch HDMI display. It inserts into the GPIO header block on the Pi, has a double-HDMI connector that pushes into both the display and the Pi at the same time, and has its own 5V power input so I can connect two batteries at once (one to the PI and one to the display).

Step 6: Add a Secure Holder for the Raspberry Pi and Display Unit

I used a cell phone holder of the type typically used in vehicles. I drilled a hole through its base and ran a long bolt, large washer, and wingnut to hold it onto the tripod.

I also run the Pi with a mini Bluetooth keyboard with integrated touch pad. It is really cool that I can take photos without touching the telescope at all!

Step 7: The Software

Here is a photo of the camera, held together by a zip tie, inserted into the eyepiece holder. The camera's sensor is a little further out than the focal plane of my eyepieces, so I have to refocus a bit once it is inserted.

There are only a few software options for using the camera. I wrote a simple Python script. It creates a menu that can change resolution, show a preview, snap one photo, snap a sequence of five photos, and exit. This is just an experimental piece of software, something more functional and user-friendly would be nice.

camera = PiCamera()    
num=0 while True: print('\n' * 50) print_menu() choice = input('Enter a command: ') if choice == "p": camera.start_preview() elif choice == "s": camera.stop_preview() elif choice == "1": camera.start_preview() sleep(1) camera.capture('/home/pi/Desktop/Image#%s.jpg' % num) num = num + 1; camera.stop_preview() elif choice == "5": camera.start_preview() sleep(1) for i in range(5): camera.capture('/home/pi/Desktop/Imageseries#%s.jpg' % num) num = num + 1 sleep(1) camera.stop_preview() elif choice == "h": camera.resolution = (3240,2464) elif choice == "m": camera.resolution = (1640,1232) elif choice == "l": camera.resolution = (800, 480) elif choice == "q": break

Step 8: More Photos

As we continue to polish the design and software, and use the Astro Cam, we'll post new images and code on this page.

Telescope: Meade ETX-80, 80mm refractor telescope.

Featured photos:

    1. Mars, Oct. 15, 2016. Mars has been going away since late last spring, yet I was able to get some detail only visible in digitally enhanced images. Here is the way it looked in the eyepiece, just a white oval showing that the sun is shining on it from an angle. By the way, small objects are much bigger and easier to see on the display than through the eyepiece, since the field of view in the camera (the size of the small patch of sky visible) is very small. It is equivalent to using a very high magnification eyepiece, and it why we can't get the entire moon in view at once.
    2. This is the digitally enhance view. I compared for different shots, each enhanced the same way, so make sure the dark regions are not just artifacts of the camera. Several distinct regions appear in the about the same place in each image, and the very bright rim and red color of the rim at the shadow side of the planet matches what you see in images from much bigger telescopes.



      • Clocks Contest

        Clocks Contest
      • Creative Misuse Contest

        Creative Misuse Contest
      • Water Contest

        Water Contest

      39 Discussions

      I finally got my camera hooked up to my scope yesterday. I was able to get a clear image in daylight but when i tried to capture jupiter I just had a black screen. Are you doing anything to set the camera controls - iso, exposure time etc?

      I am trying to understand why your images of Mars look so degraded vs the one of the Moon? Is that really what it looked like on the screen? It looks very overexposed. Have you tried to reduce exposure?

      2 replies

      Mars is tiny compared to the moon. The images were processed to digitally enhance and bring out color patterns, otherwise it is just a fuzzy white dot when viewed with a small telescope.

      Awesome work Doc! I hope you test it on a larger scope and show us the image you get of Mars, Jupiter or Saturn.

      Great project! However, I'm confused about how this camera is used without an eyepiece. I have been able to run a Pi with the motion package, mount it with an adapter for a smartphone and stream pictures to my local network. In this setup, I'm using an eyepiece. If I use the camera without its lens and without an eyepiece, what is my magnification? Can you recommend some sites that explain these optics issues? I have an 6" Orion reflector.

      2 replies

      This is called "prime focus" astrophotography and it works because the lens you remove from the camera board is being replaced by the telescope.


      calculator below will calculate the prime focus magnification...


      Using his scope focal length of 400mm it would be 87x with the new raspi cam.

      To contrast I've got an etx125 at 1900mm and the old raspi camera, my magnification will be 414x once I finish building mine.

      That's a good question, the effective magnification. Very high, I know that. But the situation is different, because you can view the image at different sizes and distances, I'm not sure it even applies. I have not researched these issues.

      I am still confused on how this is used without an eyepiece, at least to produce images with any significant magnification. Think it would work to make a fitting out of the PVC tube you used that would fit OVER a chosen eyepiece rather than being inserted without one?

      3 replies

      This is called "prime focus" astrophotography and it works because the lens you remove from the camera board is being replaced by the telescope.

      Sorry, I thought I had responded earlier. I photographed the moon, lower magnification is fine. I'm sure you use it with an eyepiece as well, but the mechanical design would be different.

      I really never tried this. I was happy with the magnification I get with no eyepiece. There is enough resolution to magnify even a planet to a degree. I'd be interested to know how well it works with an eyepiece.

      One correction. This camera is built from a Sony IMX219, which is a CMOS Image Sensor (CIS), not a CCD.

      4 replies

      Thanks! Never heard of a CIS, I'll have to check into this.

      You're not alone. Most people have no idea that the vast majority of image sensors on the market are CIS, not CCD. CIS leverages the standardized CMOS manufacturing process, which means that it is a lot less expensive to produce in mass production.

      I remember about 15 or so years ago CCDs had issues staying on for long periods of times because the pixels/cells would spill over and make the images hazy. Is that an issue with CIS devices?

      It certainly can be. It is called "blooming" in the industry. There are a number of techniques ("anti-blooming", deep trench isolation, etc) to reduce this effect that are built into image sensors, but it is impossible to eliminate completely.


      1 year ago

      Thank you for sharing! Great find on the micro SD case matching the pi camera board. I was trying to do something similar with my pi and noir camera, but I must say your solution is a much simpler approach than what i was trying. I was constructing a mount to go over the eyepiece, similar to holding a phone camera over it. I've seen some commercial products for mounting phones on telescopes, but at outrageous prices. Makes we wish I had access to a 3D printer.

      I've got all the parts already but for the epoxy... but I could try the 'ol super glue baking soda trick rather than wait for my next run to the store. I might also try connecting my AmScope (microscope camera) as well, but it has a much smaller diameter so I'll have to make a holder for that as well to work with the telescope. You made this look so simple; I'm going to abandon my other efforts for now and build this one since I have everything on hand and it it looks like it should be a quick build. Thanks so much! :)

      It's still boggling my mind how much progress since the '90s was waiting for display and sensor tech advancement/accessibility. Great way to tap into it DIY-style, grats! Still new to the pi cam v2 here, but seems like FOV is still somewhat glued to resolution unfortunately...at least in the python API. Looks like you're compensating well w/the telescope's adjustable lenses though.

      I'm sorry for my noobness but do you still need to have a telescope to do this??

      1 reply

      The lens has been removed, so some kind of objective lens is needed. Any lens projecting an image will work. Telescopes are best for astrophotography, I'd like to experiment with a microscope as well.