Introduction: Raspberry Pi Meteor Station

The goal of this tutorial is for you to build a fully functioning meteor detection video camera which you will be able to use later on for meteor detection and observations. The materials used will be relatively cheap, and can be easily bought in your local tech store. All of the software used in this project is open source, and the project itself is open source.

You can find more info about the project on Hackaday and on Croatian Meteor Network's Github.

Step 1: Requirements and Materials

The materials used are:

  • Raspberry Pi 3 computer
  • Class 10 micro SD card, 32 GB of storage or higher
  • micro SD card adapter
  • 5V power supply for the RPi with the maximum current of at least 2A
  • RPi case with a fan
  • Heatsinks
  • RTC (Real Time Clock) module - DS3231 RTC module
  • EasyCap (chipset UTV007) video digitizer (the other ones have issues on the RPi)
  • Sony Effio 673 CCTV camera and widefield lens (4mm or 6mm)
  • 12V camera power supply
  • Security camera housing
  • Wiring and cables
  • OPTIONAL: HDMI to VGA adapter

Step 2: Setting Up the RPi - Materials

We will first start off with setting up the RPi itself. In order to do that, we will need the following materials:

  • Raspberry Pi 3
  • 3 heat sinks
  • RPi plastic box with fan
  • RTC module
  • SD card

Step 3: Installing Raspbian

Now you will have to install Raspbian, RPi's OS on your micro SD card. You can get Raspbian Jessie (the OS image that works with this current camera setup) on this link: Downloading Raspbian

Also, you must have a micro SD card adapter to install the OS on the card.

In case your SD card isn't brand new, you will have to format the card before installing Raspbian. You can find the guide for installing Raspbian and formatting the SD card on this link: Installing Raspbian

Step 4: Heatsinks & SD Card

We begin by gluing the heat sinks to the CPU and GPU of the board, as well as the back of the GPU. First you have to peel off the blue cover under which is a sticky surface that attaches to the aforementioned units. The peeling-off part can be a little bit tricky, but you can use any sharp object to remove the cover with relative ease.

After that you have to put the SD card you installed Raspbian on in the SD card port on your RPi (for the location of the SD card port, see Step 6.)

Step 5: Assembling the Box and the Fan

After that you can move on to assembling the box your RPi will be in. The box is made of plastic, and is again covered in a foil that comes off easily. We suggest that you start assembling the box from the sides of your RPi board, as then you can easily identify which side is which and how exactly the box must be put together by recognizing the port slots on the sides. Then you will attach the bottom of the box. Make sure that the hole on the bottom side aligns with the GPU.

After that you can attach the top side of the box. The smaller 'legs' which come out on the both sides of the top side must be aligned with small holes on each side of the box. In this point you absolutely must make sure that the top part of the box is over the GPIO pins array. Moving on, you can now attach the RTC module. It can be attached to the first four GPIO pins looking towards the center of the board, as seen in picture. Now finish the job of setting up the hardware of your RPi by just attaching the fan to the top side of the board. The role of the fan, same as of the heat sinks, is to enable optimal cooling and performance of your RPi when it is under a heavy computational load. You will first screw the fan into place by using a small cross screw, with the screws and the fan logo pointing towards the inside of the box. Then the fan cable must be connected to GPIO pins 2 and 3, looking towards the outside of the box. If some of the screws seem to be interfering with the board itself and/or do not allow the box to be fully closed, you can, of course, screw some of them on so that they point towards the outside of the box. If the fan doesn't seem to work, try reconnecting the fan cable to the pins or even soldering the loose cable to the fan.

Step 6: Connecting the Peripherals

In this part of the process, you will turn your RPi board into a usable computer.

For this you will need:

  • OPTIONAL: HDMI to VGA cable
  • mouse
  • keyboard
  • Monitor
  • Monitor and RPi power cables

You will begin with connecting the monitor to your RPi. The video port that RPi uses is HDMI so if you don't have a HDMI cable or monitor (for instance if you have an VGA cable), you must buy a HDMI TO VGA adapter. The HDMI port is located on one of the sides of the RPi single board computer. After that you can connect your keyboard and mouse to the RPi via the USB ports. After setting up your basic input and output devices, you can plug your RPi in a power source by using the adapter and cable that came with your board. It is important to note that the power of the electricity used to run the RPi must be at least 2.5 A.

Step 7: Hardware Setup of the Camera

In this step you will make a hardware setup of your camera and connect it to RPI.

For this you will need the following:

  • EasyCap ADC (analog-digital converter) - chipset UTV007
  • Sony Effio CCTV camera
  • Wiring and cables

The cable setup and configuration is generally up to you. Basically, you need to connect the camera to the power supply with some sort of power cable and the camera signal output to the camera. You can see our configuration on the images above. You will need to connect the camera signal cable to the yellow female cable of the EasyCap ADC. The other cables of the EasyCap will not be needed. Now you can connect your EasyCap to your RPi. Since you probably won't have enough room around the Pi's USB slots area, we suggest that you connect the ADC with a USB extension cable.

WARNING: EasyCap ADC with chipsets STK1160, Empia or Arcmicro will not work. The only chipset supported is UTV007.

Step 8: Testing the Camera

In order to test your configuration, you will have to check the signal transmitted to your RPi.

From now on, you will install all of the software using the terminal, which is a command line user interface. Since you will be using it very often, it is important to note that it can be opened via the keyboard shortcut: Crtl+Alt+T.

First install mplayer via the terminal using this command:

sudo apt-get install mplayer

This is a program for viewing the video from the camera.

Next, you will have to run mplayer. If you have a NTSC camera (North American standard), run this in the terminal:

mplayer tv:// -tv driver=v4l2:device=/dev/video0:input=0:norm=NTSC -vo x11

If you have a PAL camera (Europe), enter the following:

mplayer tv:// -tv driver=v4l2:device=/dev/video0:input=0:norm=PAL -vo x11

If you are typing the commands manually in the Terminal, make sure that the correct character in the "driver=v4l2" part of the previous command is not a one ('1'), but a lowercase L letter ('l'). However, we strongly recommend just copying and pasting the commands using Ctrl+Shift+C for copying and Ctrl+Shift+V for pasting commands inside the Terminal. This makes the setup process much easier and much quicker.

If the camera is connected properly, you will see the video feed from the camera. If not, check the previous steps again and make sure you followed them correctly.

Step 9: Installing All the Necessary Software

Next you will have to install all the necessary software. First, run this:

sudo apt-get update

And upgrade all of the packages:

sudo apt-get upgrade

You can install all of the system libraries by using the following command:

sudo apt-get install git mplayer python-scipy python-matplotlib python2.7 python2.7-dev libblas-dev liblapack-dev at-spi2-core python-matplotlib libopencv-dev python-opencv python-imaging-tk libffi-dev libssl-dev

Since the code used for detecting meteors is written in Python, you also have to install some Python 'modules' which are used in the code. First, start by installing pip (Pip Installs Packages) from the terminal:

sudo pip install -U pip setuptools

You also have to install and update the Numpy package first:

sudo pip install numpy
sudo pip --upgrade numpy 

You will already have pip and Python on your RPi, but you have to upgrade to the latest version. Install all of the Python libraries with the following command:

sudo pip install gitpython Pillow scipy cython astropy pyephem weave paramiko

This will probably take some time.

Step 10: Setting Up the Timezone and RTC Module

Since accurate time plays an important role in meteor observation and detection, you must make sure your RPi keeps the correct time. First, set your timezone to UTC (a standard timezone among astronomers) using the following command:

sudo dpkg-reconfigure tzdata

This will open a GUI which will guide you through the process.
Select 'None of the above' and then 'UTC' and exit.

Next, you will have to set up your RTC module to keep the time even your computer is turned off and offline. For setting up the module you will often be asked to somehow edit a file. Do it with:

sudo nano <file_name>

where you will replace with the actual file address. After you are done, press Crtl+O and Crtl+X.

Also, when you are required to 'comment out' a line of code, do it by placing a # sign on the start of the line in question.

Add the following lines at the end of /boot/config.txt:

dtparam=i2c_arm=on
dtoverlay=i2c-rtc,ds3231

Then reboot your RPi:

sudo reboot

After that remove the fake-hwclock module since you don't need it anymore:

sudo apt-get remove fake-hwclock
sudo update-rc.d hwclock.sh enable
sudo update-rc.d fake-hwclock remove

Next, comment out the lines with -systz in the file /lib/udev/hwclock-set.

Now you have to set the current time by writing the current system time to RTC, and get rid of the redundant NTP daemon:

sudo hwclock -w
sudo apt-get remove ntp
sudo apt-get install ntpdate

More editing! Edit the /etc/rc.local file and add the hwclock command above the line that says exit 0:

sleep 1
hwclock -s
ntpdate-debian

Prevent the automatic setting of the clock to a different value by editing the /etc/default/hwclock file and changing the HWCLOCKACCESS parameter:

HWCLOCKACCESS=no

Now you have to disable the updating of the RTC system from the system clock, since we have already done that, by commenting out the following line in the file/lib/systemd/system/hwclock-save.service file:

ConditionFileIsExecutable=!/usr/sbin/ntpd

Enable the RTC clock by running:

sudo systemctl enable hwclock-save.service

For the RTC time to be updated every 15 minutes, you run this:

crontab -e

and select your favourite text editor.

And at the end of the file add the following line:

*/15 * * * * ntpdate-debian >/dev/null 2>&1

This will update the RTC clock time every 15 minutes via the Internet.

That is it! You're set! This was easy, wasn't it? All you have to do next is to reboot the computer:

sudo reboot

Step 11: Enabling the Watchdog Service

The RPi sometimes unexplicably hangs and freezes. The watchdog service essentially restarts the RPi automatically when its timer registers that the computer hasn't done anything in an arbitrary amount of time.

In order to enable the watchdog service completely, first install the watchdog package by running this in the terminal:

sudo apt-get install watchdog

Then load the service module manually:

sudo modprobe bcm2835_wdt

Add a .config file to automatically load the module and open it with nano editor:

sudo nano /etc/modules-load.d/bcm2835_wdt.conf

Then add this line to the file:

bcm2835_wdt

and then save the file with typing Ctrl+O and then Ctrl+X.

You also have to edit another file at /lib/systemd/system/watchdog.service by running this in the terminal:

sudo nano /lib/systemd/system/watchdog.service

Now add a line to the [Install] section:

[Install]
WantedBy=multi-user.target

Also, one thing that is left to be done is to configure the watchdog service itself. First open the .conf file in the terminal:

sudo nano /etc/watchdog.conf

and then uncomment [that is, remove the hashtag sign in front of it] the line that starts with #watchdog-device. Also uncomment the line that says #max-load-1 = 24.

All that is left is to enable and start the service:

sudo systemctl enable watchdog.service

And then:

sudo systemctl start watchdog.service

Step 12: Getting the Code

The code will have to be downloaded to /home/pi. In order to download the code there, enter the following in the terminal:

cd

You can obtain the code by opening the terminal and running:

git clone "https://github.com/CroatianMeteorNetwork/RMS.git"

Now, in order to compile the downloaded code and install all Python libraries, open the terminal and navigate to the folder where the code is cloned:

cd ~/RMS

And then run:

sudo python setup.py install

Step 13: Setting Up the Configuration File

One of the most important steps is setting up the configuration file. You will have to open the config file and edit it:

sudo nano /home/pi/RMS/.config

The setting-up process basically consists of several parts:

First off, you must set up your station ID, which is found under the [System] title. It has to be a 3 digit number. If your RPi belongs to an astronomical organisation, the station ID will be given to you from that organisation. If not, you can set the ID yourself. Next, you have to set the coordinates of the place where your camera is, including the height of the place of observation. The information regarding the coordinates of any place can be easily obtained via the 'GPS Coordinates' app on Android or the 'GPS Data – Coordinates, Elevation, Speed & Compass' app on iOS.

Next, you must set up the [Capture] part of the configuration file. You only need to change the settings of resolution for your camera and the FPS number (Frames Per Second).

If you have an NTSC camera (North America), you will have a screen resolution of 720 x 480, and your FPS will be 29.97.

If you have a PAL system camera (Europe), you will have a 720 x 576 screen resolution, and your FPS will be 25. You should fill in the data in the .config file according to these parameters.

After you are done with the configuration file setup, press Ctrl+O to save changes to the file and Crtl+X to exit.

Step 14: Setting Up the Camera

For the beginning of the camera setup, you will have to once again launch the mplayer that enables communication to the camera in the terminal.

If you have a NTSC camera, type this in the terminal:

mplayer tv:// -tv driver=v4l2:device=/dev/video0:input=0:norm=NTSC -vo x11

If you live in Europe, run this:

mplayer tv:// -tv driver=v4l2:device=/dev/video0:input=0:norm=PAL -vo x11

Then the mplayer window will launch and you will see exactly what your camera is capturing. Now you have to do a manual setup of the camera. First you have to press the middle 'SET' button on the back of the camera, which will open a menu. You can navigate through it with the buttons around the SET button.

Next, you have to open the RMS/Guides/icx673_settings.txt file either via terminal, or on Github, and just copy the settings given in the file to your camera by navigating through the menu and changing the settings of the camera as described in here:

<p>LENS - MANUAL</p>SHUTTER/AGC - MANUAL (ENTER)
             MODE - SHT+AGC
             SHUTTER - 1/50
             AGC - 18
WHITE BALLANCE - ANTI CR
BACKLIGHT - OFF
PICT ADJUSTMENT (ENTER)
          MIRROR - OFF
          BRIGHTNESS - 0
          CONTRAST - 255
          SHARPNESS - 0
          HUE - 128
          GAIN - 128
          DEFOGG - OFF
ATR - OFF
MOTION DETECTION - OFF
.........
Press NEXT
.........
PRIVACY - OFF
DAY/NIGHT - B/W (OFF,OFF,-,-)
NR (ENTER)
      NR MODE - OFF
      Y LEVEL - -
      C LEVEL - -
CAM ID - OFF
SYNC - INT
LANG - ENG
.........
SAVE ALL
EXIT

These settings will make the camera optimal for night-time detection of meteors.

If the image seems too dark (no stars are visible), you can set the AGC parameter to 24.

If the mplayer display turns green, press Crtl+C in its Terminal window. Open another Terminal window and type the following command two times:

sudo killall mplayer

Step 15: Finally! Running the Software

First, test your setup by running StartCapture for 0.1 hours (6 minutes):

python -m RMS.StartCapture -d 0.1

If everything is OK with the setup, a completely white window should appear. Somewhere in the top of the window there will be a line that says 'Maxpixel'. If the window doesn't launch, or the capturing process doesn't start at all, go to 'Step 16: Troubleshooting'.

You are now ready for the start of capturing data and detecting meteors. All you have to do now is to run the code in the terminal:

python -m RMS.StartCapture

This will start capturing after sunset, and will stop capturing at dawn.

The data will be saved in /home/pi/RMS_data/CapturedFiles, and the files with the meteor detections will be saved /home/pi/RMS_data/ArchivedFiles.

All meteor detections for one night of detection will be stored in a *.tar.gz file in /home/pi/RMS_data/ArchivedFiles.

Step 16: Troubleshooting

GTK issue

Sometimes and on some devices, there appears to be no 'Maxpixel' window that should be rendered before the capture and that there is a warning in the RMS.StartCapture log:

(StartCapture.py:14244): Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported

You will have to install a package using apt-get:

sudo apt-get install pyqt4-dev-tools

In order to fix the error and start capturing, run:

python

And then:

>>> import matplotlib
 >>> matplotlib.matplotlib_fname()

This will print out the location of the matplotlib python library configuration file, e.g.: /usr/local/lib/python2.7/dist-packages/matplotlib-2.0.2-py2.7-linux-armv7l.egg/matplotlib/mpl-data/matplotlibrc

Edit file with by using the nano editor:

sudo nano <file_location>

And when in the file, replace the line that says:

backend      : gtk3agg

with this line:

backend      : Qt4Agg

You also have to uncomment the line:

#backend.qt4 : PyQt4

Save the file and you are done!


Astropy installation has failed

If the astropy python module fails installing and the error message displayed says:

ImportError: No module named _build_utils.apple_accelerate

Then you probably need a newer version of numpy. So go ahead and upgrade numpy to solve the problem:

sudo pip --upgrade numpy

After doing that, you also need to do a complete reinstallation of the python modules and other packages, as described in Step 9.

Step 17: Results

Here are a few meteor images that we got from capturing the meteors and running the previously installed software.