CoSQM v1 - a color hack to the SQM-LE for Light At Night Sensing

User's Manual

Martin Aubé1, Ph.D. (PI)

Mia Caron1

1 Cégep de Sherbrooke, Sherbrooke, Québec, Canada

January 31, 2020

<a rel="license" href=""><img alt="Creative Commons License" style="border-width:0" src=" /></a><br />This work is licensed under a <a rel=license" href="">Creative Commons Attribution-ShareAlike 4.0 International License</a>.


We developped the CoSQM, a portable device which aims to sample the multispectral properties of the artificial light scattered by the atmospheres. We expect that it will become an useful tool to estimate the light pollution and its impact on the environment. CoSQM is a cylinder shaped instrument composed of a filter wheel with five different spectral transmittance in the visible range (clear, red, blue, green and yellow) that is standing on a step motor in front of a Sky Quality Meter. The device comprise a Raspberry pi open source linux computer so that it can be reproduced by anyone. CoSQM also comprise a GPS module and a camera module. The instrument can be operated remotely via the ssh protocol and the data may be accessed via an integrated web server. This device should better show how humankind can affect their own nocturnal environments. Color detection capability is an important improvement over existing non-imaging detectors in the context of the drastic change in the color of light pollution provided by the transition to the LED technology.

Presentation given at the International interdisciplinary workshop on light pollution - Toward the first dark sky reserve in North Africa, Marrakech, Morocco, October 22-26, 2018

Operation modes

Fixed installation

The CoSQM was designed to be used in a permanent installation mode. When the night twilight appear, the instrument perform multiple scand of the filterwheel in order to find the center position of the filters. This procedure is repeated every day to be sure that the optical alignment is optimal in case of an abnormal shutdown of the system (e.g. a power failure). Note that unclean shutdown of the system may endup in file system corruption. In such a case the system will fail to restard properly and then will need to be serviced. As a routine step, the CoSQM is restarted around noon local time. This is done automatically by the crond service (see Crontab section below). That time should be set correctly according to the region of installation of the instrument to be sure that it falls during day time around noon. Note that the time zone of any CoSQM must be set to GMT. This is why that reboot time should be changed according to your installation site.

Ponctual experiment

As said, the CoSQM was not designed to be used that way. But by knowing its behaviour, it is possible to "hack" a bit the system to let it believe that it is an fixed installation. All we have to do is to simulate a fake twilight. This can be done by using a diffuse light with the proper light intensity in front of the CoSQM window. Optimally, this light should be white. A phone in flashlight mode may be an appropriate system. But you need to put a diffuser over the CoSQM window before lighting it.

  1. Put the diffuser over the CoSQM window
  2. Power up the CoSQM
  3. Open the flash light of the phone from a distant place
  4. Lightup the diffuser while slowly approaching the CoSQM (should take at least YYYY minutes).



The system consists of the following items, but it would certainly be adapted to a different list of items with minor corrections.

Item # Component name Number Picture
1 Raspberry pi model 3 B+ 1
2 SanDisk Ultra 32GB microSDHC UHS-I Card 1
3 5mp wide-angle 65 degrees raspberry Camera Module 1
4 TP-link ethernet switch model TL-SF1005D 1
5 Homyl AC-DC 100–264 V to 5 V 6 A 25 W Buck Converter Step Down module 1
6 USB GPS tratux Vk-162 Remote Mount USB GPS (U-blox) 1
Real time clock breakout DS3231
7 SQM-LE board from Unihedron 1
8 Neewer 4PCS Standard 1.25 inches Color Filter Set for Telescope Eyepiece: Red Yellow Green Blue 1
9 Pololu Universal Aluminum 5mm Mounting Hub (4-40) - to attach the motor to the filter wheel 1
10 Longruner 28BYJ-48 – 5V Stepper motor 1
11 Uln2003 stepper motor driver Board for arduino 1
12 Cole-Parmer Watch Glass, 50 mm - for the main window 1
13 Cole-Parmer Watch Glass, 25 mm - for the camera window 1
14 micro usb male soldering connector - to power the raspbery pi 1
15 Quick release thumb screw with 1/4"-20 Male Female Thread 1
16 M25 uxcel gland 1
17 1 FT non booted ethernet cable 2
18 3 FT non booted ethernet cable 1
19 30.4 cm threaded rod 3/16 - 32 (6-32) 2
20 PVC 4 inches tubing cut to 32cm long 1
21 Clear silicone glue - for gluing the watch glasses -
22 Mat black spray paint - to apply inside the tube -
23 Super glue - to lock the quick release thumb screw -
24 6-32 lock nuts 4
25 6-32 standard nuts 2
26 6-32 lock washer 2
27 M3 8mm self taping screws - to attach the various boards to the printed supports 15
28 1/4" metal washer - to attach the quick release thumb screw to the bottom lid 1
29 1/4-20 lock nut - to attach the quick release thumb wcrew to the bottom lid 1
30 Stainless steel 1/2 in metal screw - to secure the tube on bottom lid 2
31 4-40 7/16 in screw - to attach the filterwheel to the hub 4
32 4 in tie wraps - to attach the various board 5

3D printed components

The printed parts needs a total filament mass of 290 grams and take about 2 days to print on a Prusa I3 mk2 printer. We recommend the use of PLA material in black color. Black is better to attenuate the light inside the instrument.

You can find the 3D print link of each piece below the image of each one.

Overall view

Filter wheel and filters disposition

Filter wheel stl file


Top lidBottom lid
Top lid stl fileBottom lid stl file

Camera stand

Camera stand stl file

Light shade

Light shade stl file

Top support

Raspberry pi sideSQM board side
Top support v1 stl fileTop support v2 stl file

Bottom support

Network switch sidePower converter module side
Bottom support stl file

Optical properties

Spectral sensitivities of the different channels

Angular response of SQM in a linear scale

The angular response is determined using figure 4 of the report on Sky Quality Meter of Pierantonio Cinzano (2007)

Power consumption

The CoSQM typically drive 5 W to operate.

Size and weight

  • Size: ~11cm diameter and 33.5 cm long
  • Mass: 1.4 kg


Pinout informations and GPIO pinout map

RPI GPIO pinout map
RPI microUSB power pinout

Stepper motor pin out

The pin numbers below refers to figure "RPI GPIO pinout map".

  • ULN2803 pin 1 connects to Pin 29
  • ULN2803 pin 2 connects to Pin 31
  • ULN2803 pin 3 connects to Pin 32
  • ULN2803 pin 4 connects to Pin 33

The 5V power is provided from the power supply of the CoSQM.

External documentation

Real time clock wiring

We are using the DS3231 RTC module to keep the date and time after powering off the system.

The RTC pins should follow the following configuration

The pin numbers below refers to figure "RPI GPIO pinout map".

  • VCC connects to Pin 1
  • SDA connects to Pin 3
  • SCL connects to Pin 5
  • GND connects to Pin 6


A red LED is installed under the CoSQM, next to the reboot/shutdown button. This LED will blink at some point to indicate the state of the system. Of course it will not blink during measurement and at least no less than 20sec to the next measurement to get rid of any contamination of the LED to the measurements. Below are the various signals given by the LED.

Event Signal
Startup of the CoSQM 5s on
Waiting for twilight for filter alignment 19s on, 1s off (loop until the twilight)
Finding the center of a filter 140 approx 1s blink
Identifying the clear filter position 45 approx 3s blink
Beginning of measurements 10 fast blink
End of a set of 5 filters measurement 3 fast blink

LED wiring

The wiring of the LED is very simple. First it is required to solder a 330 Ohm resistor to the ground led of the LED (the shortest leg). Then the other end of the resistor must be connected to the ground of the raspberry pi (pin 9). The other lef of the LED have to be connected to the GPIO 18 (pin 12).

Shutdown button

The shutdown button should follow the following configuration

The pin numbers below refers to figure "RPI GPIO pinout map".

  • 1 wire connects to Pin 13 (GPIO 27)
  • the other wire connects to the ground (GND)

The RPI will reboot if the button is held for more than two seconds but fewer than five seconds and it will shut down if the button is held for more than five seconds.


Order of parts on the threaded rod - from bottom up

Please follow this order instead of one showed in the animation below because that the order of some washers/nuts has been changed since the making of this animation.

  1. lock nut
  2. washer
  3. bottom lid
  4. washer
  5. lock washer
  6. nut
  7. bottom support
  8. top support
  9. light shade
  10. motor
  11. camera support
  12. washer
  13. lock washer
  14. nut

Schematic of the CoSQM parts

Animation showing the placement of the different components of the CoSQM Download the assembly video

Additional details - All components

  • To make sure that the lights inside the CoSQM will not affect on the measurements, hide the light from the camera with a black adhesive tape and paint a single layer of black on all the others LEDs.
  • Be sure to clean the 3D printed components by gently sanding the surface and the holes.
  • Attach the raspberry pi, the buck converter step down module and the SQM-LE board to their printed supports by using M3 8mm self taping screws.
  • Attach the TP-link ethernet switch and the stepper motor driver Board for arduino to the printed supports by using 4in tie wraps.

Additional details - Top lid

  • Apply a clear silicone glue on the outline of the windows on the top lid and place the watch glass on them.
  • Perform a leak test of the windows by filling the top lid upside down with water.

Additional details - Bottom lid

Pre-drill two holes on each side of the bottom lid with a 3/32 in drill bit. Do the same with the 4 in PVC tubing with a 9/64 in drill bit. Once all the assembly on the threaded rods is done, insert the PVC tubing over and screw two 1/2 in stainless steel metal screw in the holes.

Additional details - Welds

Perform the welds in the following order :

  • 5V (red) wire
    • From the buck converter step down module to the stepper motor driver Board for arduino.
    • 4 cm wire from the buck converter step down module to the raspberry pi.
    • From the buck converter step down module to the TP-link ethernet switch.
    • From the buck converter step down module to the SQM-LE board.
  • Do the same for the ground (black) wire.

Additional details - Ethernet wire connections

Make the connections in the following order :

  • 1 Ft non booted ethernet cable from the raspberry pi to the TP-link ethernet switch.
  • 1 Ft non booted ethernet cable from the SQM-LE board to the TP-link ethernet switch.
  • 3 Ft non booted ethernet cable from the buck converter step down module to your pc network interface.

Setting up the CoSQM for measurements

Install the instrument to point the relevant part of the sky. Normally the zenith is the direction that must be prefered. Be sure that the sky is clear from blocking structure to allow the GPS to connect correctly. One must also put some near horizon obstacles to block the direct light from impotant sources near horizon. If such source hit the optical window, there is a possibility for that light to interfere with the light coming from the sky after multiple reflection into the window. Even if the CoSQM comprise a GPS, it is not designed to be used in a roadrunner mode. The problem may arise when the system is looking if the filterwheel is correctly positionned. If the light level vary during that process, an offset in the position of the filter wheel may arise and the quality of the measurements may be affected accordingly.

Starting the CoSQM

CoSQM is trivial to startup. All you have to do is to plug the power connector to the grid. The RPI will then boot and will automatically startup the observation script. The data will be stored into the relevant /data directory accessible to the web server. If the ethernet cable is connected to a local network with 192.168.0.* root, you will be able to access the instrument remotely for any station in that network. You can both connect via ssh or http.

Downloading the data

The data are stored into the micro SD card of the Raspberry pi (RPI). In order to access the data, an apache 2 web server is configured on the RPI. You can browse the data simply from a webpage. You first need to plug the network cable a router in the subnet 192.168.0,* or simply to your pc network interface and then configure your pc IPV4 connexion properties. You need to set it to manual configuration mode then set the IP address, netmask and route/gateway according to the following table.

IP address

Once configured, restart your interface, open a web browser and enter the following address in the address bar.

You should then see a directory tree and will be able to visualize the text data along with the camera images. The data is organized by year and month.

You can also download all the data by using the following command on a linux command line:

The data will be download and stored in a local directory named

Data format and size

The data is structured in the following way for each equivalent column number:

  1. Date
  2. GMT time
  3. Latitude
  4. Longitude
  5. Elevation
  6. SQM temperature (C)
  7. Integration time (s)
  8. Clear SQM reading (mag arcsec-2)
  9. Red SQM reading (mag arcsec-2)
  10. Green SQM reading (mag arcsec-2)
  11. Blue SQM reading (mag arcsec-2)
  12. Yellow SQM reading (mag arcsec-2)
  13. Clear radiance (W m-2 sr-1)
  14. Red radiance (W m-2 sr-1)
  15. Green radiance (W m-2 sr-1)
  16. Blue radiance (W m-2 sr-1)
  17. Yellow radiance (W m-2 sr-1)

The radiances are calculated using equation 5 of Sánchez de Miguel et al. (2017)1 .

1Sánchez de Miguel, A., Aubé, M., Zamorano, J., Kocifaj, M., Roby, J., & Tapia, C. (2017). Sky Quality Meter measurements in a colour-changing world. Monthly Notices of the Royal Astronomical Society, 467(3), 2966-2979.

The average size of a complete day of measurements is about 38 kB and the images for the same day period is 4.3 MB. Considering the available memory on the 32 GB micro SD card, it is possible to run the system without emptying the card during about 13 years.

Shutdown of the CoSQM

A power button is provided at the bottom of the instrument. Please never power off the instrument by unplugging directly the power cable. Sometimes, doing so may result in data corruption problems on the RPI micro-SD card. When you push the power button, a signal is sent to the RPI for a safe shutdown. You have to press the button for at least 5 seconds for a shutdown to be initiated. Please wait about a minute after pushing the power button before unplugging the power cable.

Zoom in pictures

Physical installation