Thursday, October 12, 2017

Raspberry Pi Skycam w/ NoIR V2 Camera and Light Pollution Filter

NASA seems to assign any scientific instrument a contrived acronym. This camera detects rocks from space. Therefore, may I present WHAMMO - the Wadsworth Hillbilly Automated Meteor/Meterology Observatory.

Update: I have a working detection script running on the Linux box storing the images - full article is here.


I am interested in building a sky camera for capturing meteors, and also for checking sky conditions. I had a Raspberry Pi and camera. Initial tests were done with a normal V1 camera, which is limited to a 6 second exposure. I switched to a No-IR V2 camera, which allows 10 second exposures and doesn't have an infrared filter. The V2 camera produced much better results.

I added a simple cell phone medium-wide angle lens and found through experimentation that a light pollution filter normally used for observing improved the contrast considerably.

The camera is weather resistant and mounts a shared directory on a network computer, rather than writing to the Pi's flash card. This is to improve reliability, since the Pi's flash would wear fairly rapidly due to the high rate of writes during capture.

This post documents the development of this system and outlines next steps.

Example Video

The camera captures 10 second frames all night long. The frames can easily be stitched together with ffmpeg into a video. The command line I used was:

ffmpeg -thread_queue_size 512 -r 30 -f image2 -i sky_%04d.jpg -vcodec libx264 -preset slow -crf 22 -profile:v baseline -pix_fmt yuv420p test.mp4

The video is best viewed in full resolution rather than a small window - the stars are single pixels, in many cases. The MP4 is available for download here or you can follow the link below to Vimeo and full-screen it there.

Raspberry Pi Skycam w/ NOIR v2 Camera and Light Pollution Filter from Jason Bowling on Vimeo.

The camera was in my back yard in Wadsworth, a bright orange band on the dark sky finder map.

Still Frame + Star Chart

A full resolution copy of this image is here

The image is the result of stacking a set of 25 images in Deep Sky Stacker with the default settings. A single raw frame is available for comparison here.

You can then take that image and do a simple level adjustment to improve contrast - at that point there are far more stars in the image that I can see by eye alone. The Pleides are easily resolved into multiple stars in the image, and it's only visible at my house with some effort.

Full resolution version of the stacked and level-adjusted image is here.

V1 vs V2 camera

I tried the V1 camera first, since I had one, but wasn't very happy with the results. I found the results with the V2 NoIR camera to be much better in terms of sensitivity and noise. The V1 did work reasonably well with the saturation increased. Example video from the V1 camera is here.

Wide Lens

I used a cell phone lens kit similar to this one - the exact kit is no longer available on Amazon. I used the medium-wide lens - the widest resulted in significant distortion and I have too many trees in the back yard to make much use of a wider view anyway. I just tacked the lens to the 3d printed camera case with hot glue, since it's easily removable. I considered cyanoacrylate glue but didn't want to fog the lens.

Capture method

The command below captures the images in timelapse mode, at a resolution selected because it uses 2x2 binning to effectively increase pixel size. This improves low light sensitivity and signal to noise ratio.

#1640x1232 is 2x2 binning mode with v2 cam

mkdir /home/pi/storage/"$(date +"%d-%m-%Y")"

#note: this command is all one line
raspistill -o /home/pi/storage/"$(date +"%d-%m-%Y")"/sky_%04d.jpg -t 500000000 -tl 0 -ss 9900000 -ISO 800 -bm --nopreview -w 1640 -h 1232 &

Light pollution filter 

I found that the addition of a light pollution filter significantly improved contrast for images taken from my home. The filter works reasonably well for visual observation, but the improvement is much more noticeable with a photograph. A comparison is given below. This image is best viewed at full resolution. 

The mount was just a disk of foam board friction fit to the wide angle lens body. The filter is again secured to the mount with hot glue.

The filter does cause a bit of vignetting. I think it's worth it for my purposes.

Mounting A Filesystem On Another Computer

To avoid wear and tear on the flash, and since the Pi wouldn't be up to the image processing tasks I had in mind, I chose to use SSHFS to mount a directory on a Linux server in the house over WiFi.

The command below, all one line, has worked well for me. Without the included options, I occasionally had the mount point drop out between writes sometimes - it has been very reliable since the keep-alive options were included.

sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 jbowling@ storage

If you prefer, you can also mount a share on a Windows computer.

Black Out Those LEDS...

I turned off the board LEDS in software, and blacked out the LED on my WiFi adapter with primer to avoid leaking light up into the dome.

Mechanical Construction

I chose a 6x6x4 junction box from Home Depot (marked Item 10030 on the display case). It doesn't have an IP rating I could find, but has a nice gasket and I've found it held up well under the garden hose.

I chose this acrylic dome and this gasket material.

I drilled holes to mount the Pi on standoffs, and also a radial pattern of larger holes in order to dump heat from the box up into the dome, to reduce dew. 5W isn't a lot of heat, but it might as well get used. A slot is also cut for the camera cable.

I traced the dome with an ink pen and cut it out with scissors, with a final trim by a razor hobby knife.

A shingle nail worked well to punch holes to pass the screws through the gasket. This passed several tests with the garden hose. I am going to use cable glands to waterproof the power line when done.  This design has not been tested long term in heavy weather. 


So far, the camera has just been powered from a 12V jump start battery's USB output. I considered several options for when the camera is mounted permanently.

I considered running an AC power cord into the box and using a standard USB power block to power it, but then I have 110AC in my junction box, and that's not something I want. I decided the way to go was to run 12V over a an extension cord with the ends removed - that way it's nice, heavy double insulated wire being fed by an approved 12V power supply kept nice and dry in the garage. That also gives me spare capacity to install some resistors to reduce ice and dew on the dome, if I choose to. I can install an appropriate low amperate fuse in the line too, in case some water does make it's way in.

If you happen to have a Power Over Ethernet (POE) switch, there are converters that can power the Pi from POE. In my case, that wasn't economical. 

Next Steps

1) The next interesting part will be software to sift through the many thousands of frames and find the meteors and airplanes. That will be a neat challenge.

2) Dew heater. I'll probably add a small network of power resistors under the dome to improve resistance to dew and to melt light ice and snow. The existing setup usually doesn't dew up, but I've had it happen once.


  1. Awesome work!...Love the camera setup!

  2. I'm intrigued you can get a 10 second exposure on these cameras !

    Great work. I think I'll have to try it.

  3. Great build Jason. Are you having any issues with fogging or condensation under the dome?

  4. Nothing under the dome - just dew on the outside. Going to work on that resistor network soon... :-)

  5. A mischance in the long run will happen, it will be a mayday situation when an automaton will kiss a solid land hard. کوادکوپتر

  6. This comment has been removed by a blog administrator.

  7. جالبه بدونیم بیشتر کواد کوپترها از باتری لیتیوم پلیمر استفاده می کنند. 

  8. The article was very useful, thanks for explaining it so well. خرید کوادکوپتر

  9. Using an old PI 2B with a new Rasbian release and I get "mmal: main: Error opening output file: "

    I have tried logging in as root, using chmod u+x. I cannot clear the error. The Pi locks up and I lines and lines of the same message. ^C does not stop it. Ctrl-Alt-Del reboots the PI and then I have to reboot it again. The only fix is to power cycle the Pi.

    WHAT am I doing wrong here please?