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

User's Manual

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

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


June 17, 2021

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

1.  Abstract

The CoSQM is a portable device which aims to sample the multispectral properties of the artificial light scattered by the atmosphere. It is a convenient tool to estimate light pollution and its impact on the environment. CoSQM is an 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 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

2.  Operation mode

The CoSQM was designed to be used in a permanent installation mode. Note that unclean shutdown of the system may end-up in file system corruption. In such a case the system may fail to restart 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.

3.  Hardware

3.1  Components

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

Component name Number Picture
Raspberry pi model 4 B 2Gb
(model 3 B+ can also be used)
SanDisk Ultra 32GB microSDHC UHS-I Card 1
Ultra fit 32GB Flash Drive 1
Raspberry Camera Module HQ with 6mm lens 1
TP-link ethernet switch model TL-SF1005D 1
SQM-LE board from Unihedron 1
Neewer 4PCS Standard 1.25 inches Color Filter Set for Telescope Eyepiece: Red Yellow Green Blue 1
5mm Flange Coupling connector - to attach the motor to the filter wheel 1
Longruner NEMA17 Stepper motor 1
40mm heatsink 1
L298N stepper motor driver Board 1
Dual 5V & 12V 10Amp power supply 1
Cole-Parmer Watch Glass, 50 mm - for the main window 2
Raspberry Pi UPS HAT 1
Optoswitch LM393 1
1 FT non booted ethernet cable 2
NBF-32314 BUD industries enclosure 1
NBX-32414-PL BUD industries panel 1
Motherboard switch 1
Red LED 1
Prototype Raspberry hat 1
male 2.1mm x 5.5mm connectors 1
female 2.1mm x 5.5mm connectors 1
Clear silicone glue - for gluing the watch glasses and window supports -
black nail varnish to attenuate the components LEDs -
330 ohm resistor 1
14.3cm x 17.3cm x 1mm thick aluminum plate 1
M3 8mm self taping screws - to attach the window supports 8
8 mm M3 screws for the stepper fixation 4
M3 washer for the stepper fixation 4
M3 lock washer for the stepper fixation 8
M3 17mm brass post for the stepper fixation 4
M3 8mm conical head self tap screws to attach the plate to the main support. 6
Brass M1.5 12mm posts to attach the raspberry and the stepper driver board to the main support 6
Brass M1.5 10mm posts to attach ptototyping hat to the UPS hat. 4

3.2  Optional components

Component name Number Picture
USB GPS tratux Vk-162 Remote Mount USB GPS (U-blox) 1
SmallRig Multi-Function Mounting Plate 1

3.3  Enclosure

We use the Bud industries NEMA box part number NBF-32314 with the associated prototype plate NBX-32914-PL. On the lid, we drill two 1 1/2 inch holes according to the picture below. Four small 1/8 inch holes need to be drilled around each large holes to attach the window supports on the top lid from the inside with the M3 self taping screws. If a fixation plate have to be used, seven 5/16 inch holes should be drilled on the bottom of the box. Some holes also need to be drilled on the side for installing the connector gland, the reboot switch and the LED.

3.4  3D printed components

There are only 5 printed parts. 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 component below the image of each one.

Main support

Main support stl file

Filter wheel

Filter wheel stl file

Windows supports (2 copies)

Window support stl file

Position sensor support

Position sensor stl file

4.  Optical properties

4.1  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)

5.  Power consumption

The CoSQM typically drive in average 12 W to operate. But there may be peaks of current higher than 5A (>25W). We found that a 5A power supply regularly fail to provide the required current. This appear to be related to the activation of the stepper motor. For that reason it is recommended to use a higher power supply capacity. We suggest a 10A power supply. It is highly recommended to set the power voltage to 5.45 V so that when the motor will start, the power will remain sufficient for the RPI. The little lightning icon should disappear when the voltage is correctly set. But take care of not going above 5.5 V.

6.  Size and weight

  • Size: approx 20 cm x 20 cm x 15 cm
  • Mass: 1.06 kg

7.  Wiring

7.1  Pinout informations and GPIO pinout map

Electric sketch

7.2  USB-C power

To benefit of the UPS hat protection, you need to power the RPI through the USB-C connector. If you want you can solder your power wires directly to the RPI PCB. TP1 = 5v and TP7 = GND. In such case, use at least AWG20 stranded wire (not solid core wire). It can also be a good idea to sue hot glue to the wires after soldering to serve as stress relief.

7.3  LED

A red LED is installed near the connectors of the CoSQM. 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 20 sec 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)
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 pin of the LED (the shortest pin). Then the other end of the resistor must be connected to the ground of the raspberry pi. The other pin of the LED have to be connected to the GPIO 13 (pin 33).

7.4  Shutdown/reboot button

The shutdown button should follow the following configuration

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

  • 1 wire connects to Pin 29 (GPIO 05)
  • 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.

8.  Assembly

8.1  Assembling steps

  1. Screw the SQM-LE board on the main support with 3 M3 8mm self tap screws
  2. Screw the camera on the main support with a 1/2-20 3/8in screw
  3. Put the 6mm lens on the camera
  4. Open the lens aperture to the maximum
  5. Let the camera cable cross the main support by the dedicated slot
  6. Screw the four post with four washers and four lock washers on the stepper
  7. Screw the metal plate on the four posts using four 8mm M3 screws and four lock washers
  8. Screw the metal plate on the main support with four M3 8mm self tap screws
  9. Screw the motor flange on the filter wheel with four M2 10mm self tap screws
  10. Screw the flange on the stepper shaft and secure the two screws
  11. Glue the color filters into onto the filter wheel. The hole close to the position encoding slut remains empty. Then as seen from the top the filter order clockwise is Red, Green, Blue, Yellow.
  12. Attach the RPI with two 12mm brass post provided with the UPS and with two 8mm M3 self tap screws
  13. In progress

8.2  Main support

An 1mm thick aluminum plate have to be screwed to the top of the main support with 4 self tap M3 screws. That plate is supporting the stepper and block possible light contamination coming from underneath components. This plate also assure a certain level of heat dissipation protecting the support from over heating. The image below show the plate when installed on the main support. The small holes are 9/64in in diameter and the two large holes are 7/8in in diameter.

On that supporting plate, the right angle camera support have to be screwed with 1/4-20 screw. We suggest to use the same thickness as for the plate. The two holes may have a diameter of 33/64in.

8.3  All components

  • To make sure that the lights inside the CoSQM will not affect on the measurements, hide the light from the camera with duct seal or electrical compound.
  • Be sure to clean the 3D printed components by gently sanding the surface and the holes.
  • Attach the TP-link ethernet switch to the enclosure prototyping plate with double face tape.

8.4  Window supports

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

8.5  Welds

We recommend to weld the wires on a prototype hat.

8.6  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.
  • 1 Ft ethernet panel mount cable to the TP-link ethernet switch.

8.7  Stepper motor

Use the 18 mm M3 screws to secure the motor on the main support. Be sure to put the washers and the lock washers between the screws heads and the support. This is important because that the vibrations produced by the motor can lead to the screws to unscrew with time.

The stepper motor can become quite hot. To reduce the surface temperature of the motor, install two heat sinks on it. One under and one on the side. This is an important step to protect the PLA main support from suffering of excessive heat.

9.  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 preferred. Be sure that the sky is clear from blocking structure to allow the GPS to connect correctly (if a GPS is used). One must also put some near horizon obstacles to block the direct light from important 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 can comprise a GPS, it is not designed to be used in a roadrunner mode.

10.  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. The standard IP used by the CoSQM is

11.  Downloading the data

11.1  Wired connection

The data are stored into the micro SD card of the Raspberry pi (RPI). In order to access the data, an apache2 web server is configured on the RPI. You can browse the data simply from a web page using the following URL . To do that you first need to plug the network cable of your computer to a router of switch in the sub net 192.168.0.* and configure your pc IPV4 connexion properties. You need to set it to manual configuration mode then set the IP address, net mask 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. Note that the "200" in your computer IP can be replaced by any other address and depending on the local network configuration, a automatic DHCP IP attribution can work.

To access the data, type this in your browser:

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:

wget -r

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

11.2  Wifi access

You can alternatively connect to the cosqm wifi network to access the web server (or the ssh). The wifi SSID is cosqm and the passphrase is cosqmwifi. Your device IP will then be set automatically (if you are using DHCP) to a value between and To access the data, simply do the same as for the wired connection explained above using IP .

12.  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.

13.  Shutdown of the CoSQM

A Shutdown/reboot 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.

14.  Zoom-in pictures

N.B. Since pictures above were taken, the filter wheel, position sensor support and main support have been slightly improved.

GlossyBlue theme adapté par David Gilbert et Martin Aubé
Powered by PmWiki