Measure nightsky with TSL237

Hi, i am working on a program that is gonna use the TSL237 sensor to measure the night sky darkness That sensor is way more sensitive for low light than for instance the TSL235 that some other has been using, i believe it has a output frequency @ 21.8 ?W/cm2 instead of the TSL235 that has 430 ?W/cm2.

It may be some other differences to? Here is the PDF for it: https://docs.google.com/viewer?a=v&q=cache:Plvrk-_pFQwJ:www.ams.com/eng/content/download/250250/975933/file/TSL237-J.pdf+TSL237&hl=sv&pid=bl&srcid=ADGEESjUTdu6N77Fo19CfVUS9QH3XGxoRrMVamEsH0Ks55GQgOfOke8V-DaDA0qYjHfaNHOmm9-tUJVo5ovLYqdlAONPu6ZyLsKOm_iwdDCqSC2U_2hMFH2ynBy48mAt6bFnG9jLaAYl&sig=AHIEtbShhuCFzTVDeFqfAbEUaVrjHy2ypw

The reason i want to use this is that when i push a button i want to take a reading from the sensor, (or two-three readings and use a median value for better accuracy) and then calculate that value to Magnitude / square arc second http://old.nightwise.org/magnitudes.htm

so i dont wanna do a continous reading, just when i press a button, take a reading, display the magnitude/ square arc second on a lcd for about 10 sec. and then my arduino will continue with the rest of my code (witch is stepper motor controll with steps printout and a DHT-sensor.

Can this be done with some existing code? Do i have to include a frequency library?

BR/ Daniel

That google link is not usable.

The link got me the datasheet.

I wonder how well could be done using a clear IR led as a sensor? Assuming it could be calibrated.

@GoForSome, Using a LED as a sensor you mean?. I think the photosensitive area is pretty small here (and then the current it generates will be in the range of 1pA or even less), but it would be interesting to test them as their are super cheap and you can get them with any spectral range you want (different led colors).

The TSL237 is one of the most sensitive (well, tied with the TSL238, which is just the same but in other package format) photodiodes with integrated amp op and voltage to freq in the market now, but you will probably want to use some kind of IR-cut filter to cover the sensor because it's sensibility peaks on the red - near IR. The Sky Quality Meter (SQM) uses it as it's sensor, I think Corpze just want to build one of those himself.

One of the problems of these sensors is the huge range of frequencies you want to measure, from ~ 0.1 Hz (or even less in 'pristine skies' !) to nearly 1MHz.

I'm also doing some test in this field with the TSL238 and arduino, using FreqCounter (High Frequencies) and pulseIn for low frequencies, but this mix is far from perfect and it's giving me some headaches hehe.

Can this be done with some existing code?

I doubt it, this sounds unique to me. Still the code you need is fairly trivial.

Do i have to include a frequency library?

No you don't. You might be better off writing your own frequency measuring code because then you will know what impact it is having on the rest of your system.

minaya:
@GoForSome, Using a LED as a sensor you mean?. I think the photosensitive area is pretty small here (and then the current it generates will be in the range of 1pA or even less), but it would be interesting to test them as their are super cheap and you can get them with any spectral range you want (different led colors).

There’s a led as a light sensor sketch where you park a led and resistor between two pins. You charge the led as you would a capacitor and that <= 1 pA degrades the minute charge over time. In the dark it could take a few msecs at least, in the bright it could take less than 50 usecs. Mitsubishi Labs uses it for rock solid, dirt cheap wireless and to make self-adjusting brightness LCD’s.

You’re not trying to measure low current except as the time it takes to bring a digital pin LOW. It would only be as good as the calibration at best. But then just how to calibrate closely, I dunno.

Charge in a clear-lens IR led would degrade with near-IR and every higher frequency light. Leds with colored lenses filter what they get IIRC, and even that is used in some apps.

minaya: @GoForSome, Using a LED as a sensor you mean?. I think the photosensitive area is pretty small here (and then the current it generates will be in the range of 1pA or even less), but it would be interesting to test them as their are super cheap and you can get them with any spectral range you want (different led colors).

The TSL237 is one of the most sensitive (well, tied with the TSL238, which is just the same but in other package format) photodiodes with integrated amp op and voltage to freq in the market now, but you will probably want to use some kind of IR-cut filter to cover the sensor because it's sensibility peaks on the red - near IR. The Sky Quality Meter (SQM) uses it as it's sensor, I think Corpze just want to build one of those himself.

One of the problems of these sensors is the huge range of frequencies you want to measure, from ~ 0.1 Hz (or even less in 'pristine skies' !) to nearly 1MHz.

I'm also doing some test in this field with the TSL238 and arduino, using FreqCounter (High Frequencies) and pulseIn for low frequencies, but this mix is far from perfect and it's giving me some headaches hehe.

Yep, thats right, i am gonna build my own SQM, IR and UV-filter is already on its way :) But i still haven´t found any lens that matches the SQM-L lens... (40 degree, -20 - +20 degrees)

This is the code i am talking about: http://arduino.cc/forum/index.php/topic,21536.msg160200.html#msg160200

Wouldn't that go?

I wonder how the conversion from uW/cm2 to mag/sq arc second would look like, and print that out to the LCD :/

SQM lens is just a half-sphere ball lens (you can get them from Edmund Scientific). Those lenses have a really short focal length and a decent aperture.

About the code, every time I try to write an interrupt-driven counter, I end forgiving it and looking for alternatives because of problems like overflows, freezes with intense light (you can fix them, but I think it’s not trivial). And they don’t solve themselves the ‘slow’ frequency reading mode needed in very dark nights (mag>21). For that, you need to count the pulse period (which can be as long as 10 seconds or so on unpolluted skies).

The mag/arcsec2 conversion is as simple as doing

ZP - 2.5*log10(frequency)

where ZP is the zero point, which depends on each individual photometer (sensitivity of your sensor, the filter you are using, the lens characteristics). It’s probably the hardest part of the project if you want to be accurate and you won’t probably get ‘scientific-level’ values unless you can access already calibrated photodiodes / lamps to study the response of your system.

The LCD output is nearly trivial in arduino (both in normal LCDs and I2C ones) :wink:

Here is the breadboard of the SQM, i wonder what kind of lens it is? http://jatobservatory.org/SQM/SQM_kit.html

Is the ZP specified in the datasheet or do i have to find that out for myself?

Best I could hope for would be a relative haze and back-scatter meter. :grin: I'll leave the rest to you guys, the weather service and NASA.

Just a thought... If you know a star's magnitude as seen from orbit then could you judge sky quality by the apparent brightness?

@GoForSmoke, each star contributes to the ‘total’ flux on the sky with the same amount of photons no matter how the sky is polluted. In fact, in urban observatories it’s very possible to do some limited photometry with objects that are bright enough. You just need to ‘subtract’ the background flux to the total (background object) flux and you get the net object flux.

The problem with light pollution is the ‘photonic’ noise it adds. This photonic noise, that scales with the root square of the flux (in photoelectrons) tends to make the observation of a particular object in the sky just impossible if it is dimm. This idea applies to digital astronomical images, but with your eyes the idea is somewhat similar.

@Corpze, the zero point needs to be measured for each individual photometric system, no matter if it’s a telescope ccd, a camera with an objective lens or your little TSL photometers with IR-cut filter and lens. One way (maybe the recommended one) to measure it is using calibrated lamps and calibrated photodiodes as reference. But in the end, you can approximately calibrate it if you know someone who has a SQM or you have a digital camera capable to take fixed exposures images (you calibrate the camera filter lens system with absolute photometry as usual in astronomy, then determine the Night Sky Brightness at some point in the sky with your already calibrated camera, take some measures with the TSL pointing at that direction and derive an approximate Zero Point to match both measures).

As I said, this ZP calibration is (repeat after me) hard if you want to make your instrument scientific-grade. Depends of course in your particular interest, but sometimes people (even in scientific projects) just use them ‘differentially’. If you just need to measure how the sky at some location compares to the sky at other locations (or how it changes over the time), you can even use the direct ‘frequency’ as your variable, no need to mess around on these strange unit systems hehe.

The frequency measured with these photodiodes increases linearly with the number of photons.

minaya:
@GoForSmoke, each star contributes to the ‘total’ flux on the sky with the same amount of photons no matter how the sky is polluted. In fact, in urban observatories it’s very possible to do some limited photometry with objects that are bright enough. You just need to ‘subtract’ the background flux to the total (background object) flux and you get the net object flux.

The problem with light pollution is the ‘photonic’ noise it adds. This photonic noise, that scales with the root square of the flux (in photoelectrons) tends to make the observation of a particular object in the sky just impossible if it is dimm. This idea applies to digital astronomical images, but with your eyes the idea is somewhat similar.

@Corpze, the zero point needs to be measured for each individual photometric system, no matter if it’s a telescope ccd, a camera with an objective lens or your little TSL photometers with IR-cut filter and lens. One way (maybe the recommended one) to measure it is using calibrated lamps and calibrated photodiodes as reference. But in the end, you can approximately calibrate it if you know someone who has a SQM or you have a digital camera capable to take fixed exposures images (you calibrate the camera filter lens system with absolute photometry as usual in astronomy, then determine the Night Sky Brightness at some point in the sky with your already calibrated camera, take some measures with the TSL pointing at that direction and derive an approximate Zero Point to match both measures).

As I said, this ZP calibration is (repeat after me) hard if you want to make your instrument scientific-grade. Depends of course in your particular interest, but sometimes people (even in scientific projects) just use them ‘differentially’. If you just need to measure how the sky at some location compares to the sky at other locations (or how it changes over the time), you can even use the direct ‘frequency’ as your variable, no need to mess around on these strange unit systems hehe.

The frequency measured with these photodiodes increases linearly with the number of photons.

Thanks for your very good answer, i will use the meter for my own, to measure different sites where i do my astrophotographing.

For the ZP i have a luxmeter that i can use, it will not be scientific grade, but good enough for me!

It´s just one thing left, does anyone know what kind of “lensmodule” i have marked on the picture?

SQM-board.jpg

minaya: @GoForSmoke, each star contributes to the 'total' flux on the sky with the same amount of photons no matter how the sky is polluted.

There must be something you say that I don't understand.

Parts of the sky, especially at low alt, do get a lot of particles/dust from natural and man-made sources. At night here we have electric generation stations do their stack cleaning (evidenced by the crap laid down for miles with lead, cadmium and mercury as well as sulfur compounds). For well over 10 years now the pall running from India clear across China has cut sunlight by 15% and more, reducing crop yields. Even CLOUDS reflect light back to space... water and dust pollution!

Somehow I don't think that all the photons from Sirius make it to Earth surface. Flying over Earth it's possible to see how much dust and humidity in the lower atmosphere blur details compared to up in the mountains from the same AGL. And up in the mountains where the air is thinner and doesn't have such a load of junk (first time I really understood was on Pike's Peak) objects miles away look very clear where at sea level they're blurred in less than 2 miles.

When a big volcano pops (Krakatoa around 1880) the whole planet cools just from the dust.

Does starlight get through all that with the same photon count? Sunlight doesn't and the Sun is a star.

I've had the chance to see the night sky from 6500 ft (the saddle between Mauna Loa and Mauna Kea) and 8000-9000 (central north New Mexico) up away from any cities before and wow, the sky doesn't just look more clear but far brighter.

Corpze: Thanks for your very good answer, i will use the meter for my own, to measure different sites where i do my astrophotographing.

For the ZP i have a luxmeter that i can use, it will not be scientific grade, but good enough for me!

It´s just one thing left, does anyone know what kind of "lensmodule" i have marked on the picture?

Oh, and one more question; The code i am gonna start out with is this: http://arduino.cc/forum/index.php/topic,21536.msg160200.html#msg160200

But will that work? it is written for a Arduino duemilanove?

@GoForSmoke.

I didn't mention the important 'extinction' effect (I was just talking about the 'light pollution' effect only, the photons added by human activities). Of course, dust particles extincts and scatters the radiation of objects that are outside the atmosphere, but normally the human effect here isn't as important as one thought (maybe in heavy polluted cities). The main effect of those particles is to reflect the scattered light that comes from cities to the outside.

In high altitude mountains like Mauna Kea, Atacama, Roque de los Muchachos aerosols (these atmospheric particles you mention) abundance is relatively low, and thus is the effect on the night sky.

But of course, if the sky is foggy/cloudy o very polluted (like in Pekin or even at desert with sand storms), you won't see anything. ;).

Which is why I asked about calibration using known magnitude objects . And the haze from India to China and beyond, 15% less sunlight is just scary IMO.

The naked eye view from over 1 mile alt is just freaking amazing! It's better than Hubble pics. Everyone should have the chance. I wonder how few nowadays have every seen the Milky Way as a solid band?

Corpze:

Corpze: Thanks for your very good answer, i will use the meter for my own, to measure different sites where i do my astrophotographing.

For the ZP i have a luxmeter that i can use, it will not be scientific grade, but good enough for me!

It´s just one thing left, does anyone know what kind of "lensmodule" i have marked on the picture?

Oh, and one more question; The code i am gonna start out with is this: http://arduino.cc/forum/index.php/topic,21536.msg160200.html#msg160200

But will that work? it is written for a Arduino duemilanove?

Ok, so iv'e hooked up the sensor but it just recieves 0pulses, 0khz and 0 uw... but in the code, i can´t se that the sensor input pin is initialized? i have hooked it up to pin 5, maybe it is initialized in the freqCounter.h lib?

INPUT LOW is the default state for all I/O pins. It makes them safer for one, kind of a NULL state as opposed to starting up as OUTPUT LOW or HIGH.

I connected the capacitor wrong :stuck_out_tongue: Now it works like a charm… XD

I wonder how and where i am gonna put the formula for converting uW/cm2 to mag/arcsecond2, (according to minaya, its this formula;
ZP - 2.5*log10(frequency) where ZP is my ZeroPoint i will calculate that after i have revcieved the lens if i could find one :~ )
in this code:

#include <FreqCounter.h>



long irradiance;
long freq;
long  pulses;
const float area = 0.0092;
int cnt;
int pinLed=13;
short period = 100; // 100 ms Gate Time

void setup() {
  pinMode(pinLed, OUTPUT);
  Serial.begin(115200);        // connect to the serial port
  Serial.println("Frequency Counter");
}

void loop() {
 light();
 Serial.print(cnt++);
 Serial.print("  Pulses: ");
 Serial.print(pulses);
 Serial.print(";  Freq: ");
 Serial.print(freq);
 Serial.print(" Hz;  Irradiance: ");
 Serial.print(irradiance);
 Serial.println(" uW/cm2 = KHz");
 delay(1000);
}  

void light(){
  digitalWrite(pinLed, HIGH);
  FreqCounter::f_comp=10;   // Cal Value / Calibrate with professional Freq Counter
  FreqCounter::start(period);  // 100 ms Gate Time
  while (FreqCounter::f_ready == 0)
  pulses=FreqCounter::f_freq;
  delay(20);
  digitalWrite(pinLed, LOW);
  freq = (pulses*1000)/(period*area);
  irradiance = (freq/1000);
  return ;
}

You have the code to measure the frequency, so you need to put the conversion to magnitudes after that :wink: . Don’t forget to declare the variable in which you want to save the ‘mag/arcsec2’ value (maybe as global var?). You have an excelent example in how the code you used defines and prints through Serial the variable Irradiance. Just mimic that (change the math expression).

log10 is included in <math.h> library, don’t forget to include it in the header of you sketch.