(:translatelink style=horizontal :)

PLANS - Photometer for Light At Night Sensing

Software package

Introduction

The aim of this project is to develop a system capable of remotely controlling a light pollution monitoring system consisting in a 13 filter slots. Twelve of the slots are filled with narrow-bands filers. The photometer is connected to a raspberry pi 3b and a servo motor filter wheel.

Instead of starting from scratch, we decided to take advantage of the SAND spectrometer software package by adding a new instrument to its palette. Some element of the SAND platform are useless for the PLANS photometer project and then we decided to remove the corresponding sections in the procedure below in order to get it much easy to follow.

The linux distribution used for this system is raspbian Jessie.

We choosed a development philosophy based on a complete control from the Linux command line. The system can be controlled simply with a low speed remote connection provided by a SSH client installed on the user workstation. The raspberry-pi (RPI) connected to the system act as a server.

From internet:

ssh -p 2022 sand@router_public_ip

or

inside a private network

ssh sand@servers_local_ip

From the internet, port 2022 is used instead of standard port 22 to reduce risk of attacks by hackers. A password and user name is required. The standard username is sand. The system administrator should be able to provide you the password for sand.

Installing and configuring subsystems

Hardware profile

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

  1. Raspberry pi 3 B
  2. SanDisk Ultra 32GB microSDHC UHS-I Card
  3. 5mp wide-angle 65 degrees raspberry Camera Module
  4. D-LINK 10/100 a 5 ports ethernet hub (GO-SW-5E)
  5. D-LINK router model DIR-601 or DI-604 or EBR-2310 or equivalent
  6. AUKEY 25W / 5A 5 Ports USB Desktop Charging Station
  7. 20000mAh Dual USB Port Solar Charger & Battery Pack Power Bank
  8. Washdown Electronics Enclosure 11" x 11" x 7" from McMaster-Carr
  9. GPS USB BU-353 usb from GlobalSat
  10. Pololu Micro Maestro 6-Channel USB Servo Controller
  11. HS-422 Servo Motor
  12. SQM-LE from Unihedron
  13. Narroband Intor's 1/2" filters (liste ici)
  14. Servo city PT785-S Pan / Tilt mount (optional)

Basic system installations and dependancies

  • Install raspbian Jessie image on the microSD card
  • Put the microSD card on the Raspberry and power it on.
  • Set time, time zone and date
    • time zone have to be GMT
      • Select None of the above
      • Select GMT
    • Set time and date
    span class="st0">'2017-02-03 01:35:55'
    • Adapt the date and time to your situation.
  • Create the sand account
    span class="st0">"sand  ALL=(ALL:ALL) ALL"
  • Use the raspberry configuration tool to desactivate the Auto login
  • Restart the computer
  • Login as sand
  • Install the following packages

sudo add-apt-repository ppa:jon-severinsson/ffmpeg && sudo apt-get update -qq sudo apt-get install ffmpeg

SSH

SSH server allows any remote SSH client to connect to the server to remotely control system programs from the command line or to download (upstream / downstream) data.

  • We must first be sure that the SSH server start automatically when you start the computer.
  • Select Interfacing Options
    • SSH
      • Yes (to enable ssh)
  • Set up your personal firewall to allow the SSH and http connections to pass through the firewall.

Installing SAND applications

Latest available package release on bitbucket mercurial repository

  • To download SAND apps:
  • Copy apps to system directory:
  • Copy local configuration file

Servo city PT785-S Pan / Tilt mount and filter wheel servo motor

We are using the Pololu Micro Maestro 6-Channel USB Servo Controller to command up to 3 servo motors involved in the system. The motor channels have to be defined in the localconfig file (elev_channel, azim_channel, filter_channel).

Prior to be able to use the Pololu Maestro with the RPI we need to be sure that the maestro is configured in the correct mode. So then you first need a windows computer to do it. Install the maestro software on that computer. You can download it from this page https://www.pololu.com/docs/0J40/3.a

After successful installation, connect the usb cable of the Maestro to the windows computer and then start the Maestro Control Center. Get sure that the Maestro communicate with the computer (look to the Connected to section. Then you can try to move the motor from the Status tab. If you are able to move the motor then go to the Serial setting tab and select USB Dual Port and click on Apply Settings button in the lower right corner. Then you can quit the software and plug the Maestro usb cable to one RPI usb port.

  1. Download the python maestro support:
  1. Then do:
span class="st0">"PYTHONPATH=$PYTHONPATH:/usr/local/bin"

Access to serial/USB ports in order to control mount and to ports video0 or video1 for the mount webcam (if applicable)

It seems that the serial ports are not available by default to a given user in the terminal and the remote web control can not access it. A patch to remedy to this is to put add the sand user to the dialout group.

An external USB webcam will be available on the USB device /dev/video1 instead of /dev/video0 that is allocated to the RPI camera.

Skycalc

Skycalc allows ephemeris calculations that provide, among other time of the astronomical twilight ans sunset. These data will be used to manage the launch of observation requests. However a number of additional information will also be archived in the execution log file as the percentage of the lunar disk illuminated.

  1. Download skycalc.c from link below and save file (probably in /home/sand/Downloads)

Learn more

skycalc manual

D-LINK router configuration

The router is useful when SAND is connected to the Internet and that the appropriate ports are open to take control of the instrument remotely. If the system is not connected to the internet, a simple network switch or hub is sufficient.

  • Router local IP: 192.168.0.1
  • Disable DHCP server and attribute Fixed IP as follow:
    • 192.168.0.100 = control computer
    • 192.168.0.101 = vebcam server
    • 192.168.0.other = any other computer connected temporarly or permanently to the router
  • Create a virtual server to redirect port 2022 of the router toward SSH port 22 of 192.168.0.100
  • Do the same for port 2080 to allow web access redirection (port 80)
  • Create virtual server from port 2180 toward 192.168.0.101 port 80 (webcam server). This redirection will allow a user to see the webcam image from the web even if the computer is off.

Apache server

We are using the Apache web server. This server allow the remote control from a web interface. It allow also browsing the database.

To activate the web server, we must:

  • activate userdir module
sudo a2enmod userdir
sudo service apache2 restart
  • Create the directory /home/sand/public_html modify the permissions by doing:
  • Add the following lines to /etc/apache2/apache2.conf

# added for cosqm
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>

  • Restart the webserver

Webcam server LINKSYS WVC54GC ou D-LINK DCS-920 et webcam logitech quickcam notebook

We are using a webcam server to track cloudiness and transparency of the window during day time. The webcam server is also usefull to measure the ambiant luminosity. This is obtained by taking the mean grey level of the image. If the mean grey level is higher that a given treshold (typically 10 or 20) then the observe script will pause for 15 min before make another verification of the mean grey level. Observe can also decide to begin observation if the ambiant luminosity is under the threshold when the starting observation time is more than 12 hours later.

  • Giving that we can choose between 2 webcam server models, it is absolutely necessary to specify the model in the /home/sand/localconfig file.
  • It is also required to set the network setting so that the DHCP is disabled. We are using fixed address 192.168.0.101 for the webcam server.
  • You should add the sand user in the webcam configuration interface with password that fit the one in the /usr/local/bin/webcamimg script.
  • Another webcam server may be used to monitor the state of the mount. This device should have ip address 192.168.0.102. The user should use the web interface to see this image.
  • Again giving that we can choose between 2 webcam server models, it is absolutely necessary to specify the model in the /home/sand/public_html/cgi-bin/print.cgi file.

crontab

The crond daemon is scheduling repetitive task on lilux system. Users who have the right to use crond can schedule their own tasks to crond. We are using crond to schedule a webcam acquisition every 15 min and to create an animated gif with the last 6 hours images.

Allow sand user to use crond

Allow sand to use cron by doing:

Add program webcamimg to the crond schedule

Edit crontab

Add the following content:

*/15 * * * * /usr/local/bin/webcamimg

Add sand user to the video group

USB GPS BU-353 from GlobalSat

The GPS is controlled by the gpsd server. The GPS startup may easily take 45 seconds (time to connect to available satellites). Sometime, the GPS do not succeed to connect to satellites. Most of the time this occur when satellites are masked by obstacles like mountains or buildings. The observe script is able to extract latitude and longitude from the GPS and use them for ephemeris calculations. To be sure that the gpsd server will startup with the system do the following steps.

Create the script gpsstart into /etc/init.d .

sudo echo "#!/bin/bash" > /etc/init.d/gpsstart
sudo echo "### BEGIN INIT INFO" >> /etc/init.d/gpsstart
sudo echo "# Provides: gpsstart" >> /etc/init.d/gpsstart
sudo echo "# Required-Start: $remote_fs $syslog" >> /etc/init.d/gpsstart
sudo echo "# Required-Stop: $remote_fs $syslog" >> /etc/init.d/gpsstart
sudo echo "# Default-Start: 2 3 4 5" >> /etc/init.d/gpsstart
sudo echo "# Default-Stop: 0 1 6" >> /etc/init.d/gpsstart
sudo echo "# Short-Description: Start daemon at boot time" >> /etc/init.d/gpsstart
sudo echo "# Description: Enable service provided by daemon." >> /etc/init.d/gpsstart
sudo echo "### END INIT INFO" >> /etc/init.d/gpsstart
sudo echo "/usr/sbin/gpsd /dev/ttyUSB0" >> /etc/init.d/gpsstart
cd /etc/init.d
sudo chmod a+x gpsstart
cd /etc/rc5.d
sudo ln -s ../init.d/gpsstart S94gpsstart

UPS control

The UPS is a power battery backup. It will protect the system against power fluctuations and will allow the system to continue its ongoing tasks during short power failure.

  • Use an APC UPS
  • Do:
  • In drakconf->system->services and deamons et enable the apcupsd deamon on startup. Then startup the deamon.
  • Be sure that everything is working properly by doing:

System reboot

Now all the relevant software are installed, in order to activate all newly added functionalities, restart the computer.

Development documentation

Here

User's guide

Jump to SAND user's guide

$StopWatch