diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5fd5a1d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "wxserver"] + path = wxserver + url = https://github.com/gshau/wxserver diff --git a/README.md b/README.md index 186aeff..eb2f66a 100644 --- a/README.md +++ b/README.md @@ -1 +1,13 @@ -# SQM_TSL2591 +# Arduino compatible Sky Quality Meter using the TSL2591 + +This is an application of the TSL 2591 sensor to measuring sky brightness for astronomical applications. It returns the sky brightness in units of magnitude per square arc-second. Also accessible to the user are the raw counts of the visible and IR channels. + +Some features: + - Adaptive exposure and gain control to reduce noise in low light environment. + - Calibration offset can be adjusted by user with ```setCalibrationOffset``` + - Noise estimates given assuming signal counts follow a Poisson process + +This, along with other Arduino projects, can be placed on an ESP8266 module. I have written a library for using these modules to push data to an influx time-series database and display these results using Grafana. Below is a screenshot the Grafana frontend with of one night. Shown are two sensors, one in a weatherstation taking measurements from the sky, and another in a cabinet to illustrate the noise floor. + + +![SQM Chart](/screenshots/SQMdual.png?raw=true "SQM Chart") diff --git a/SQM_TSL2591.cpp b/SQM_TSL2591/SQM_TSL2591.cpp similarity index 100% rename from SQM_TSL2591.cpp rename to SQM_TSL2591/SQM_TSL2591.cpp diff --git a/SQM_TSL2591.h b/SQM_TSL2591/SQM_TSL2591.h similarity index 100% rename from SQM_TSL2591.h rename to SQM_TSL2591/SQM_TSL2591.h diff --git a/example/SQM_TSL2591_example.cpp b/example/SQM_TSL2591_example.cpp new file mode 100644 index 0000000..eb97d35 --- /dev/null +++ b/example/SQM_TSL2591_example.cpp @@ -0,0 +1,54 @@ +/* + SQM_example + Uses a TSL2591 sensor as a Sky Quality Meter + + This example code is in the public domain. + + Gabe Shaughnessy + Oct 21 2017 + */ + + +#include +#include +#include "SQM_TSL2591.h" + +SQM_TSL2591 sqm = SQM_TSL2591(2591); +void readSQM(void); + + + +void setup() { + Serial.begin(9600); + pinMode(13, OUTPUT); + if (sqm.begin()) { + + Serial.println("Found SQM (TSL) sensor"); + sqm.config.gain = TSL2591_GAIN_LOW; + sqm.config.time = TSL2591_INTEGRATIONTIME_200MS; + sqm.configSensor(); + sqm.showConfig(); + sqm.setCalibrationOffset(0.0); + } else{ + Serial.println("SQM sensor not found"); + } + + +} + +void loop() { + digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) + + sqm.takeReading(); + digitalWrite(13, LOW); // turn the LED on (HIGH is the voltage level) + + Serial.print("full: "); Serial.println(sqm.full); + Serial.print("ir: "); Serial.println(sqm.ir); + Serial.print("vis: "); Serial.println(sqm.vis); + Serial.print("mpsas: "); Serial.print(sqm.mpsas); + Serial.print(" +/- "); Serial.println(sqm.dmpsas); + + Serial.println("======================================"); + + delay(5000); +} diff --git a/screenshots/SQMchart.png b/screenshots/SQMchart.png new file mode 100644 index 0000000..7ebc4fb Binary files /dev/null and b/screenshots/SQMchart.png differ diff --git a/screenshots/SQMdual.png b/screenshots/SQMdual.png new file mode 100644 index 0000000..4be4ac4 Binary files /dev/null and b/screenshots/SQMdual.png differ diff --git a/wxserver b/wxserver new file mode 160000 index 0000000..ac77dc3 --- /dev/null +++ b/wxserver @@ -0,0 +1 @@ +Subproject commit ac77dc31eac922befc4fdb745548ae9ee77ee600